ili9488: Start updating to new display port interface (#137)
ILI9488: Start updating to new display port interface
This commit is contained in:
parent
2dad083264
commit
c7607e93d8
|
@ -29,6 +29,13 @@ extern "C" {
|
||||||
|
|
||||||
#define ILI9341_INITIAL_ORIENTATION CONFIG_LV_DISPLAY_ORIENTATION
|
#define ILI9341_INITIAL_ORIENTATION CONFIG_LV_DISPLAY_ORIENTATION
|
||||||
|
|
||||||
|
/* ILI9488 Configuration */
|
||||||
|
#if CONFIG_LV_DISP_USE_RST
|
||||||
|
#define ILI9488_USE_RST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ILI9488_INITIAL_ORIENTATION CONFIG_LV_DISPLAY_ORIENTATION
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,7 +14,7 @@ void *disp_driver_init(lv_disp_drv_t *drv)
|
||||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481
|
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481
|
||||||
ili9481_init();
|
ili9481_init();
|
||||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488
|
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488
|
||||||
ili9488_init();
|
ili9488_init(drv);
|
||||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789
|
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789
|
||||||
st7789_init(drv);
|
st7789_init(drv);
|
||||||
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S
|
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
#include "ili9488.h"
|
#include "ili9488.h"
|
||||||
#include "disp_spi.h"
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "disp_spi.h"
|
||||||
#include "freertos/task.h"
|
#include "display_port.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
|
@ -31,11 +29,12 @@ typedef struct {
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC PROTOTYPES
|
* STATIC PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
static void ili9488_set_orientation(uint8_t orientation);
|
static void ili9488_set_orientation(lv_disp_drv_t * drv, uint8_t orientation);
|
||||||
|
|
||||||
static void ili9488_send_cmd(uint8_t cmd);
|
static void ili9488_send_cmd(lv_disp_drv_t * drv, uint8_t cmd);
|
||||||
static void ili9488_send_data(void * data, uint16_t length);
|
static void ili9488_send_data(lv_disp_drv_t * drv, void * data, uint16_t length);
|
||||||
static void ili9488_send_color(void * data, uint16_t length);
|
static void ili9488_send_color(lv_disp_drv_t * drv, void * data, uint16_t length);
|
||||||
|
static void ili9488_reset(lv_disp_drv_t * drv);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
|
@ -50,62 +49,47 @@ static void ili9488_send_color(void * data, uint16_t length);
|
||||||
**********************/
|
**********************/
|
||||||
// From github.com/jeremyjh/ESP32_TFT_library
|
// From github.com/jeremyjh/ESP32_TFT_library
|
||||||
// From github.com/mvturnho/ILI9488-lvgl-ESP32-WROVER-B
|
// From github.com/mvturnho/ILI9488-lvgl-ESP32-WROVER-B
|
||||||
void ili9488_init(void)
|
void ili9488_init(lv_disp_drv_t * drv)
|
||||||
{
|
{
|
||||||
lcd_init_cmd_t ili_init_cmds[]={
|
lcd_init_cmd_t ili_init_cmds[]={
|
||||||
{ILI9488_CMD_SLEEP_OUT, {0x00}, 0x80},
|
{ILI9488_CMD_SLEEP_OUT, {0x00}, 0x80},
|
||||||
{ILI9488_CMD_POSITIVE_GAMMA_CORRECTION, {0x00, 0x03, 0x09, 0x08, 0x16, 0x0A, 0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A, 0x0F}, 15},
|
{ILI9488_CMD_POSITIVE_GAMMA_CORRECTION, {0x00, 0x03, 0x09, 0x08, 0x16, 0x0A, 0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A, 0x0F}, 15},
|
||||||
{ILI9488_CMD_NEGATIVE_GAMMA_CORRECTION, {0x00, 0x16, 0x19, 0x03, 0x0F, 0x05, 0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37, 0x0F}, 15},
|
{ILI9488_CMD_NEGATIVE_GAMMA_CORRECTION, {0x00, 0x16, 0x19, 0x03, 0x0F, 0x05, 0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37, 0x0F}, 15},
|
||||||
{ILI9488_CMD_POWER_CONTROL_1, {0x17, 0x15}, 2},
|
{ILI9488_CMD_POWER_CONTROL_1, {0x17, 0x15}, 2},
|
||||||
{ILI9488_CMD_POWER_CONTROL_2, {0x41}, 1},
|
{ILI9488_CMD_POWER_CONTROL_2, {0x41}, 1},
|
||||||
{ILI9488_CMD_VCOM_CONTROL_1, {0x00, 0x12, 0x80}, 3},
|
{ILI9488_CMD_VCOM_CONTROL_1, {0x00, 0x12, 0x80}, 3},
|
||||||
{ILI9488_CMD_MEMORY_ACCESS_CONTROL, {(0x20 | 0x08)}, 1},
|
{ILI9488_CMD_MEMORY_ACCESS_CONTROL, {(0x20 | 0x08)}, 1},
|
||||||
{ILI9488_CMD_COLMOD_PIXEL_FORMAT_SET, {0x66}, 1},
|
{ILI9488_CMD_COLMOD_PIXEL_FORMAT_SET, {0x66}, 1},
|
||||||
{ILI9488_CMD_INTERFACE_MODE_CONTROL, {0x00}, 1},
|
{ILI9488_CMD_INTERFACE_MODE_CONTROL, {0x00}, 1},
|
||||||
{ILI9488_CMD_FRAME_RATE_CONTROL_NORMAL, {0xA0}, 1},
|
{ILI9488_CMD_FRAME_RATE_CONTROL_NORMAL, {0xA0}, 1},
|
||||||
{ILI9488_CMD_DISPLAY_INVERSION_CONTROL, {0x02}, 1},
|
{ILI9488_CMD_DISPLAY_INVERSION_CONTROL, {0x02}, 1},
|
||||||
{ILI9488_CMD_DISPLAY_FUNCTION_CONTROL, {0x02, 0x02}, 2},
|
{ILI9488_CMD_DISPLAY_FUNCTION_CONTROL, {0x02, 0x02}, 2},
|
||||||
{ILI9488_CMD_SET_IMAGE_FUNCTION, {0x00}, 1},
|
{ILI9488_CMD_SET_IMAGE_FUNCTION, {0x00}, 1},
|
||||||
{ILI9488_CMD_WRITE_CTRL_DISPLAY, {0x28}, 1},
|
{ILI9488_CMD_WRITE_CTRL_DISPLAY, {0x28}, 1},
|
||||||
{ILI9488_CMD_WRITE_DISPLAY_BRIGHTNESS, {0x7F}, 1},
|
{ILI9488_CMD_WRITE_DISPLAY_BRIGHTNESS, {0x7F}, 1},
|
||||||
{ILI9488_CMD_ADJUST_CONTROL_3, {0xA9, 0x51, 0x2C, 0x02}, 4},
|
{ILI9488_CMD_ADJUST_CONTROL_3, {0xA9, 0x51, 0x2C, 0x02}, 4},
|
||||||
{ILI9488_CMD_DISPLAY_ON, {0x00}, 0x80},
|
{ILI9488_CMD_DISPLAY_ON, {0x00}, 0x80},
|
||||||
{0, {0}, 0xff},
|
{0, {0}, 0xff},
|
||||||
};
|
};
|
||||||
|
|
||||||
//Initialize non-SPI GPIOs
|
ili9488_reset(drv);
|
||||||
gpio_pad_select_gpio(ILI9488_DC);
|
|
||||||
gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT);
|
|
||||||
|
|
||||||
#if ILI9488_USE_RST
|
LV_LOG_INFO("ILI9488 initialization.");
|
||||||
gpio_pad_select_gpio(ILI9488_RST);
|
|
||||||
gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT);
|
|
||||||
|
|
||||||
//Reset the display
|
//Send all the commands
|
||||||
gpio_set_level(ILI9488_RST, 0);
|
uint16_t cmd = 0;
|
||||||
vTaskDelay(100 / portTICK_RATE_MS);
|
while (ili_init_cmds[cmd].databytes!=0xff) {
|
||||||
gpio_set_level(ILI9488_RST, 1);
|
ili9488_send_cmd(drv, ili_init_cmds[cmd].cmd);
|
||||||
vTaskDelay(100 / portTICK_RATE_MS);
|
ili9488_send_data(drv, ili_init_cmds[cmd].data, ili_init_cmds[cmd].databytes&0x1F);
|
||||||
#endif
|
|
||||||
|
|
||||||
LV_LOG_INFO("ILI9488 initialization.");
|
if (ili_init_cmds[cmd].databytes & 0x80) {
|
||||||
|
display_port_delay(drv, 100);
|
||||||
|
}
|
||||||
|
|
||||||
// Exit sleep
|
cmd++;
|
||||||
ili9488_send_cmd(0x01); /* Software reset */
|
}
|
||||||
vTaskDelay(100 / portTICK_RATE_MS);
|
|
||||||
|
|
||||||
//Send all the commands
|
ili9488_set_orientation(drv, ILI9488_INITIAL_ORIENTATION);
|
||||||
uint16_t cmd = 0;
|
|
||||||
while (ili_init_cmds[cmd].databytes!=0xff) {
|
|
||||||
ili9488_send_cmd(ili_init_cmds[cmd].cmd);
|
|
||||||
ili9488_send_data(ili_init_cmds[cmd].data, ili_init_cmds[cmd].databytes&0x1F);
|
|
||||||
if (ili_init_cmds[cmd].databytes & 0x80) {
|
|
||||||
vTaskDelay(100 / portTICK_RATE_MS);
|
|
||||||
}
|
|
||||||
cmd++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ili9488_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush function based on mvturnho repo
|
// Flush function based on mvturnho repo
|
||||||
|
@ -117,7 +101,9 @@ void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
||||||
uint8_t *mybuf;
|
uint8_t *mybuf;
|
||||||
do {
|
do {
|
||||||
mybuf = (uint8_t *) heap_caps_malloc(3 * size * sizeof(uint8_t), MALLOC_CAP_DMA);
|
mybuf = (uint8_t *) heap_caps_malloc(3 * size * sizeof(uint8_t), MALLOC_CAP_DMA);
|
||||||
if (mybuf == NULL) LV_LOG_WARN("Could not allocate enough DMA memory!");
|
if (mybuf == NULL) {
|
||||||
|
LV_LOG_WARN("Could not allocate enough DMA memory!");
|
||||||
|
}
|
||||||
} while (mybuf == NULL);
|
} while (mybuf == NULL);
|
||||||
|
|
||||||
uint32_t LD = 0;
|
uint32_t LD = 0;
|
||||||
|
@ -150,17 +136,17 @@ void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
||||||
};
|
};
|
||||||
|
|
||||||
/*Column addresses*/
|
/*Column addresses*/
|
||||||
ili9488_send_cmd(ILI9488_CMD_COLUMN_ADDRESS_SET);
|
ili9488_send_cmd(drv, ILI9488_CMD_COLUMN_ADDRESS_SET);
|
||||||
ili9488_send_data(xb, 4);
|
ili9488_send_data(drv, xb, 4);
|
||||||
|
|
||||||
/*Page addresses*/
|
/*Page addresses*/
|
||||||
ili9488_send_cmd(ILI9488_CMD_PAGE_ADDRESS_SET);
|
ili9488_send_cmd(drv, ILI9488_CMD_PAGE_ADDRESS_SET);
|
||||||
ili9488_send_data(yb, 4);
|
ili9488_send_data(drv, yb, 4);
|
||||||
|
|
||||||
/*Memory write*/
|
/*Memory write*/
|
||||||
ili9488_send_cmd(ILI9488_CMD_MEMORY_WRITE);
|
ili9488_send_cmd(drv, ILI9488_CMD_MEMORY_WRITE);
|
||||||
|
|
||||||
ili9488_send_color((void *) mybuf, size * 3);
|
ili9488_send_color(drv, (void *) mybuf, size * 3);
|
||||||
heap_caps_free(mybuf);
|
heap_caps_free(mybuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,29 +154,38 @@ void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
|
static inline void set_cmd_mode(lv_disp_drv_t * drv)
|
||||||
|
{
|
||||||
|
display_port_gpio_dc(drv, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void ili9488_send_cmd(uint8_t cmd)
|
static inline void set_data_mode(lv_disp_drv_t * drv)
|
||||||
|
{
|
||||||
|
display_port_gpio_dc(drv, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ili9488_send_cmd(lv_disp_drv_t * drv, uint8_t cmd)
|
||||||
{
|
{
|
||||||
disp_wait_for_pending_transactions();
|
disp_wait_for_pending_transactions();
|
||||||
gpio_set_level(ILI9488_DC, 0); /*Command mode*/
|
set_cmd_mode(drv);
|
||||||
disp_spi_send_data(&cmd, 1);
|
disp_spi_send_data(&cmd, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ili9488_send_data(void * data, uint16_t length)
|
static void ili9488_send_data(lv_disp_drv_t * drv, void * data, uint16_t length)
|
||||||
{
|
{
|
||||||
disp_wait_for_pending_transactions();
|
disp_wait_for_pending_transactions();
|
||||||
gpio_set_level(ILI9488_DC, 1); /*Data mode*/
|
set_data_mode(drv);
|
||||||
disp_spi_send_data(data, length);
|
disp_spi_send_data(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ili9488_send_color(void * data, uint16_t length)
|
static void ili9488_send_color(lv_disp_drv_t * drv, void * data, uint16_t length)
|
||||||
{
|
{
|
||||||
disp_wait_for_pending_transactions();
|
disp_wait_for_pending_transactions();
|
||||||
gpio_set_level(ILI9488_DC, 1); /*Data mode*/
|
set_data_mode(drv);
|
||||||
disp_spi_send_colors(data, length);
|
disp_spi_send_colors(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ili9488_set_orientation(uint8_t orientation)
|
static void ili9488_set_orientation(lv_disp_drv_t * drv, uint8_t orientation)
|
||||||
{
|
{
|
||||||
assert(orientation < 4);
|
assert(orientation < 4);
|
||||||
|
|
||||||
|
@ -204,6 +199,20 @@ static void ili9488_set_orientation(uint8_t orientation)
|
||||||
|
|
||||||
LV_LOG_INFO("0x36 command value: 0x%02X", data[orientation]);
|
LV_LOG_INFO("0x36 command value: 0x%02X", data[orientation]);
|
||||||
|
|
||||||
ili9488_send_cmd(0x36);
|
ili9488_send_cmd(drv, 0x36);
|
||||||
ili9488_send_data((void *) &data[orientation], 1);
|
ili9488_send_data(drv, (void *) &data[orientation], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset the display, if we don't have a reset pin we use software reset */
|
||||||
|
static void ili9488_reset(lv_disp_drv_t *drv)
|
||||||
|
{
|
||||||
|
#if defined(ILI9488_USE_RST)
|
||||||
|
display_port_gpio_rst(drv, 0);
|
||||||
|
display_port_delay(drv, 100);
|
||||||
|
display_port_gpio_rst(drv, 1);
|
||||||
|
display_port_delay(drv, 100);
|
||||||
|
#else
|
||||||
|
ili9341_send_cmd(drv, 0x01);
|
||||||
|
display_port_delay(drv, 5);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,13 @@ extern "C" {
|
||||||
#else
|
#else
|
||||||
#include "lvgl/lvgl.h"
|
#include "lvgl/lvgl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../lvgl_helpers.h"
|
#include "../lvgl_helpers.h"
|
||||||
|
#include "display_config.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
#define ILI9488_DC CONFIG_LV_DISP_PIN_DC
|
|
||||||
#define ILI9488_RST CONFIG_LV_DISP_PIN_RST
|
|
||||||
#define ILI9488_USE_RST CONFIG_LV_DISP_USE_RSTS
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
* ILI9488 REGS
|
* ILI9488 REGS
|
||||||
|
@ -144,7 +143,7 @@ typedef struct {
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
void ili9488_init(void);
|
void ili9488_init(lv_disp_drv_t * drv);
|
||||||
void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
|
void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
|
Loading…
Reference in a new issue