Cleanup lvgl_helpers (#171)
* lvgl_spi_conf: Define TFT_SPI_HOST even when no SPI is choosen * lvgl_helpers: Let the SPI driver choose SPI DMA Channel Use SPI_DMA_CH1 only on ESP32 target. * lvgl_helpers: Move FT81X initialization to helper * lvgl_interface_init: Initial cleanup * lvgl_helpers: Replace spi_common_dma_t values with integers This enum was introduced in ESP-IDF v4.3 and can't be used in older versions of ESP-IDF. * lvgl_helpers: Rearrange includes * lvgl_tft: Remove gpio_pad_select_gpio from drivers init functions * lvgl_helpers: Use spi_host_device_t from v4.3 onwards * esp_backlight: Replace gpio with esp_rom API * il3820: Remove GPIO initialization from driver init * FT81x: Replace gpio_pad_select_gpio with esp_rom alias * Fix esp_rom_gpio.h path * FT81x: Fix esp_rom_gpio.h path * adcraw: Disable usage of gpio_pad_select_gpio * GC9A01: Remove usage of gpio_pad_select_gpio * ra8875: Remove usage of gpio_pad_select_gpio * Revert "esp_backlight: Replace gpio with esp_rom API" This reverts commit24e4bf0b88
. * Revert "FT81x: Replace gpio_pad_select_gpio with esp_rom alias" This reverts commit8c7bc42140
. * esp_lcd_backlight: Handle different versions of ESP-IDF * esp_lcd_backlight: Add missing header * lvgl_spi_conf: Add missing include * uc8151d/jd79653a: Fix compilation error when logging is enabled * FT81x: Handle ESP-IDF v4.3 rom_gpio * FT81x: Add missing include * Compilation error when SPI Host is not selected * lvgl_helpers.c: Enable init_ft81x only when FT81X is selected * adcraw: Handle gpio_pad_selection on multiple ESP-IDF versions * esp_lcd_backlight: Remove esp_rom functions * FT81x: Remove esp_rom functions * adcraw: Remove esp_rom functions
This commit is contained in:
parent
8dda9ded4f
commit
463721e291
15 changed files with 337 additions and 325 deletions
|
@ -35,7 +35,7 @@ static void ili9486_set_orientation(uint8_t orientation);
|
|||
static void ili9486_send_cmd(uint8_t cmd);
|
||||
static void ili9486_send_data(void * data, uint16_t length);
|
||||
static void ili9486_send_color(void * data, uint16_t length);
|
||||
|
||||
static void ili9486_reset(void);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
@ -50,77 +50,62 @@ static void ili9486_send_color(void * data, uint16_t length);
|
|||
|
||||
void ili9486_init(void)
|
||||
{
|
||||
lcd_init_cmd_t ili_init_cmds[]={
|
||||
{0x11, {0}, 0x80},
|
||||
{0x3A, {0x55}, 1},
|
||||
{0x2C, {0x44}, 1},
|
||||
{0xC5, {0x00, 0x00, 0x00, 0x00}, 4},
|
||||
{0xE0, {0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00}, 15},
|
||||
{0XE1, {0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00}, 15},
|
||||
{0x20, {0}, 0}, /* display inversion OFF */
|
||||
{0x36, {0x48}, 1},
|
||||
{0x29, {0}, 0x80}, /* display on */
|
||||
{0x00, {0}, 0xff},
|
||||
};
|
||||
lcd_init_cmd_t ili_init_cmds[]={
|
||||
{0x11, {0}, 0x80},
|
||||
{0x3A, {0x55}, 1},
|
||||
{0x2C, {0x44}, 1},
|
||||
{0xC5, {0x00, 0x00, 0x00, 0x00}, 4},
|
||||
{0xE0, {0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00}, 15},
|
||||
{0XE1, {0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00}, 15},
|
||||
{0x20, {0}, 0}, /* display inversion OFF */
|
||||
{0x36, {0x48}, 1},
|
||||
{0x29, {0}, 0x80}, /* display on */
|
||||
{0x00, {0}, 0xff},
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
gpio_pad_select_gpio(ILI9486_DC);
|
||||
gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT);
|
||||
ili9486_reset();
|
||||
|
||||
#if ILI9486_USE_RST
|
||||
gpio_pad_select_gpio(ILI9486_RST);
|
||||
gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT);
|
||||
LV_LOG_INFO("ILI9486 Initialization.");
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9486_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(ILI9486_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
#endif
|
||||
|
||||
LV_LOG_INFO("ILI9486 Initialization.");
|
||||
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
while (ili_init_cmds[cmd].databytes!=0xff) {
|
||||
ili9486_send_cmd(ili_init_cmds[cmd].cmd);
|
||||
ili9486_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++;
|
||||
}
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
while (ili_init_cmds[cmd].databytes!=0xff) {
|
||||
ili9486_send_cmd(ili_init_cmds[cmd].cmd);
|
||||
ili9486_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++;
|
||||
}
|
||||
|
||||
ili9486_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
|
||||
}
|
||||
|
||||
void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
||||
{
|
||||
uint8_t data[4] = {0};
|
||||
uint32_t size = 0;
|
||||
uint8_t data[4] = {0};
|
||||
/* 2 is the number of bytes in color depth */
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area) * 2;
|
||||
|
||||
/*Column addresses*/
|
||||
ili9486_send_cmd(0x2A);
|
||||
data[0] = (area->x1 >> 8) & 0xFF;
|
||||
data[1] = area->x1 & 0xFF;
|
||||
data[2] = (area->x2 >> 8) & 0xFF;
|
||||
data[3] = area->x2 & 0xFF;
|
||||
ili9486_send_data(data, 4);
|
||||
/*Column addresses*/
|
||||
ili9486_send_cmd(0x2A);
|
||||
data[0] = (area->x1 >> 8) & 0xFF;
|
||||
data[1] = area->x1 & 0xFF;
|
||||
data[2] = (area->x2 >> 8) & 0xFF;
|
||||
data[3] = area->x2 & 0xFF;
|
||||
ili9486_send_data(data, 4);
|
||||
|
||||
/*Page addresses*/
|
||||
ili9486_send_cmd(0x2B);
|
||||
data[0] = (area->y1 >> 8) & 0xFF;
|
||||
data[1] = area->y1 & 0xFF;
|
||||
data[2] = (area->y2 >> 8) & 0xFF;
|
||||
data[3] = area->y2 & 0xFF;
|
||||
ili9486_send_data(data, 4);
|
||||
/*Page addresses*/
|
||||
ili9486_send_cmd(0x2B);
|
||||
data[0] = (area->y1 >> 8) & 0xFF;
|
||||
data[1] = area->y1 & 0xFF;
|
||||
data[2] = (area->y2 >> 8) & 0xFF;
|
||||
data[3] = area->y2 & 0xFF;
|
||||
ili9486_send_data(data, 4);
|
||||
|
||||
/*Memory write*/
|
||||
ili9486_send_cmd(0x2C);
|
||||
|
||||
size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
|
||||
ili9486_send_color((void*) color_map, size * 2);
|
||||
/*Memory write*/
|
||||
ili9486_send_cmd(0x2C);
|
||||
ili9486_send_color((void*) color_map, size);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -128,30 +113,30 @@ void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
**********************/
|
||||
static void ili9486_send_cmd(uint8_t cmd)
|
||||
{
|
||||
uint8_t to16bit[] = {
|
||||
0x00, cmd
|
||||
};
|
||||
uint8_t to16bit[] = {
|
||||
0x00, cmd
|
||||
};
|
||||
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ILI9486_DC, 0); /*Command mode*/
|
||||
disp_spi_send_data(to16bit, sizeof to16bit);
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ILI9486_DC, 0); /*Command mode*/
|
||||
disp_spi_send_data(to16bit, sizeof to16bit);
|
||||
}
|
||||
|
||||
static void ili9486_send_data(void * data, uint16_t length)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t to16bit[32];
|
||||
uint8_t * dummy = data;
|
||||
uint32_t i;
|
||||
uint8_t to16bit[32];
|
||||
uint8_t * dummy = data;
|
||||
|
||||
for(i=0; i < (length); i++)
|
||||
{
|
||||
to16bit[2*i+1] = dummy[i];
|
||||
to16bit[2*i] = 0x00;
|
||||
}
|
||||
for(i=0; i < (length); i++)
|
||||
{
|
||||
to16bit[2*i+1] = dummy[i];
|
||||
to16bit[2*i] = 0x00;
|
||||
}
|
||||
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ILI9486_DC, 1); /*Data mode*/
|
||||
disp_spi_send_data(to16bit, (length*2));
|
||||
disp_wait_for_pending_transactions();
|
||||
gpio_set_level(ILI9486_DC, 1); /*Data mode*/
|
||||
disp_spi_send_data(to16bit, (length*2));
|
||||
}
|
||||
|
||||
static void ili9486_send_color(void * data, uint16_t length)
|
||||
|
@ -179,3 +164,13 @@ static void ili9486_set_orientation(uint8_t orientation)
|
|||
ili9486_send_cmd(0x36);
|
||||
ili9486_send_data((void *) &data[orientation], 1);
|
||||
}
|
||||
|
||||
static void ili9486_reset(void)
|
||||
{
|
||||
#if ILI9486_USE_RST
|
||||
gpio_set_level(ILI9486_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(ILI9486_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue