lvgl_tft: Remove gpio_pad_select_gpio from drivers init functions

This commit is contained in:
C47D 2022-01-11 19:21:38 -06:00
parent 8cb1b3bdc2
commit 31247430df
6 changed files with 205 additions and 218 deletions

View file

@ -49,7 +49,7 @@ typedef struct {
static void hx8357_send_cmd(uint8_t cmd); static void hx8357_send_cmd(uint8_t cmd);
static void hx8357_send_data(void * data, uint16_t length); static void hx8357_send_data(void * data, uint16_t length);
static void hx8357_send_color(void * data, uint16_t length); static void hx8357_send_color(void * data, uint16_t length);
static void hx8357_reset(void);
/********************** /**********************
* INITIALIZATION ARRAYS * INITIALIZATION ARRAYS
@ -156,20 +156,7 @@ static uint8_t displayType = HX8357D;
void hx8357_init(void) void hx8357_init(void)
{ {
//Initialize non-SPI GPIOs hx8357_reset();
gpio_pad_select_gpio(HX8357_DC);
gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT);
#if HX8357_USE_RST
gpio_pad_select_gpio(HX8357_RST);
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
//Reset the display
gpio_set_level(HX8357_RST, 0);
vTaskDelay(10 / portTICK_RATE_MS);
gpio_set_level(HX8357_RST, 1);
vTaskDelay(120 / portTICK_RATE_MS);
#endif
LV_LOG_INFO("Initialization."); LV_LOG_INFO("Initialization.");
@ -286,3 +273,13 @@ static void hx8357_send_color(void * data, uint16_t length)
gpio_set_level(HX8357_DC, 1); /*Data mode*/ gpio_set_level(HX8357_DC, 1); /*Data mode*/
disp_spi_send_colors(data, length); disp_spi_send_colors(data, length);
} }
static void hx8357_reset(void)
{
#if HX8357_USE_RST
gpio_set_level(HX8357_RST, 0);
vTaskDelay(10 / portTICK_RATE_MS);
gpio_set_level(HX8357_RST, 1);
vTaskDelay(120 / portTICK_RATE_MS);
#endif
}

View file

@ -35,6 +35,7 @@ static void ili9481_set_orientation(uint8_t orientation);
static void ili9481_send_cmd(uint8_t cmd); static void ili9481_send_cmd(uint8_t cmd);
static void ili9481_send_data(void * data, uint16_t length); static void ili9481_send_data(void * data, uint16_t length);
static void ili9481_send_color(void * data, uint16_t length); static void ili9481_send_color(void * data, uint16_t length);
static void ili9481_reset(void);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@ -70,27 +71,10 @@ void ili9481_init(void)
{0, {0}, 0xff}, {0, {0}, 0xff},
}; };
//Initialize non-SPI GPIOs ili9481_reset();
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
LV_LOG_INFO("Initialization."); LV_LOG_INFO("Initialization.");
// Exit sleep
ili9481_send_cmd(0x01); /* Software reset */
vTaskDelay(100 / portTICK_RATE_MS);
//Send all the commands //Send all the commands
uint16_t cmd = 0; uint16_t cmd = 0;
while (ili_init_cmds[cmd].databytes!=0xff) { while (ili_init_cmds[cmd].databytes!=0xff) {
@ -108,7 +92,8 @@ void ili9481_init(void)
// Flush function based on mvturnho repo // Flush function based on mvturnho repo
void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map) 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; lv_color16_t *buffer_16bit = (lv_color16_t *) color_map;
uint8_t *mybuf; 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*/ /*Memory write*/
ili9481_send_cmd(ILI9481_CMD_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); 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_cmd(ILI9481_CMD_MEMORY_ACCESS_CONTROL);
ili9481_send_data((void *) &data[orientation], 1); 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
}

View file

@ -35,7 +35,7 @@ static void ili9486_set_orientation(uint8_t orientation);
static void ili9486_send_cmd(uint8_t cmd); static void ili9486_send_cmd(uint8_t cmd);
static void ili9486_send_data(void * data, uint16_t length); static void ili9486_send_data(void * data, uint16_t length);
static void ili9486_send_color(void * data, uint16_t length); static void ili9486_send_color(void * data, uint16_t length);
static void ili9486_reset(void);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
**********************/ **********************/
@ -63,20 +63,7 @@ void ili9486_init(void)
{0x00, {0}, 0xff}, {0x00, {0}, 0xff},
}; };
//Initialize non-SPI GPIOs ili9486_reset();
gpio_pad_select_gpio(ILI9486_DC);
gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT);
#if ILI9486_USE_RST
gpio_pad_select_gpio(ILI9486_RST);
gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT);
//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."); LV_LOG_INFO("ILI9486 Initialization.");
@ -97,7 +84,8 @@ void ili9486_init(void)
void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map) void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
{ {
uint8_t data[4] = {0}; uint8_t data[4] = {0};
uint32_t size = 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*/ /*Column addresses*/
ili9486_send_cmd(0x2A); ili9486_send_cmd(0x2A);
@ -117,10 +105,7 @@ void ili9486_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
/*Memory write*/ /*Memory write*/
ili9486_send_cmd(0x2C); ili9486_send_cmd(0x2C);
ili9486_send_color((void*) color_map, size);
size = lv_area_get_width(area) * lv_area_get_height(area);
ili9486_send_color((void*) color_map, size * 2);
} }
/********************** /**********************
@ -179,3 +164,13 @@ static void ili9486_set_orientation(uint8_t orientation)
ili9486_send_cmd(0x36); ili9486_send_cmd(0x36);
ili9486_send_data((void *) &data[orientation], 1); 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
}

View file

@ -34,6 +34,7 @@ typedef struct {
static void sh1107_send_cmd(uint8_t cmd); static void sh1107_send_cmd(uint8_t cmd);
static void sh1107_send_data(void * data, uint16_t length); static void sh1107_send_data(void * data, uint16_t length);
static void sh1107_send_color(void * data, uint16_t length); static void sh1107_send_color(void * data, uint16_t length);
static void sh1107_reset(void);
static lv_coord_t get_display_ver_res(lv_disp_drv_t *disp_drv); static lv_coord_t get_display_ver_res(lv_disp_drv_t *disp_drv);
static lv_coord_t get_display_hor_res(lv_disp_drv_t *disp_drv); static lv_coord_t get_display_hor_res(lv_disp_drv_t *disp_drv);
@ -93,20 +94,7 @@ void sh1107_init(void)
{0, {0}, 0xff}, {0, {0}, 0xff},
}; };
//Initialize non-SPI GPIOs sh1107_reset();
gpio_pad_select_gpio(SH1107_DC);
gpio_set_direction(SH1107_DC, GPIO_MODE_OUTPUT);
#if SH1107_USE_RST
gpio_pad_select_gpio(SH1107_RST);
gpio_set_direction(SH1107_RST, GPIO_MODE_OUTPUT);
//Reset the display
gpio_set_level(SH1107_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(SH1107_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
#endif
//Send all the commands //Send all the commands
uint16_t cmd = 0; uint16_t cmd = 0;
@ -257,3 +245,13 @@ static lv_coord_t get_display_hor_res(lv_disp_drv_t *disp_drv)
return val; return val;
} }
static void sh1107_reset(void)
{
#if SH1107_USE_RST
gpio_set_level(SH1107_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(SH1107_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
#endif
}

View file

@ -39,6 +39,7 @@ static void st7735s_send_cmd(uint8_t cmd);
static void st7735s_send_data(void * data, uint16_t length); static void st7735s_send_data(void * data, uint16_t length);
static void st7735s_send_color(void * data, uint16_t length); static void st7735s_send_color(void * data, uint16_t length);
static void st7735s_set_orientation(uint8_t orientation); static void st7735s_set_orientation(uint8_t orientation);
static void st7735s_reset(void);
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192 #ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
static void axp192_write_byte(uint8_t addr, uint8_t data); static void axp192_write_byte(uint8_t addr, uint8_t data);
@ -98,20 +99,7 @@ void st7735s_init(void)
{0, {0}, 0xff} {0, {0}, 0xff}
}; };
//Initialize non-SPI GPIOs st7735s_reset();
gpio_pad_select_gpio(ST7735S_DC);
gpio_set_direction(ST7735S_DC, GPIO_MODE_OUTPUT);
#if ST7735S_USE_RST
gpio_pad_select_gpio(ST7735S_RST);
gpio_set_direction(ST7735S_RST, GPIO_MODE_OUTPUT);
//Reset the display
gpio_set_level(ST7735S_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(ST7735S_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
#endif
LV_LOG_INFO("ST7735S initialization."); LV_LOG_INFO("ST7735S initialization.");
@ -137,7 +125,7 @@ void st7735s_init(void)
void st7735s_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map) void st7735s_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
{ {
uint8_t data[4]; uint8_t data[4] = {0};
/*Column addresses*/ /*Column addresses*/
st7735s_send_cmd(0x2A); st7735s_send_cmd(0x2A);
@ -158,8 +146,8 @@ void st7735s_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
/*Memory write*/ /*Memory write*/
st7735s_send_cmd(0x2C); st7735s_send_cmd(0x2C);
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area); uint32_t size = lv_area_get_width(area) * lv_area_get_height(area) * 2;
st7735s_send_color((void*)color_map, size * 2); st7735s_send_color((void*)color_map, size);
} }
void st7735s_sleep_in() void st7735s_sleep_in()
@ -227,6 +215,16 @@ static void st7735s_set_orientation(uint8_t orientation)
st7735s_send_data((void *) &data[orientation], 1); st7735s_send_data((void *) &data[orientation], 1);
} }
static void st7735s_reset(void)
{
#if ST7735S_USE_RST
gpio_set_level(ST7735S_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(ST7735S_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
#endif
}
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192 #ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
static void axp192_write_byte(uint8_t addr, uint8_t data) static void axp192_write_byte(uint8_t addr, uint8_t data)

View file

@ -36,6 +36,7 @@ static void st7796s_set_orientation(uint8_t orientation);
static void st7796s_send_cmd(uint8_t cmd); static void st7796s_send_cmd(uint8_t cmd);
static void st7796s_send_data(void *data, uint16_t length); static void st7796s_send_data(void *data, uint16_t length);
static void st7796s_send_color(void *data, uint16_t length); static void st7796s_send_color(void *data, uint16_t length);
static void st7796s_reset(void);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@ -79,20 +80,7 @@ void st7796s_init(void)
{0, {0}, 0xff}, {0, {0}, 0xff},
}; };
//Initialize non-SPI GPIOs st7796s_reset();
gpio_pad_select_gpio(ST7796S_DC);
gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT);
#if ST7796S_USE_RST
gpio_pad_select_gpio(ST7796S_RST);
gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT);
//Reset the display
gpio_set_level(ST7796S_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(ST7796S_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
#endif
LV_LOG_INFO("Initialization."); LV_LOG_INFO("Initialization.");
@ -210,3 +198,13 @@ static void st7796s_set_orientation(uint8_t orientation)
st7796s_send_cmd(0x36); st7796s_send_cmd(0x36);
st7796s_send_data((void *)&data[orientation], 1); st7796s_send_data((void *)&data[orientation], 1);
} }
static void st7796s_reset(void)
{
#if ST7796S_USE_RST
gpio_set_level(ST7796S_RST, 0);
vTaskDelay(100 / portTICK_RATE_MS);
gpio_set_level(ST7796S_RST, 1);
vTaskDelay(100 / portTICK_RATE_MS);
#endif
}