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
|
@ -6,8 +6,11 @@
|
|||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "sdkconfig.h"
|
||||
#include "lvgl_helpers.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "driver/spi_common.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_idf_version.h"
|
||||
|
||||
|
@ -47,6 +50,13 @@
|
|||
*/
|
||||
static int calculate_spi_max_transfer_size(const int display_buffer_size);
|
||||
|
||||
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
|
||||
/**
|
||||
* Handle FT81X initialization as it's a particular case
|
||||
*/
|
||||
static void init_ft81x(int dma_channel);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
@ -68,25 +78,20 @@ void lvgl_interface_init(void)
|
|||
ESP_LOGI(TAG, "Display hor size: %d, ver size: %d", LV_HOR_RES_MAX, LV_VER_RES_MAX);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Display buffer size: %d", lvgl_get_display_buffer_size());
|
||||
|
||||
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
|
||||
ESP_LOGI(TAG, "Initializing SPI master for FT81X");
|
||||
|
||||
size_t display_buffer_size = lvgl_get_display_buffer_size();
|
||||
int spi_max_transfer_size = calculate_spi_max_transfer_size(display_buffer_size);
|
||||
|
||||
lvgl_spi_driver_init(TFT_SPI_HOST,
|
||||
DISP_SPI_MISO, DISP_SPI_MOSI, DISP_SPI_CLK,
|
||||
spi_max_transfer_size, SPI_DMA_CH1,
|
||||
DISP_SPI_IO2, DISP_SPI_IO3);
|
||||
ESP_LOGI(TAG, "Display buffer size: %d", display_buffer_size);
|
||||
|
||||
disp_spi_add_device(TFT_SPI_HOST);
|
||||
|
||||
#if defined (CONFIG_LV_TOUCH_CONTROLLER_FT81X)
|
||||
touch_driver_init();
|
||||
/* SPI DMA Channel selection
|
||||
* SPI_DMA_CH1 is only defined for ESP32, so let the driver choose which
|
||||
* channel to use, and use the proven channel 1 on esp32 targets */
|
||||
int dma_channel = 3;
|
||||
#if defined (CONFIG_IDF_TARGET_ESP32)
|
||||
dma_channel = 1;
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
|
||||
init_ft81x(dma_channel);
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
@ -95,19 +100,19 @@ void lvgl_interface_init(void)
|
|||
ESP_LOGI(TAG, "Initializing SPI master");
|
||||
|
||||
int miso = DISP_SPI_MISO;
|
||||
size_t display_buffer_size = lvgl_get_display_buffer_size();
|
||||
int spi_max_transfer_size = calculate_spi_max_transfer_size(display_buffer_size);
|
||||
|
||||
/* Set the miso signal to be the selected for the touch driver */
|
||||
#if defined (SHARED_SPI_BUS)
|
||||
miso = TP_SPI_MISO;
|
||||
#endif
|
||||
|
||||
lvgl_spi_driver_init(TFT_SPI_HOST,
|
||||
miso, DISP_SPI_MOSI, DISP_SPI_CLK,
|
||||
spi_max_transfer_size, SPI_DMA_CH1,
|
||||
DISP_SPI_IO2, DISP_SPI_IO3);
|
||||
lvgl_spi_driver_init(TFT_SPI_HOST, miso, DISP_SPI_MOSI, DISP_SPI_CLK,
|
||||
spi_max_transfer_size, dma_channel, DISP_SPI_IO2, DISP_SPI_IO3);
|
||||
|
||||
disp_spi_add_device(TFT_SPI_HOST);
|
||||
|
||||
/* Add device for touch driver */
|
||||
#if defined (SHARED_SPI_BUS)
|
||||
tp_spi_add_device(TOUCH_SPI_HOST);
|
||||
touch_driver_init();
|
||||
|
@ -122,26 +127,28 @@ void lvgl_interface_init(void)
|
|||
|
||||
/* Touch controller initialization */
|
||||
#if CONFIG_LV_TOUCH_CONTROLLER != TOUCH_CONTROLLER_NONE
|
||||
#if defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI)
|
||||
#if defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI)
|
||||
ESP_LOGI(TAG, "Initializing SPI master for touch");
|
||||
|
||||
lvgl_spi_driver_init(TOUCH_SPI_HOST,
|
||||
TP_SPI_MISO, TP_SPI_MOSI, TP_SPI_CLK,
|
||||
DMA_DEFAULT_TRANSFER_SIZE, SPI_DMA_CH2,
|
||||
GPIO_NOT_USED, GPIO_NOT_USED);
|
||||
#if defined (CONFIG_IDF_TARGET_ESP32)
|
||||
dma_channel = 2;
|
||||
#endif
|
||||
|
||||
lvgl_spi_driver_init(TOUCH_SPI_HOST, TP_SPI_MISO, TP_SPI_MOSI, TP_SPI_CLK,
|
||||
DMA_DEFAULT_TRANSFER_SIZE, dma_channel, GPIO_NOT_USED, GPIO_NOT_USED);
|
||||
|
||||
tp_spi_add_device(TOUCH_SPI_HOST);
|
||||
|
||||
touch_driver_init();
|
||||
#elif defined (CONFIG_LV_I2C_TOUCH)
|
||||
#elif defined (CONFIG_LV_I2C_TOUCH)
|
||||
touch_driver_init();
|
||||
#elif defined (CONFIG_LV_TOUCH_DRIVER_ADC)
|
||||
#elif defined (CONFIG_LV_TOUCH_DRIVER_ADC)
|
||||
touch_driver_init();
|
||||
#elif defined (CONFIG_LV_TOUCH_DRIVER_DISPLAY)
|
||||
#elif defined (CONFIG_LV_TOUCH_DRIVER_DISPLAY)
|
||||
touch_driver_init();
|
||||
#else
|
||||
#error "No protocol defined for touch controller"
|
||||
#endif
|
||||
#else
|
||||
#error "No protocol defined for touch controller"
|
||||
#endif
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
@ -254,7 +261,7 @@ size_t lvgl_get_display_buffer_size(void)
|
|||
* We could use the ESP_IDF_VERSION_VAL macro available in the "esp_idf_version.h"
|
||||
* header available since ESP-IDF v4.
|
||||
*/
|
||||
bool lvgl_spi_driver_init(spi_host_device_t host,
|
||||
bool lvgl_spi_driver_init(int host,
|
||||
int miso_pin, int mosi_pin, int sclk_pin,
|
||||
int max_transfer_sz,
|
||||
int dma_channel,
|
||||
|
@ -286,12 +293,9 @@ bool lvgl_spi_driver_init(spi_host_device_t host,
|
|||
};
|
||||
|
||||
ESP_LOGI(TAG, "Initializing SPI bus...");
|
||||
#if defined (CONFIG_IDF_TARGET_ESP32C3)
|
||||
dma_channel = SPI_DMA_CH_AUTO;
|
||||
#endif
|
||||
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
|
||||
esp_err_t ret = spi_bus_initialize(host, &buscfg, (spi_dma_chan_t)dma_channel);
|
||||
esp_err_t ret = spi_bus_initialize((spi_host_device_t) host, &buscfg, (spi_dma_chan_t)dma_channel);
|
||||
#else
|
||||
esp_err_t ret = spi_bus_initialize(host, &buscfg, dma_channel);
|
||||
#endif
|
||||
|
@ -324,3 +328,20 @@ static int calculate_spi_max_transfer_size(const int display_buffer_size)
|
|||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
|
||||
static void init_ft81x(int dma_channel)
|
||||
{
|
||||
size_t display_buffer_size = lvgl_get_display_buffer_size();
|
||||
int spi_max_transfer_size = calculate_spi_max_transfer_size(display_buffer_size);
|
||||
|
||||
lvgl_spi_driver_init(TFT_SPI_HOST, DISP_SPI_MISO, DISP_SPI_MOSI, DISP_SPI_CLK,
|
||||
spi_max_transfer_size, dma_channel, DISP_SPI_IO2, DISP_SPI_IO3);
|
||||
|
||||
disp_spi_add_device(TFT_SPI_HOST);
|
||||
|
||||
#if defined (CONFIG_LV_TOUCH_CONTROLLER_FT81X)
|
||||
touch_driver_init();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -14,8 +14,6 @@ extern "C" {
|
|||
*********************/
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "driver/spi_common.h"
|
||||
|
||||
#include "lvgl_spi_conf.h"
|
||||
#include "lvgl_tft/disp_driver.h"
|
||||
#include "lvgl_tft/esp_lcd_backlight.h"
|
||||
|
@ -39,7 +37,7 @@ void lvgl_i2c_locking(void* leader);
|
|||
void lvgl_interface_init(void);
|
||||
|
||||
/* Initialize SPI master */
|
||||
bool lvgl_spi_driver_init(spi_host_device_t host, int miso_pin, int mosi_pin, int sclk_pin,
|
||||
bool lvgl_spi_driver_init(int host, int miso_pin, int mosi_pin, int sclk_pin,
|
||||
int max_transfer_sz, int dma_channel, int quadwp_pin, int quadhd_pin);
|
||||
|
||||
/* Initialize display GPIOs, e.g. DC and RST pins */
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#ifndef LVGL_SPI_CONF_H
|
||||
#define LVGL_SPI_CONF_H
|
||||
|
||||
#include <sdkconfig.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -73,11 +75,15 @@ extern "C" {
|
|||
|
||||
#define ENABLE_TOUCH_INPUT CONFIG_LV_ENABLE_TOUCH
|
||||
|
||||
#if defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_SPI)
|
||||
/* Display controller SPI host configuration */
|
||||
#if defined (CONFIG_LV_TFT_DISPLAY_SPI2_HOST)
|
||||
#define TFT_SPI_HOST SPI2_HOST
|
||||
#elif defined (CONFIG_LV_TFT_DISPLAY_SPI3_HOST)
|
||||
#define TFT_SPI_HOST SPI3_HOST
|
||||
#else
|
||||
#error SPI host not defined
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Touch controller SPI host configuration */
|
||||
|
|
|
@ -36,6 +36,7 @@ static void GC9A01_set_orientation(uint8_t orientation);
|
|||
static void GC9A01_send_cmd(uint8_t cmd);
|
||||
static void GC9A01_send_data(void * data, uint16_t length);
|
||||
static void GC9A01_send_color(void * data, uint16_t length);
|
||||
static void GC9A01_reset(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -110,20 +111,7 @@ void GC9A01_init(void)
|
|||
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
gpio_pad_select_gpio(GC9A01_DC);
|
||||
gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if GC9A01_USE_RST
|
||||
gpio_pad_select_gpio(GC9A01_RST);
|
||||
gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(GC9A01_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(GC9A01_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
#endif
|
||||
GC9A01_reset();
|
||||
|
||||
LV_LOG_INFO("Initialization.");
|
||||
|
||||
|
@ -241,3 +229,14 @@ static void GC9A01_set_orientation(uint8_t orientation)
|
|||
GC9A01_send_cmd(0x36);
|
||||
GC9A01_send_data((void *) &data[orientation], 1);
|
||||
}
|
||||
|
||||
static void GC9A01_reset(void)
|
||||
{
|
||||
#if GC9A01_USE_RST
|
||||
//Reset the display
|
||||
gpio_set_level(GC9A01_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
gpio_set_level(GC9A01_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ typedef struct {
|
|||
static void hx8357_send_cmd(uint8_t cmd);
|
||||
static void hx8357_send_data(void * data, uint16_t length);
|
||||
static void hx8357_send_color(void * data, uint16_t length);
|
||||
|
||||
static void hx8357_reset(void);
|
||||
|
||||
/**********************
|
||||
* INITIALIZATION ARRAYS
|
||||
|
@ -156,20 +156,7 @@ static uint8_t displayType = HX8357D;
|
|||
|
||||
void hx8357_init(void)
|
||||
{
|
||||
//Initialize non-SPI GPIOs
|
||||
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
|
||||
hx8357_reset();
|
||||
|
||||
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*/
|
||||
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
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ static inline void il3820_set_window( uint16_t sx, uint16_t ex, uint16_t ys, uin
|
|||
static inline void il3820_set_cursor(uint16_t sx, uint16_t ys);
|
||||
static void il3820_update_display(void);
|
||||
static void il3820_clear_cntlr_mem(uint8_t ram_cmd, bool update);
|
||||
static void il3820_reset(void);
|
||||
|
||||
/* Required by LVGL */
|
||||
void il3820_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
|
||||
|
@ -195,26 +196,7 @@ void il3820_init(void)
|
|||
{
|
||||
uint8_t tmp[3] = {0};
|
||||
|
||||
/* Initialize non-SPI GPIOs */
|
||||
gpio_pad_select_gpio(IL3820_DC_PIN);
|
||||
gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT);
|
||||
|
||||
gpio_pad_select_gpio(IL3820_BUSY_PIN);
|
||||
gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT);
|
||||
|
||||
#if IL3820_USE_RST
|
||||
gpio_pad_select_gpio(IL3820_RST_PIN);
|
||||
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
|
||||
|
||||
/* Harware reset */
|
||||
gpio_set_level( IL3820_RST_PIN, 0);
|
||||
vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS);
|
||||
gpio_set_level( IL3820_RST_PIN, 1);
|
||||
vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS);
|
||||
#endif
|
||||
|
||||
/* Software reset */
|
||||
il3820_write_cmd(IL3820_CMD_SW_RESET, NULL, 0);
|
||||
il3820_reset();
|
||||
|
||||
/* Busy wait for the BUSY signal to go low */
|
||||
il3820_waitbusy(IL3820_WAIT);
|
||||
|
@ -416,3 +398,17 @@ static void il3820_clear_cntlr_mem(uint8_t ram_cmd, bool update)
|
|||
il3820_update_display();
|
||||
}
|
||||
}
|
||||
|
||||
static void il3820_reset(void)
|
||||
{
|
||||
#if IL3820_USE_RST
|
||||
/* Harware reset */
|
||||
gpio_set_level( IL3820_RST_PIN, 0);
|
||||
vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS);
|
||||
gpio_set_level( IL3820_RST_PIN, 1);
|
||||
vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS);
|
||||
#endif
|
||||
|
||||
/* Software reset */
|
||||
il3820_write_cmd(IL3820_CMD_SW_RESET, NULL, 0);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
**********************/
|
||||
|
@ -63,20 +63,7 @@ void ili9486_init(void)
|
|||
{0x00, {0}, 0xff},
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
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
|
||||
ili9486_reset();
|
||||
|
||||
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)
|
||||
{
|
||||
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*/
|
||||
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*/
|
||||
ili9486_send_cmd(0x2C);
|
||||
|
||||
size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
|
||||
ili9486_send_color((void*) color_map, size * 2);
|
||||
ili9486_send_color((void*) color_map, size);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -417,8 +417,11 @@ void jd79653a_lv_rounder_cb(lv_disp_drv_t *disp_drv, lv_area_t *area)
|
|||
|
||||
void jd79653a_lv_fb_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
|
||||
{
|
||||
#if LV_USE_LOG
|
||||
size_t len = ((area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1)) / 8;
|
||||
LV_LOG_INFO("x1: 0x%x, x2: 0x%x, y1: 0x%x, y2: 0x%x", area->x1, area->x2, area->y1, area->y2);
|
||||
LV_LOG_INFO("Writing LVGL fb with len: %u, partial counter: %u", len, partial_counter);
|
||||
#endif
|
||||
|
||||
uint8_t *buf = (uint8_t *) color_map;
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ static void ra8875_configure_clocks(bool high_speed);
|
|||
static void ra8875_set_memory_write_cursor(unsigned int x, unsigned int y);
|
||||
static void ra8875_set_window(unsigned int xs, unsigned int xe, unsigned int ys, unsigned int ye);
|
||||
static void ra8875_send_buffer(uint8_t * data, size_t length, bool signal_flush);
|
||||
|
||||
static void ra8875_reset(void);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
@ -180,18 +180,7 @@ void ra8875_init(void)
|
|||
|
||||
LV_LOG_INFO("Initializing RA8875...");
|
||||
|
||||
// Initialize non-SPI GPIOs
|
||||
|
||||
#if RA8875_USE_RST
|
||||
gpio_pad_select_gpio(RA8875_RST);
|
||||
gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
// Reset the RA8875
|
||||
gpio_set_level(RA8875_RST, 0);
|
||||
vTaskDelay(DIV_ROUND_UP(100, portTICK_RATE_MS));
|
||||
gpio_set_level(RA8875_RST, 1);
|
||||
vTaskDelay(DIV_ROUND_UP(100, portTICK_RATE_MS));
|
||||
#endif
|
||||
ra8875_reset();
|
||||
|
||||
// Initalize RA8875 clocks (SPI must be decelerated before initializing clocks)
|
||||
disp_spi_change_device_speed(SPI_CLOCK_SPEED_SLOW_HZ);
|
||||
|
@ -376,3 +365,13 @@ static void ra8875_send_buffer(uint8_t * data, size_t length, bool signal_flush)
|
|||
| (RA8875_MODE_DATA_WRITE); // Data write mode
|
||||
disp_spi_transaction(data, length, flags, NULL, prefix, 0);
|
||||
}
|
||||
|
||||
static void ra8875_reset(void)
|
||||
{
|
||||
#if RA8875_USE_RST
|
||||
gpio_set_level(RA8875_RST, 0);
|
||||
vTaskDelay(DIV_ROUND_UP(100, portTICK_RATE_MS));
|
||||
gpio_set_level(RA8875_RST, 1);
|
||||
vTaskDelay(DIV_ROUND_UP(100, portTICK_RATE_MS));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct {
|
|||
static void sh1107_send_cmd(uint8_t cmd);
|
||||
static void sh1107_send_data(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_hor_res(lv_disp_drv_t *disp_drv);
|
||||
|
@ -93,20 +94,7 @@ void sh1107_init(void)
|
|||
{0, {0}, 0xff},
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
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
|
||||
sh1107_reset();
|
||||
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
|
@ -257,3 +245,13 @@ static lv_coord_t get_display_hor_res(lv_disp_drv_t *disp_drv)
|
|||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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_color(void * data, uint16_t length);
|
||||
static void st7735s_set_orientation(uint8_t orientation);
|
||||
static void st7735s_reset(void);
|
||||
|
||||
#ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192
|
||||
static void axp192_write_byte(uint8_t addr, uint8_t data);
|
||||
|
@ -98,20 +99,7 @@ void st7735s_init(void)
|
|||
{0, {0}, 0xff}
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
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
|
||||
st7735s_reset();
|
||||
|
||||
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)
|
||||
{
|
||||
uint8_t data[4];
|
||||
uint8_t data[4] = {0};
|
||||
|
||||
/*Column addresses*/
|
||||
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*/
|
||||
st7735s_send_cmd(0x2C);
|
||||
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
st7735s_send_color((void*)color_map, size * 2);
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area) * 2;
|
||||
st7735s_send_color((void*)color_map, size);
|
||||
}
|
||||
|
||||
void st7735s_sleep_in()
|
||||
|
@ -227,6 +215,16 @@ static void st7735s_set_orientation(uint8_t orientation)
|
|||
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
|
||||
|
||||
static void axp192_write_byte(uint8_t addr, uint8_t data)
|
||||
|
|
|
@ -36,6 +36,7 @@ static void st7796s_set_orientation(uint8_t orientation);
|
|||
static void st7796s_send_cmd(uint8_t cmd);
|
||||
static void st7796s_send_data(void *data, uint16_t length);
|
||||
static void st7796s_send_color(void *data, uint16_t length);
|
||||
static void st7796s_reset(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -79,20 +80,7 @@ void st7796s_init(void)
|
|||
{0, {0}, 0xff},
|
||||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
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
|
||||
st7796s_reset();
|
||||
|
||||
LV_LOG_INFO("Initialization.");
|
||||
|
||||
|
@ -210,3 +198,13 @@ static void st7796s_set_orientation(uint8_t orientation)
|
|||
st7796s_send_cmd(0x36);
|
||||
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
|
||||
}
|
||||
|
|
|
@ -189,8 +189,11 @@ static void uc8151d_full_update(uint8_t *buf)
|
|||
|
||||
void uc8151d_lv_fb_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
|
||||
{
|
||||
#if LV_USE_LOG
|
||||
size_t len = ((area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1)) / 8;
|
||||
LV_LOG_INFO("x1: 0x%x, x2: 0x%x, y1: 0x%x, y2: 0x%x", area->x1, area->x2, area->y1, area->y2);
|
||||
LV_LOG_INFO("Writing LVGL fb with len: %u", len);
|
||||
#endif
|
||||
|
||||
uint8_t *buf = (uint8_t *) color_map;
|
||||
uc8151d_full_update(buf);
|
||||
|
|
Loading…
Reference in a new issue