minor fixes

This commit is contained in:
Vitor Alho 2023-09-05 12:33:09 -03:00
parent 6a6fdcf289
commit 1cf7dd0876
3 changed files with 33 additions and 24 deletions

View file

@ -18,7 +18,8 @@ extern "C" {
#include "lvgl_tft/disp_driver.h" #include "lvgl_tft/disp_driver.h"
#include "lvgl_tft/esp_lcd_backlight.h" #include "lvgl_tft/esp_lcd_backlight.h"
#include "lvgl_touch/touch_driver.h" #include "lvgl_touch/touch_driver.h"
#include "hal/spi_hal.h"
#include "esp_idf_version.h"
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@ -38,10 +39,9 @@ extern "C" {
# endif # endif
#endif #endif
#ifdef USE_PORT_TICK_PERIOD_MS #if ESP_IDF_VERSION_MAJOR >= 5
#define portTICK_DELAY_MS portTICK_PERIOD_MS #define portTICK_DELAY_MS portTICK_PERIOD_MS
#else #elif USE_PORT_TICK_RATE_MS
#ifdef USE_PORT_TICK_RATE_MS
#define portTICK_DELAY_MS portTICK_RATE_MS #define portTICK_DELAY_MS portTICK_RATE_MS
#endif #endif
@ -57,9 +57,17 @@ extern "C" {
* When using the mono theme, the display pixels can be represented in one bit, * When using the mono theme, the display pixels can be represented in one bit,
* so the buffer size can be divided by 8, e.g. see SSD1306 display size. */ * so the buffer size can be divided by 8, e.g. see SSD1306 display size. */
#define TFT_DISPLAY_BUFFER_SIZE (TFT_DISPLAY_BUFFER_SIZE_OVERFLOW_PROTECTION * 3 * 8) #define TFT_DISPLAY_BUFFER_SIZE_IN_BITS (LV_HOR_RES_MAX * 40 * 3 * 8)
#define TFT_DISPLAY_BUFFER_SIZE_OVERFLOW_PROTECTION (TFT_DISPLAY_BUFFER_SIZE>SPI_LL_DMA_MAX_BIT_LEN)? SPI_LL_DMA_MAX_BIT_LEN-1000 : #define TFT_DISPLAY_BUFFER_SIZE (LV_HOR_RES_MAX * 40)
#include "spi_master.h"
#if CONFIG_IDF_TARGET_ESP32S3
#define DMA_MAX_BIT_LENGHT (1<<18) // according with SPI_LL_DMA_MAX_BIT_LEN in spi_ll.h
#else
#define DMA_MAX_BIT_LENGHT (1<<24) // according with SPI_LL_DMA_MAX_BIT_LEN in spi_ll.h
#endif
#define TFT_DISPLAY_BUFFER_SIZE_OVERFLOW_PROTECTION ((TFT_DISPLAY_BUFFER_SIZE_IN_BITS>DMA_MAX_BIT_LENGHT)? (((DMA_MAX_BIT_LENGHT-1000)/8)/3) :TFT_DISPLAY_BUFFER_SIZE)
#if defined (CONFIG_CUSTOM_DISPLAY_BUFFER_SIZE) #if defined (CONFIG_CUSTOM_DISPLAY_BUFFER_SIZE)
#define DISP_BUF_SIZE CONFIG_CUSTOM_DISPLAY_BUFFER_BYTES #define DISP_BUF_SIZE CONFIG_CUSTOM_DISPLAY_BUFFER_BYTES
#else #else
@ -82,15 +90,15 @@ extern "C" {
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341
#define DISP_BUF_SIZE (TFT_DISPLAY_BUFFER_SIZE_OVERFLOW_PROTECTION) #define DISP_BUF_SIZE (TFT_DISPLAY_BUFFER_SIZE_OVERFLOW_PROTECTION)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SSD1306 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SSD1306
#if defined (CONFIG_LV_THEME_MONO) #if defined (CONFIG_LV_THEME_MONO)
#define TFT_DISPLAY_MONO_BUFFER_SIZE (LV_HOR_RES_MAX * (LV_VER_RES_MAX / 8)) #define TFT_DISPLAY_MONO_BUFFER_SIZE (LV_HOR_RES_MAX * (LV_VER_RES_MAX / 8))
#define TFT_DISPLAY_MONO_BUFFER_SIZE_OVERFLOW_PROTECTION (TFT_DISPLAY_MONO_BUFFER_SIZE>SPI_LL_DMA_MAX_BIT_LEN)? SPI_LL_DMA_MAX_BIT_LEN-1000 : #define TFT_DISPLAY_MONO_BUFFER_SIZE_OVERFLOW_PROTECTION (TFT_DISPLAY_MONO_BUFFER_SIZE>SPI_LL_DMA_MAX_BIT_LEN)? SPI_LL_DMA_MAX_BIT_LEN-1000 :
#define DISP_BUF_SIZE (TFT_DISPLAY_MONO_BUFFER_SIZE_OVERFLOW_PROTECTION) #define DISP_BUF_SIZE (TFT_DISPLAY_MONO_BUFFER_SIZE_OVERFLOW_PROTECTION)
#else #else
#define TFT_DISPLAY_MONO_BUFFER_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX) #define TFT_DISPLAY_MONO_BUFFER_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX)
#define TFT_DISPLAY_MONO_BUFFER_SIZE_OVERFLOW_PROTECTION (TFT_DISPLAY_MONO_BUFFER_SIZE>SPI_LL_DMA_MAX_BIT_LEN)? SPI_LL_DMA_MAX_BIT_LEN-1000 : #define TFT_DISPLAY_MONO_BUFFER_SIZE_OVERFLOW_PROTECTION (TFT_DISPLAY_MONO_BUFFER_SIZE>SPI_LL_DMA_MAX_BIT_LEN)? SPI_LL_DMA_MAX_BIT_LEN-1000 :
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX)
#endif #endif
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X) #elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
#define DISP_BUF_LINES 40 #define DISP_BUF_LINES 40
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * DISP_BUF_LINES) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * DISP_BUF_LINES)

View file

@ -12,6 +12,7 @@
#include "esp_log.h" #include "esp_log.h"
#include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3 #include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "esp_idf_version.h"
typedef struct { typedef struct {
bool pwm_control; // true: LEDC is used, false: GPIO is used bool pwm_control; // true: LEDC is used, false: GPIO is used
@ -50,7 +51,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
}; };
const ledc_timer_config_t LCD_backlight_timer = { const ledc_timer_config_t LCD_backlight_timer = {
.speed_mode = LEDC_LOW_SPEED_MODE, .speed_mode = LEDC_LOW_SPEED_MODE,
#ifdef ESP_IDF_VERSION_MAJOR >=5 #if ESP_IDF_VERSION_MAJOR >= 5
.duty_resolution = LEDC_TIMER_10_BIT, .duty_resolution = LEDC_TIMER_10_BIT,
#else #else
.bit_num = LEDC_TIMER_10_BIT, .bit_num = LEDC_TIMER_10_BIT,
@ -61,7 +62,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer)); ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer));
ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel)); ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel));
#ifdef ESP_IDF_VERSION_MAJOR >=5 #if ESP_IDF_VERSION_MAJOR >= 5
esp_rom_gpio_connect_out_signal(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert,0); esp_rom_gpio_connect_out_signal(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert,0);
#else #else
gpio_matrix_out(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0); gpio_matrix_out(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0);
@ -72,7 +73,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config)
// Configure GPIO for output // Configure GPIO for output
bckl_dev->index = config->gpio_num; bckl_dev->index = config->gpio_num;
#ifdef ESP_IDF_VERSION_MAJOR >=5 #if ESP_IDF_VERSION_MAJOR >= 5
esp_rom_gpio_connect_out_signal(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false); esp_rom_gpio_connect_out_signal(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false);
esp_rom_gpio_pad_select_gpio(config->gpio_num); esp_rom_gpio_pad_select_gpio(config->gpio_num);
ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT)); ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT));

View file

@ -58,7 +58,7 @@ void ili9488_init(void)
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, {0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00}, 15}, {ILI9488_CMD_POSITIVE_GAMMA_CORRECTION, {0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00}, 15},
{ILI9488_CMD_NEGATIVE_GAMMA_CORRECTION, {0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00}, 15} {ILI9488_CMD_NEGATIVE_GAMMA_CORRECTION, {0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00}, 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_POWER_CONTROL_NORMAL_3, {0x44}, 1}, {ILI9488_CMD_POWER_CONTROL_NORMAL_3, {0x44}, 1},
@ -78,7 +78,7 @@ void ili9488_init(void)
}; };
//Initialize non-SPI GPIOs //Initialize non-SPI GPIOs
#ifdef ESP_IDF_VERSION_MAJOR >= 5 #if ESP_IDF_VERSION_MAJOR >= 5
esp_rom_gpio_pad_select_gpio(ILI9488_DC); esp_rom_gpio_pad_select_gpio(ILI9488_DC);
#else #else
gpio_pad_select_gpio(ILI9488_DC); gpio_pad_select_gpio(ILI9488_DC);
@ -86,7 +86,7 @@ void ili9488_init(void)
gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT); gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT);
#if ILI9488_USE_RST #if ILI9488_USE_RST
#ifdef ESP_IDF_VERSION_MAJOR >= 5 #if ESP_IDF_VERSION_MAJOR >= 5
esp_rom_gpio_pad_select_gpio(ILI9488_RST); esp_rom_gpio_pad_select_gpio(ILI9488_RST);
#else #else
gpio_pad_select_gpio(ILI9488_RST); gpio_pad_select_gpio(ILI9488_RST);