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,6 +35,7 @@ static void ili9481_set_orientation(uint8_t orientation);
|
|||
static void ili9481_send_cmd(uint8_t cmd);
|
||||
static void ili9481_send_data(void * data, uint16_t length);
|
||||
static void ili9481_send_color(void * data, uint16_t length);
|
||||
static void ili9481_reset(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -70,27 +71,10 @@ void ili9481_init(void)
|
|||
{0, {0}, 0xff},
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
gpio_pad_select_gpio(ILI9481_DC);
|
||||
gpio_set_direction(ILI9481_DC, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ILI9481_USE_RST
|
||||
gpio_pad_select_gpio(ILI9481_RST);
|
||||
gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9481_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(ILI9481_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
#endif
|
||||
ili9481_reset();
|
||||
|
||||
LV_LOG_INFO("Initialization.");
|
||||
|
||||
// Exit sleep
|
||||
ili9481_send_cmd(0x01); /* Software reset */
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
while (ili_init_cmds[cmd].databytes!=0xff) {
|
||||
|
@ -108,7 +92,8 @@ void ili9481_init(void)
|
|||
// Flush function based on mvturnho repo
|
||||
void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
||||
{
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
/* 3 is number of bytes in lv_color_t */
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area) * 3;
|
||||
|
||||
lv_color16_t *buffer_16bit = (lv_color16_t *) color_map;
|
||||
uint8_t *mybuf;
|
||||
|
@ -159,7 +144,9 @@ void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
/*Memory write*/
|
||||
ili9481_send_cmd(ILI9481_CMD_MEMORY_WRITE);
|
||||
|
||||
ili9481_send_color((void *) mybuf, size * 3);
|
||||
ili9481_send_color((void *) mybuf, size);
|
||||
|
||||
/* FIXME: Can we free the memory even when it's being transferred? */
|
||||
heap_caps_free(mybuf);
|
||||
}
|
||||
|
||||
|
@ -203,3 +190,17 @@ static void ili9481_set_orientation(uint8_t orientation)
|
|||
ili9481_send_cmd(ILI9481_CMD_MEMORY_ACCESS_CONTROL);
|
||||
ili9481_send_data((void *) &data[orientation], 1);
|
||||
}
|
||||
|
||||
static void ili9481_reset(void)
|
||||
{
|
||||
#if ILI9481_USE_RST
|
||||
gpio_set_level(ILI9481_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(ILI9481_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
#else
|
||||
// Exit sleep, software reset
|
||||
ili9481_send_cmd(0x01);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue