From 1ed680bff64f28a8c7a9bd407f4cda823a309180 Mon Sep 17 00:00:00 2001 From: hiruna Date: Fri, 26 May 2023 22:17:50 +1000 Subject: [PATCH 01/20] =?UTF-8?q?=1B[200~Backward=20compatibility=20for=20?= =?UTF-8?q?LV=5FHOR=5FRES=5FMAX=20&=20LV=5FVER=5FRES=5FMAX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lvgl_helpers.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lvgl_helpers.h b/lvgl_helpers.h index c0101748..6bd01b0b 100644 --- a/lvgl_helpers.h +++ b/lvgl_helpers.h @@ -22,7 +22,13 @@ extern "C" { /********************* * DEFINES *********************/ - +/* Backward compatibility for LV_HOR_RES_MAX & LV_VER_RES_MAX */ +#if defined (CONFIG_LV_HOR_RES_MAX) +#define LV_HOR_RES_MAX CONFIG_LV_HOR_RES_MAX +#endif +#if defined (CONFIG_LV_VER_RES_MAX) +#define LV_VER_RES_MAX CONFIG_LV_VER_RES_MAX +#endif /* DISP_BUF_SIZE value doesn't have an special meaning, but it's the size * of the buffer(s) passed to LVGL as display buffers. The default values used * were the values working for the contributor of the display controller. From ae62146df3fdc5ff25de8372da30c413ea59656a Mon Sep 17 00:00:00 2001 From: hiruna Date: Fri, 26 May 2023 22:18:11 +1000 Subject: [PATCH 02/20] Backward compatibility for LV_HOR_RES_MAX & LV_VER_RES_MAX --- lvgl_helpers.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lvgl_helpers.h b/lvgl_helpers.h index 6bd01b0b..0e427d70 100644 --- a/lvgl_helpers.h +++ b/lvgl_helpers.h @@ -22,6 +22,7 @@ extern "C" { /********************* * DEFINES *********************/ + /* Backward compatibility for LV_HOR_RES_MAX & LV_VER_RES_MAX */ #if defined (CONFIG_LV_HOR_RES_MAX) #define LV_HOR_RES_MAX CONFIG_LV_HOR_RES_MAX @@ -29,6 +30,7 @@ extern "C" { #if defined (CONFIG_LV_VER_RES_MAX) #define LV_VER_RES_MAX CONFIG_LV_VER_RES_MAX #endif + /* DISP_BUF_SIZE value doesn't have an special meaning, but it's the size * of the buffer(s) passed to LVGL as display buffers. The default values used * were the values working for the contributor of the display controller. From 85de8d78227e348e7f58bc3e8b3105457b6f7631 Mon Sep 17 00:00:00 2001 From: hiruna Date: Fri, 26 May 2023 22:20:21 +1000 Subject: [PATCH 03/20] add requires driver --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 407802a6..28345867 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,7 @@ endif() idf_component_register(SRCS ${SOURCES} INCLUDE_DIRS ${LVGL_INCLUDE_DIRS} - REQUIRES lvgl) + REQUIRES lvgl driver) target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_LVGL_H_INCLUDE_SIMPLE") From bc57b32d87368c830433d89e64771609726e62be Mon Sep 17 00:00:00 2001 From: hiruna Date: Fri, 26 May 2023 22:23:27 +1000 Subject: [PATCH 04/20] Backward compatibility for LV_HOR_RES_MAX & LV_VER_RES_MAX --- lvgl_tft/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lvgl_tft/Kconfig b/lvgl_tft/Kconfig index 4a74ad2e..3c32565c 100644 --- a/lvgl_tft/Kconfig +++ b/lvgl_tft/Kconfig @@ -196,6 +196,14 @@ menu "LVGL TFT Display controller" help Display controller protocol I2C + config LV_HOR_RES_MAX + int "Maximal horizontal resolution to support by the library." + default 128 + + config LV_VER_RES_MAX + int "Maximal vertical resolution to support by the library." + default 64 + # Used in display init function to send display orientation commands choice DISPLAY_ORIENTATION prompt "Display orientation" From f8b0f34a59f8c726efdd8a3f5f7767ba1e1769ad Mon Sep 17 00:00:00 2001 From: hiruna Date: Fri, 26 May 2023 22:25:42 +1000 Subject: [PATCH 05/20] fixes for idf 5.x --- lvgl_tft/FT81x.c | 2 +- lvgl_tft/GC9A01.c | 10 +++++----- lvgl_tft/esp_lcd_backlight.c | 9 +++++---- lvgl_tft/hx8357.c | 10 +++++----- lvgl_tft/il3820.c | 14 +++++++------- lvgl_tft/ili9163c.c | 10 +++++----- lvgl_tft/ili9341.c | 10 +++++----- lvgl_tft/ili9481.c | 12 ++++++------ lvgl_tft/ili9486.c | 10 +++++----- lvgl_tft/ili9488.c | 12 ++++++------ lvgl_tft/pcd8544.c | 8 ++++---- lvgl_tft/ra8875.c | 14 +++++++------- lvgl_tft/sh1107.c | 10 +++++----- lvgl_tft/st7735s.c | 10 +++++----- lvgl_tft/st7789.c | 10 +++++----- lvgl_tft/st7796s.c | 10 +++++----- lvgl_touch/adcraw.c | 4 ++-- lvgl_touch/stmpe610.c | 2 +- 18 files changed, 84 insertions(+), 83 deletions(-) diff --git a/lvgl_tft/FT81x.c b/lvgl_tft/FT81x.c index 63e0dee7..d896e3ad 100644 --- a/lvgl_tft/FT81x.c +++ b/lvgl_tft/FT81x.c @@ -263,7 +263,7 @@ void TFT_bitmap_display(void) void FT81x_init(void) { #if EVE_USE_PDN - gpio_pad_select_gpio(EVE_PDN); + gpio_reset_pin(EVE_PDN); #endif gpio_set_level(EVE_CS, 1); diff --git a/lvgl_tft/GC9A01.c b/lvgl_tft/GC9A01.c index c807233d..c5861ce5 100644 --- a/lvgl_tft/GC9A01.c +++ b/lvgl_tft/GC9A01.c @@ -112,18 +112,18 @@ void GC9A01_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(GC9A01_DC); + gpio_reset_pin(GC9A01_DC); gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT); #if GC9A01_USE_RST - gpio_pad_select_gpio(GC9A01_RST); + gpio_reset_pin(GC9A01_RST); gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(GC9A01_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(GC9A01_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "Initialization."); @@ -134,7 +134,7 @@ void GC9A01_init(void) GC9A01_send_cmd(GC_init_cmds[cmd].cmd); GC9A01_send_data(GC_init_cmds[cmd].data, GC_init_cmds[cmd].databytes&0x1F); if (GC_init_cmds[cmd].databytes & 0x80) { - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/esp_lcd_backlight.c b/lvgl_tft/esp_lcd_backlight.c index f4395bda..247735af 100644 --- a/lvgl_tft/esp_lcd_backlight.c +++ b/lvgl_tft/esp_lcd_backlight.c @@ -6,6 +6,7 @@ /********************* * INCLUDES *********************/ +#include #include "esp_lcd_backlight.h" #include "driver/ledc.h" #include "driver/gpio.h" @@ -49,22 +50,22 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config) }; const ledc_timer_config_t LCD_backlight_timer = { .speed_mode = LEDC_LOW_SPEED_MODE, - .bit_num = LEDC_TIMER_10_BIT, + .duty_resolution = LEDC_TIMER_10_BIT, .timer_num = config->timer_idx, .freq_hz = 5000, .clk_cfg = LEDC_AUTO_CLK}; ESP_ERROR_CHECK(ledc_timer_config(&LCD_backlight_timer)); ESP_ERROR_CHECK(ledc_channel_config(&LCD_backlight_channel)); - gpio_matrix_out(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert, 0); + gpio_iomux_out(config->gpio_num, ledc_periph_signal[LEDC_LOW_SPEED_MODE].sig_out0_idx + config->channel_idx, config->output_invert); } else { // Configure GPIO for output bckl_dev->index = config->gpio_num; - gpio_pad_select_gpio(config->gpio_num); + gpio_reset_pin(config->gpio_num); ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT)); - gpio_matrix_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert, false); + gpio_iomux_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert); } return (disp_backlight_h)bckl_dev; diff --git a/lvgl_tft/hx8357.c b/lvgl_tft/hx8357.c index bb9ea58b..3d8d07da 100644 --- a/lvgl_tft/hx8357.c +++ b/lvgl_tft/hx8357.c @@ -160,18 +160,18 @@ static uint8_t displayType = HX8357D; void hx8357_init(void) { //Initialize non-SPI GPIOs - gpio_pad_select_gpio(HX8357_DC); + gpio_reset_pin(HX8357_DC); gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT); #if HX8357_USE_RST - gpio_pad_select_gpio(HX8357_RST); + gpio_reset_pin(HX8357_RST); gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(HX8357_RST, 0); - vTaskDelay(10 / portTICK_RATE_MS); + vTaskDelay(10 / portTICK_PERIOD_MS); gpio_set_level(HX8357_RST, 1); - vTaskDelay(120 / portTICK_RATE_MS); + vTaskDelay(120 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "Initialization."); @@ -192,7 +192,7 @@ void hx8357_init(void) } } if (x & 0x80) { // If high bit set... - vTaskDelay(numArgs * 5 / portTICK_RATE_MS); // numArgs is actually a delay time (5ms units) + vTaskDelay(numArgs * 5 / portTICK_PERIOD_MS); // numArgs is actually a delay time (5ms units) } } diff --git a/lvgl_tft/il3820.c b/lvgl_tft/il3820.c index 1ce0b395..063f9818 100644 --- a/lvgl_tft/il3820.c +++ b/lvgl_tft/il3820.c @@ -196,21 +196,21 @@ void il3820_init(void) uint8_t tmp[3] = {0}; /* Initialize non-SPI GPIOs */ - gpio_pad_select_gpio(IL3820_DC_PIN); + gpio_reset_pin(IL3820_DC_PIN); gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT); - gpio_pad_select_gpio(IL3820_BUSY_PIN); + gpio_reset_pin(IL3820_BUSY_PIN); gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT); #if IL3820_USE_RST - gpio_pad_select_gpio(IL3820_RST_PIN); + gpio_reset_pin(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); + vTaskDelay(IL3820_RESET_DELAY / portTICK_PERIOD_MS); gpio_set_level( IL3820_RST_PIN, 1); - vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS); + vTaskDelay(IL3820_RESET_DELAY / portTICK_PERIOD_MS); #endif /* Software reset */ @@ -267,14 +267,14 @@ static void il3820_waitbusy(int wait_ms) { int i = 0; - vTaskDelay(10 / portTICK_RATE_MS); // 10ms delay + vTaskDelay(10 / portTICK_PERIOD_MS); // 10ms delay for(i = 0; i < (wait_ms * 10); i++) { if(gpio_get_level(IL3820_BUSY_PIN) != IL3820_BUSY_LEVEL) { return; } - vTaskDelay(10 / portTICK_RATE_MS); + vTaskDelay(10 / portTICK_PERIOD_MS); } ESP_LOGE( TAG, "busy exceeded %dms", i*10 ); diff --git a/lvgl_tft/ili9163c.c b/lvgl_tft/ili9163c.c index 059d076c..13f22b70 100644 --- a/lvgl_tft/ili9163c.c +++ b/lvgl_tft/ili9163c.c @@ -138,16 +138,16 @@ void ili9163c_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ILI9163C_DC); + gpio_reset_pin(ILI9163C_DC); gpio_set_direction(ILI9163C_DC, GPIO_MODE_OUTPUT); - gpio_pad_select_gpio(ILI9163C_RST); + gpio_reset_pin(ILI9163C_RST); gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(ILI9163C_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ILI9163C_RST, 1); - vTaskDelay(150 / portTICK_RATE_MS); + vTaskDelay(150 / portTICK_PERIOD_MS); //Send all the commands uint16_t cmd = 0; @@ -157,7 +157,7 @@ void ili9163c_init(void) ili9163c_send_data(ili_init_cmds[cmd].data, ili_init_cmds[cmd].databytes & 0x1F); if (ili_init_cmds[cmd].databytes & 0x80) { - vTaskDelay(150 / portTICK_RATE_MS); + vTaskDelay(150 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/ili9341.c b/lvgl_tft/ili9341.c index e91680f1..2c9bd0f2 100644 --- a/lvgl_tft/ili9341.c +++ b/lvgl_tft/ili9341.c @@ -81,18 +81,18 @@ void ili9341_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ILI9341_DC); + gpio_reset_pin(ILI9341_DC); gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT); #if ILI9341_USE_RST - gpio_pad_select_gpio(ILI9341_RST); + gpio_reset_pin(ILI9341_RST); gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(ILI9341_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ILI9341_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "Initialization."); @@ -103,7 +103,7 @@ void ili9341_init(void) ili9341_send_cmd(ili_init_cmds[cmd].cmd); ili9341_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); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/ili9481.c b/lvgl_tft/ili9481.c index 74bda98b..4c6f4307 100644 --- a/lvgl_tft/ili9481.c +++ b/lvgl_tft/ili9481.c @@ -74,25 +74,25 @@ void ili9481_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ILI9481_DC); + gpio_reset_pin(ILI9481_DC); gpio_set_direction(ILI9481_DC, GPIO_MODE_OUTPUT); #if ILI9481_USE_RST - gpio_pad_select_gpio(ILI9481_RST); + gpio_reset_pin(ILI9481_RST); gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(ILI9481_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ILI9481_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "ILI9481 initialization."); // Exit sleep ili9481_send_cmd(0x01); /* Software reset */ - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); //Send all the commands uint16_t cmd = 0; @@ -100,7 +100,7 @@ void ili9481_init(void) ili9481_send_cmd(ili_init_cmds[cmd].cmd); ili9481_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); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/ili9486.c b/lvgl_tft/ili9486.c index 829f0bd8..db49780d 100644 --- a/lvgl_tft/ili9486.c +++ b/lvgl_tft/ili9486.c @@ -66,18 +66,18 @@ void ili9486_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ILI9486_DC); + gpio_reset_pin(ILI9486_DC); gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT); #if ILI9486_USE_RST - gpio_pad_select_gpio(ILI9486_RST); + gpio_reset_pin(ILI9486_RST); gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(ILI9486_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ILI9486_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "ILI9486 Initialization."); @@ -88,7 +88,7 @@ void ili9486_init(void) 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); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/ili9488.c b/lvgl_tft/ili9488.c index feb9fbaf..a85cc51f 100644 --- a/lvgl_tft/ili9488.c +++ b/lvgl_tft/ili9488.c @@ -76,25 +76,25 @@ void ili9488_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ILI9488_DC); + gpio_reset_pin(ILI9488_DC); gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT); #if ILI9488_USE_RST - gpio_pad_select_gpio(ILI9488_RST); + gpio_reset_pin(ILI9488_RST); gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(ILI9488_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ILI9488_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "ILI9488 initialization."); // Exit sleep ili9488_send_cmd(0x01); /* Software reset */ - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); //Send all the commands uint16_t cmd = 0; @@ -102,7 +102,7 @@ void ili9488_init(void) ili9488_send_cmd(ili_init_cmds[cmd].cmd); ili9488_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); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/pcd8544.c b/lvgl_tft/pcd8544.c index 49d067eb..01a7ab27 100644 --- a/lvgl_tft/pcd8544.c +++ b/lvgl_tft/pcd8544.c @@ -57,16 +57,16 @@ void pcd8544_init(void){ // TODO: orientation // Initialize non-SPI GPIOs - gpio_pad_select_gpio(PCD8544_DC); + gpio_reset_pin(PCD8544_DC); gpio_set_direction(PCD8544_DC, GPIO_MODE_OUTPUT); - gpio_pad_select_gpio(PCD8544_RST); + gpio_reset_pin(PCD8544_RST); gpio_set_direction(PCD8544_RST, GPIO_MODE_OUTPUT); // Reset the display gpio_set_level(PCD8544_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(PCD8544_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); pcd8544_send_cmd(0x21); /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */ pcd8544_send_cmd(0x06); /* temp. control: b10 = 2 */ diff --git a/lvgl_tft/ra8875.c b/lvgl_tft/ra8875.c index b4f8e2ac..cc911b41 100644 --- a/lvgl_tft/ra8875.c +++ b/lvgl_tft/ra8875.c @@ -151,14 +151,14 @@ void ra8875_init(void) // Initialize non-SPI GPIOs #if RA8875_USE_RST - gpio_pad_select_gpio(RA8875_RST); + gpio_reset_pin(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)); + vTaskDelay(DIV_ROUND_UP(100, portTICK_PERIOD_MS)); gpio_set_level(RA8875_RST, 1); - vTaskDelay(DIV_ROUND_UP(100, portTICK_RATE_MS)); + vTaskDelay(DIV_ROUND_UP(100, portTICK_PERIOD_MS)); #endif // Initalize RA8875 clocks (SPI must be decelerated before initializing clocks) @@ -251,21 +251,21 @@ void ra8875_sleep_in(void) ra8875_configure_clocks(false); ra8875_write_cmd(RA8875_REG_PWRR, 0x00); // Power and Display Control Register (PWRR) - vTaskDelay(DIV_ROUND_UP(20, portTICK_RATE_MS)); + vTaskDelay(DIV_ROUND_UP(20, portTICK_PERIOD_MS)); ra8875_write_cmd(RA8875_REG_PWRR, 0x02); // Power and Display Control Register (PWRR) } void ra8875_sleep_out(void) { ra8875_write_cmd(RA8875_REG_PWRR, 0x00); // Power and Display Control Register (PWRR) - vTaskDelay(DIV_ROUND_UP(20, portTICK_RATE_MS)); + vTaskDelay(DIV_ROUND_UP(20, portTICK_PERIOD_MS)); ra8875_configure_clocks(true); disp_spi_change_device_speed(-1); ra8875_write_cmd(RA8875_REG_PWRR, 0x80); // Power and Display Control Register (PWRR) - vTaskDelay(DIV_ROUND_UP(20, portTICK_RATE_MS)); + vTaskDelay(DIV_ROUND_UP(20, portTICK_PERIOD_MS)); } uint8_t ra8875_read_cmd(uint8_t cmd) @@ -298,7 +298,7 @@ void ra8875_configure_clocks(bool high_speed) vTaskDelay(1); ra8875_write_cmd(RA8875_REG_PCSR, PCSR_VAL); // Pixel Clock Setting Register (PCSR) - vTaskDelay(DIV_ROUND_UP(20, portTICK_RATE_MS)); + vTaskDelay(DIV_ROUND_UP(20, portTICK_PERIOD_MS)); } static void ra8875_set_window(unsigned int xs, unsigned int xe, unsigned int ys, unsigned int ye) diff --git a/lvgl_tft/sh1107.c b/lvgl_tft/sh1107.c index d7f60676..2761095d 100644 --- a/lvgl_tft/sh1107.c +++ b/lvgl_tft/sh1107.c @@ -92,18 +92,18 @@ void sh1107_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(SH1107_DC); + gpio_reset_pin(SH1107_DC); gpio_set_direction(SH1107_DC, GPIO_MODE_OUTPUT); #if SH1107_USE_RST - gpio_pad_select_gpio(SH1107_RST); + gpio_reset_pin(SH1107_RST); gpio_set_direction(SH1107_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(SH1107_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(SH1107_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif //Send all the commands @@ -112,7 +112,7 @@ void sh1107_init(void) sh1107_send_cmd(init_cmds[cmd].cmd); sh1107_send_data(init_cmds[cmd].data, init_cmds[cmd].databytes&0x1F); if (init_cmds[cmd].databytes & 0x80) { - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/st7735s.c b/lvgl_tft/st7735s.c index 8be725be..340fb3a2 100644 --- a/lvgl_tft/st7735s.c +++ b/lvgl_tft/st7735s.c @@ -98,18 +98,18 @@ void st7735s_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ST7735S_DC); + gpio_reset_pin(ST7735S_DC); gpio_set_direction(ST7735S_DC, GPIO_MODE_OUTPUT); #if ST7735S_USE_RST - gpio_pad_select_gpio(ST7735S_RST); + gpio_reset_pin(ST7735S_RST); gpio_set_direction(ST7735S_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(ST7735S_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ST7735S_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "ST7735S initialization."); @@ -120,7 +120,7 @@ void st7735s_init(void) st7735s_send_cmd(init_cmds[cmd].cmd); st7735s_send_data(init_cmds[cmd].data, init_cmds[cmd].databytes&0x1F); if (init_cmds[cmd].databytes & 0x80) { - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/st7789.c b/lvgl_tft/st7789.c index de7b35aa..29a4ab57 100644 --- a/lvgl_tft/st7789.c +++ b/lvgl_tft/st7789.c @@ -86,20 +86,20 @@ void st7789_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ST7789_DC); + gpio_reset_pin(ST7789_DC); gpio_set_direction(ST7789_DC, GPIO_MODE_OUTPUT); #if !defined(ST7789_SOFT_RST) - gpio_pad_select_gpio(ST7789_RST); + gpio_reset_pin(ST7789_RST); gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT); #endif //Reset the display #if !defined(ST7789_SOFT_RST) gpio_set_level(ST7789_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ST7789_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #else st7789_send_cmd(ST7789_SWRESET); #endif @@ -112,7 +112,7 @@ void st7789_init(void) st7789_send_cmd(st7789_init_cmds[cmd].cmd); st7789_send_data(st7789_init_cmds[cmd].data, st7789_init_cmds[cmd].databytes&0x1F); if (st7789_init_cmds[cmd].databytes & 0x80) { - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_tft/st7796s.c b/lvgl_tft/st7796s.c index 7de92ef0..0a8dd1c3 100644 --- a/lvgl_tft/st7796s.c +++ b/lvgl_tft/st7796s.c @@ -82,18 +82,18 @@ void st7796s_init(void) }; //Initialize non-SPI GPIOs - gpio_pad_select_gpio(ST7796S_DC); + gpio_reset_pin(ST7796S_DC); gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT); #if ST7796S_USE_RST - gpio_pad_select_gpio(ST7796S_RST); + gpio_reset_pin(ST7796S_RST); gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT); //Reset the display gpio_set_level(ST7796S_RST, 0); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); gpio_set_level(ST7796S_RST, 1); - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); #endif ESP_LOGI(TAG, "Initialization."); @@ -106,7 +106,7 @@ void st7796s_init(void) st7796s_send_data(init_cmds[cmd].data, init_cmds[cmd].databytes & 0x1F); if (init_cmds[cmd].databytes & 0x80) { - vTaskDelay(100 / portTICK_RATE_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); } cmd++; } diff --git a/lvgl_touch/adcraw.c b/lvgl_touch/adcraw.c index 6170b4c8..ac72dbac 100644 --- a/lvgl_touch/adcraw.c +++ b/lvgl_touch/adcraw.c @@ -139,10 +139,10 @@ static void setup_axis(gpio_num_t plus, gpio_num_t minus, gpio_num_t measure, gp { // Set GPIOs: // - Float "ignore" and "measure" - gpio_pad_select_gpio(ignore); + gpio_reset_pin(ignore); gpio_set_direction(ignore, GPIO_MODE_DISABLE); gpio_set_pull_mode(ignore, GPIO_FLOATING); - gpio_pad_select_gpio(measure); + gpio_reset_pin(measure); gpio_set_direction(measure, GPIO_MODE_DISABLE); gpio_set_pull_mode(measure, GPIO_FLOATING); // - Set "plus" to 1, "minus" to 0 diff --git a/lvgl_touch/stmpe610.c b/lvgl_touch/stmpe610.c index 6c5ae604..0f8410f8 100644 --- a/lvgl_touch/stmpe610.c +++ b/lvgl_touch/stmpe610.c @@ -63,7 +63,7 @@ void stmpe610_init(void) // Attempt a software reset write_8bit_reg(STMPE_SYS_CTRL1, STMPE_SYS_CTRL1_RESET); - vTaskDelay(10 / portTICK_RATE_MS); + vTaskDelay(10 / portTICK_PERIOD_MS); // Reset the SPI configuration, making sure auto-increment is set u8 = read_8bit_reg(STMPE_SPI_CFG); From 735b5df0ff35211a3d7e5632b916853c5f7a667b Mon Sep 17 00:00:00 2001 From: hiruna Date: Fri, 26 May 2023 22:27:08 +1000 Subject: [PATCH 06/20] fix i2c_manager conf checks --- lvgl_i2c/i2c_manager.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lvgl_i2c/i2c_manager.c b/lvgl_i2c/i2c_manager.c index 080d81a7..d09845bf 100644 --- a/lvgl_i2c/i2c_manager.c +++ b/lvgl_i2c/i2c_manager.c @@ -58,7 +58,7 @@ static SemaphoreHandle_t* I2C_FN(_mutex) = &I2C_FN(_local_mutex)[0]; static const uint8_t ACK_CHECK_EN = 1; -#if defined (I2C_NUM_0) && defined (CONFIG_I2C_MANAGER_0_ENABLED) +#if defined (CONFIG_I2C_MANAGER_0_ENABLED) #define I2C_ZERO I2C_NUM_0 #if defined (CONFIG_I2C_MANAGER_0_PULLUPS) #define I2C_MANAGER_0_PULLUPS true @@ -66,12 +66,12 @@ static const uint8_t ACK_CHECK_EN = 1; #define I2C_MANAGER_0_PULLUPS false #endif - #define I2C_MANAGER_0_TIMEOUT ( CONFIG_I2C_MANAGER_0_TIMEOUT / portTICK_RATE_MS ) - #define I2C_MANAGER_0_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT / portTICK_RATE_MS ) + #define I2C_MANAGER_0_TIMEOUT ( CONFIG_I2C_MANAGER_0_TIMEOUT / portTICK_PERIOD_MS ) + #define I2C_MANAGER_0_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT / portTICK_PERIOD_MS ) #endif -#if defined (I2C_NUM_1) && defined (CONFIG_I2C_MANAGER_1_ENABLED) +#if defined (CONFIG_I2C_MANAGER_1_ENABLED) #define I2C_ONE I2C_NUM_1 #if defined (CONFIG_I2C_MANAGER_1_PULLUPS) #define I2C_MANAGER_1_PULLUPS true @@ -79,8 +79,8 @@ static const uint8_t ACK_CHECK_EN = 1; #define I2C_MANAGER_1_PULLUPS false #endif - #define I2C_MANAGER_1_TIMEOUT ( CONFIG_I2C_MANAGER_1_TIMEOUT / portTICK_RATE_MS ) - #define I2C_MANAGER_1_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT / portTICK_RATE_MS ) + #define I2C_MANAGER_1_TIMEOUT ( CONFIG_I2C_MANAGER_1_TIMEOUT / portTICK_PERIOD_MS ) + #define I2C_MANAGER_1_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT / portTICK_PERIOD_MS ) #endif #define ERROR_PORT(port, fail) { \ @@ -168,7 +168,7 @@ esp_err_t I2C_FN(_init)(i2c_port_t port) { ESP_LOGW(TAG, "If it was already open, we'll use it with whatever settings were used " "to open it. See I2C Manager README for details."); } else { - ESP_LOGI(TAG, "Initialised port %d (SDA: %d, SCL: %d, speed: %d Hz.)", + ESP_LOGI(TAG, "Initialised port %d (SDA: %d, SCL: %d, speed: %lu Hz.)", port, conf.sda_io_num, conf.scl_io_num, conf.master.clk_speed); } @@ -186,7 +186,7 @@ esp_err_t I2C_FN(_read)(i2c_port_t port, uint16_t addr, uint32_t reg, uint8_t *b // May seem weird, but init starts with a check if it's needed, no need for that check twice. I2C_FN(_init)(port); - ESP_LOGV(TAG, "Reading port %d, addr 0x%03x, reg 0x%04x", port, addr, reg); + ESP_LOGV(TAG, "Reading port %d, addr 0x%03x, reg 0x%04lx", port, addr, reg); TickType_t timeout = 0; #if defined (I2C_ZERO) @@ -239,17 +239,17 @@ esp_err_t I2C_FN(_write)(i2c_port_t port, uint16_t addr, uint32_t reg, const uin // May seem weird, but init starts with a check if it's needed, no need for that check twice. I2C_FN(_init)(port); - ESP_LOGV(TAG, "Writing port %d, addr 0x%03x, reg 0x%04x", port, addr, reg); + ESP_LOGV(TAG, "Writing port %d, addr 0x%03x, reg 0x%04lx", port, addr, reg); TickType_t timeout = 0; #if defined (I2C_ZERO) if (port == I2C_NUM_0) { - timeout = (CONFIG_I2C_MANAGER_0_TIMEOUT) / portTICK_RATE_MS; + timeout = (CONFIG_I2C_MANAGER_0_TIMEOUT) / portTICK_PERIOD_MS; } #endif #if defined (I2C_ONE) if (port == I2C_NUM_1) { - timeout = (CONFIG_I2C_MANAGER_1_TIMEOUT) / portTICK_RATE_MS; + timeout = (CONFIG_I2C_MANAGER_1_TIMEOUT) / portTICK_PERIOD_MS; } #endif @@ -294,12 +294,12 @@ esp_err_t I2C_FN(_lock)(i2c_port_t port) { TickType_t timeout; #if defined (I2C_ZERO) if (port == I2C_NUM_0) { - timeout = (CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT) / portTICK_RATE_MS; + timeout = (CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT) / portTICK_PERIOD_MS; } #endif #if defined (I2C_ONE) if (port == I2C_NUM_1) { - timeout = (CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT) / portTICK_RATE_MS; + timeout = (CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT) / portTICK_PERIOD_MS; } #endif From 785b7d5c28ad1140e1fe2b362639aab7368557d3 Mon Sep 17 00:00:00 2001 From: hiruna Date: Fri, 26 May 2023 22:50:04 +1000 Subject: [PATCH 07/20] gpio_pad_select_gpio -> esp_rom_gpio_pad_select_gpio --- lvgl_tft/FT81x.c | 2 +- lvgl_tft/GC9A01.c | 4 ++-- lvgl_tft/esp_lcd_backlight.c | 4 ++-- lvgl_tft/hx8357.c | 4 ++-- lvgl_tft/il3820.c | 6 +++--- lvgl_tft/ili9163c.c | 4 ++-- lvgl_tft/ili9341.c | 4 ++-- lvgl_tft/ili9481.c | 4 ++-- lvgl_tft/ili9486.c | 4 ++-- lvgl_tft/ili9488.c | 4 ++-- lvgl_tft/pcd8544.c | 4 ++-- lvgl_tft/ra8875.c | 2 +- lvgl_tft/sh1107.c | 4 ++-- lvgl_tft/st7735s.c | 4 ++-- lvgl_tft/st7789.c | 4 ++-- lvgl_tft/st7796s.c | 4 ++-- lvgl_touch/adcraw.c | 4 ++-- 17 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lvgl_tft/FT81x.c b/lvgl_tft/FT81x.c index d896e3ad..87550796 100644 --- a/lvgl_tft/FT81x.c +++ b/lvgl_tft/FT81x.c @@ -263,7 +263,7 @@ void TFT_bitmap_display(void) void FT81x_init(void) { #if EVE_USE_PDN - gpio_reset_pin(EVE_PDN); + esp_rom_gpio_pad_select_gpio(EVE_PDN); #endif gpio_set_level(EVE_CS, 1); diff --git a/lvgl_tft/GC9A01.c b/lvgl_tft/GC9A01.c index c5861ce5..fe5c7b8d 100644 --- a/lvgl_tft/GC9A01.c +++ b/lvgl_tft/GC9A01.c @@ -112,11 +112,11 @@ void GC9A01_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(GC9A01_DC); + esp_rom_gpio_pad_select_gpio(GC9A01_DC); gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT); #if GC9A01_USE_RST - gpio_reset_pin(GC9A01_RST); + esp_rom_gpio_pad_select_gpio(GC9A01_RST); gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/esp_lcd_backlight.c b/lvgl_tft/esp_lcd_backlight.c index 247735af..0da96cb6 100644 --- a/lvgl_tft/esp_lcd_backlight.c +++ b/lvgl_tft/esp_lcd_backlight.c @@ -63,7 +63,7 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config) { // Configure GPIO for output bckl_dev->index = config->gpio_num; - gpio_reset_pin(config->gpio_num); + esp_rom_gpio_pad_select_gpio(config->gpio_num); ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT)); gpio_iomux_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert); } @@ -102,7 +102,7 @@ void disp_backlight_delete(disp_backlight_h bckl) if (bckl_dev->pwm_control) { ledc_stop(LEDC_LOW_SPEED_MODE, bckl_dev->index, 0); } else { - gpio_reset_pin(bckl_dev->index); + esp_rom_gpio_pad_select_gpio(bckl_dev->index); } free (bckl); } diff --git a/lvgl_tft/hx8357.c b/lvgl_tft/hx8357.c index 3d8d07da..30a3e384 100644 --- a/lvgl_tft/hx8357.c +++ b/lvgl_tft/hx8357.c @@ -160,11 +160,11 @@ static uint8_t displayType = HX8357D; void hx8357_init(void) { //Initialize non-SPI GPIOs - gpio_reset_pin(HX8357_DC); + esp_rom_gpio_pad_select_gpio(HX8357_DC); gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT); #if HX8357_USE_RST - gpio_reset_pin(HX8357_RST); + esp_rom_gpio_pad_select_gpio(HX8357_RST); gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/il3820.c b/lvgl_tft/il3820.c index 063f9818..d4ff1add 100644 --- a/lvgl_tft/il3820.c +++ b/lvgl_tft/il3820.c @@ -196,14 +196,14 @@ void il3820_init(void) uint8_t tmp[3] = {0}; /* Initialize non-SPI GPIOs */ - gpio_reset_pin(IL3820_DC_PIN); + esp_rom_gpio_pad_select_gpio(IL3820_DC_PIN); gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT); - gpio_reset_pin(IL3820_BUSY_PIN); + esp_rom_gpio_pad_select_gpio(IL3820_BUSY_PIN); gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT); #if IL3820_USE_RST - gpio_reset_pin(IL3820_RST_PIN); + esp_rom_gpio_pad_select_gpio(IL3820_RST_PIN); gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT); /* Harware reset */ diff --git a/lvgl_tft/ili9163c.c b/lvgl_tft/ili9163c.c index 13f22b70..a4e00190 100644 --- a/lvgl_tft/ili9163c.c +++ b/lvgl_tft/ili9163c.c @@ -138,9 +138,9 @@ void ili9163c_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ILI9163C_DC); + esp_rom_gpio_pad_select_gpio(ILI9163C_DC); gpio_set_direction(ILI9163C_DC, GPIO_MODE_OUTPUT); - gpio_reset_pin(ILI9163C_RST); + esp_rom_gpio_pad_select_gpio(ILI9163C_RST); gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9341.c b/lvgl_tft/ili9341.c index 2c9bd0f2..f580e677 100644 --- a/lvgl_tft/ili9341.c +++ b/lvgl_tft/ili9341.c @@ -81,11 +81,11 @@ void ili9341_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ILI9341_DC); + esp_rom_gpio_pad_select_gpio(ILI9341_DC); gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT); #if ILI9341_USE_RST - gpio_reset_pin(ILI9341_RST); + esp_rom_gpio_pad_select_gpio(ILI9341_RST); gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9481.c b/lvgl_tft/ili9481.c index 4c6f4307..b27c5177 100644 --- a/lvgl_tft/ili9481.c +++ b/lvgl_tft/ili9481.c @@ -74,11 +74,11 @@ void ili9481_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ILI9481_DC); + esp_rom_gpio_pad_select_gpio(ILI9481_DC); gpio_set_direction(ILI9481_DC, GPIO_MODE_OUTPUT); #if ILI9481_USE_RST - gpio_reset_pin(ILI9481_RST); + esp_rom_gpio_pad_select_gpio(ILI9481_RST); gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9486.c b/lvgl_tft/ili9486.c index db49780d..0d4a8231 100644 --- a/lvgl_tft/ili9486.c +++ b/lvgl_tft/ili9486.c @@ -66,11 +66,11 @@ void ili9486_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ILI9486_DC); + esp_rom_gpio_pad_select_gpio(ILI9486_DC); gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT); #if ILI9486_USE_RST - gpio_reset_pin(ILI9486_RST); + esp_rom_gpio_pad_select_gpio(ILI9486_RST); gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9488.c b/lvgl_tft/ili9488.c index a85cc51f..f67a5d14 100644 --- a/lvgl_tft/ili9488.c +++ b/lvgl_tft/ili9488.c @@ -76,11 +76,11 @@ void ili9488_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ILI9488_DC); + esp_rom_gpio_pad_select_gpio(ILI9488_DC); gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT); #if ILI9488_USE_RST - gpio_reset_pin(ILI9488_RST); + esp_rom_gpio_pad_select_gpio(ILI9488_RST); gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/pcd8544.c b/lvgl_tft/pcd8544.c index 01a7ab27..9f5e2ff0 100644 --- a/lvgl_tft/pcd8544.c +++ b/lvgl_tft/pcd8544.c @@ -57,9 +57,9 @@ void pcd8544_init(void){ // TODO: orientation // Initialize non-SPI GPIOs - gpio_reset_pin(PCD8544_DC); + esp_rom_gpio_pad_select_gpio(PCD8544_DC); gpio_set_direction(PCD8544_DC, GPIO_MODE_OUTPUT); - gpio_reset_pin(PCD8544_RST); + esp_rom_gpio_pad_select_gpio(PCD8544_RST); gpio_set_direction(PCD8544_RST, GPIO_MODE_OUTPUT); // Reset the display diff --git a/lvgl_tft/ra8875.c b/lvgl_tft/ra8875.c index cc911b41..2a5e4559 100644 --- a/lvgl_tft/ra8875.c +++ b/lvgl_tft/ra8875.c @@ -151,7 +151,7 @@ void ra8875_init(void) // Initialize non-SPI GPIOs #if RA8875_USE_RST - gpio_reset_pin(RA8875_RST); + esp_rom_gpio_pad_select_gpio(RA8875_RST); gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT); // Reset the RA8875 diff --git a/lvgl_tft/sh1107.c b/lvgl_tft/sh1107.c index 2761095d..bef776c3 100644 --- a/lvgl_tft/sh1107.c +++ b/lvgl_tft/sh1107.c @@ -92,11 +92,11 @@ void sh1107_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(SH1107_DC); + esp_rom_gpio_pad_select_gpio(SH1107_DC); gpio_set_direction(SH1107_DC, GPIO_MODE_OUTPUT); #if SH1107_USE_RST - gpio_reset_pin(SH1107_RST); + esp_rom_gpio_pad_select_gpio(SH1107_RST); gpio_set_direction(SH1107_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/st7735s.c b/lvgl_tft/st7735s.c index 340fb3a2..ed1f4810 100644 --- a/lvgl_tft/st7735s.c +++ b/lvgl_tft/st7735s.c @@ -98,11 +98,11 @@ void st7735s_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ST7735S_DC); + esp_rom_gpio_pad_select_gpio(ST7735S_DC); gpio_set_direction(ST7735S_DC, GPIO_MODE_OUTPUT); #if ST7735S_USE_RST - gpio_reset_pin(ST7735S_RST); + esp_rom_gpio_pad_select_gpio(ST7735S_RST); gpio_set_direction(ST7735S_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/st7789.c b/lvgl_tft/st7789.c index 29a4ab57..f2144b19 100644 --- a/lvgl_tft/st7789.c +++ b/lvgl_tft/st7789.c @@ -86,11 +86,11 @@ void st7789_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ST7789_DC); + esp_rom_gpio_pad_select_gpio(ST7789_DC); gpio_set_direction(ST7789_DC, GPIO_MODE_OUTPUT); #if !defined(ST7789_SOFT_RST) - gpio_reset_pin(ST7789_RST); + esp_rom_gpio_pad_select_gpio(ST7789_RST); gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT); #endif diff --git a/lvgl_tft/st7796s.c b/lvgl_tft/st7796s.c index 0a8dd1c3..6faae1e3 100644 --- a/lvgl_tft/st7796s.c +++ b/lvgl_tft/st7796s.c @@ -82,11 +82,11 @@ void st7796s_init(void) }; //Initialize non-SPI GPIOs - gpio_reset_pin(ST7796S_DC); + esp_rom_gpio_pad_select_gpio(ST7796S_DC); gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT); #if ST7796S_USE_RST - gpio_reset_pin(ST7796S_RST); + esp_rom_gpio_pad_select_gpio(ST7796S_RST); gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_touch/adcraw.c b/lvgl_touch/adcraw.c index ac72dbac..77590489 100644 --- a/lvgl_touch/adcraw.c +++ b/lvgl_touch/adcraw.c @@ -139,10 +139,10 @@ static void setup_axis(gpio_num_t plus, gpio_num_t minus, gpio_num_t measure, gp { // Set GPIOs: // - Float "ignore" and "measure" - gpio_reset_pin(ignore); + esp_rom_gpio_pad_select_gpio(ignore); gpio_set_direction(ignore, GPIO_MODE_DISABLE); gpio_set_pull_mode(ignore, GPIO_FLOATING); - gpio_reset_pin(measure); + esp_rom_gpio_pad_select_gpio(measure); gpio_set_direction(measure, GPIO_MODE_DISABLE); gpio_set_pull_mode(measure, GPIO_FLOATING); // - Set "plus" to 1, "minus" to 0 From 8f72cfaa943d969f759460efcda0075eebde6889 Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 27 May 2023 13:00:33 +1000 Subject: [PATCH 08/20] source i2c_manager files from https://github.com/ropg/i2c_manager master --- lvgl_i2c/Kconfig | 12 +- lvgl_i2c/i2c_manager.c | 302 ++++++++++++++++++++--------------------- lvgl_i2c/i2c_manager.h | 22 +-- 3 files changed, 167 insertions(+), 169 deletions(-) diff --git a/lvgl_i2c/Kconfig b/lvgl_i2c/Kconfig index 48df924e..5f0bf899 100644 --- a/lvgl_i2c/Kconfig +++ b/lvgl_i2c/Kconfig @@ -6,10 +6,8 @@ menu "I2C Port 0" if I2C_MANAGER_0_ENABLED config I2C_MANAGER_0_SDA int "SDA (GPIO pin)" - default 0 config I2C_MANAGER_0_SCL int "SCL (GPIO pin)" - default 0 config I2C_MANAGER_0_FREQ_HZ int "Frequency (Hz)" default 400000 @@ -19,7 +17,7 @@ menu "I2C Port 0" 5000000 (5 Mhz). I2C busses that involve external wires may have to be slower, and the real maximum speed the bus will support depends on the value of the pullup resistors and the - design of the overall circuit. + design of the overall circuit. config I2C_MANAGER_0_TIMEOUT int "R/W timeout (ms)" default 20 @@ -50,10 +48,10 @@ endmenu menu "I2C Port 1" - + config I2C_MANAGER_1_ENABLED bool "Enable I2C port 1" - + if I2C_MANAGER_1_ENABLED config I2C_MANAGER_1_SDA int "SDA (GPIO pin)" @@ -68,7 +66,7 @@ menu "I2C Port 1" 5000000 (5 Mhz). I2C busses that involve external wires may have to be slower, and the real maximum speed the bus will support depends on the value of the pullup resistors and the - design of the overall circuit. + design of the overall circuit. config I2C_MANAGER_1_TIMEOUT int "R/W timeout (ms)" default 20 @@ -95,4 +93,4 @@ menu "I2C Port 1" can attain. Try with these off first if you don't know. endif -endmenu +endmenu \ No newline at end of file diff --git a/lvgl_i2c/i2c_manager.c b/lvgl_i2c/i2c_manager.c index d09845bf..6780d9fc 100644 --- a/lvgl_i2c/i2c_manager.c +++ b/lvgl_i2c/i2c_manager.c @@ -42,7 +42,7 @@ SOFTWARE. #if defined __has_include - #if __has_include ("esp_idf_version.h") +#if __has_include ("esp_idf_version.h") #include "esp_idf_version.h" #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) #define HAS_CLK_FLAGS @@ -58,29 +58,29 @@ static SemaphoreHandle_t* I2C_FN(_mutex) = &I2C_FN(_local_mutex)[0]; static const uint8_t ACK_CHECK_EN = 1; -#if defined (CONFIG_I2C_MANAGER_0_ENABLED) - #define I2C_ZERO I2C_NUM_0 +#if defined (I2C_NUM_0) && defined (CONFIG_I2C_MANAGER_0_ENABLED) +#define I2C_ZERO I2C_NUM_0 #if defined (CONFIG_I2C_MANAGER_0_PULLUPS) #define I2C_MANAGER_0_PULLUPS true #else #define I2C_MANAGER_0_PULLUPS false #endif - #define I2C_MANAGER_0_TIMEOUT ( CONFIG_I2C_MANAGER_0_TIMEOUT / portTICK_PERIOD_MS ) - #define I2C_MANAGER_0_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT / portTICK_PERIOD_MS ) + #define I2C_MANAGER_0_TIMEOUT ( pdMS_TO_TICKS( CONFIG_I2C_MANAGER_0_TIMEOUT ) ) + #define I2C_MANAGER_0_LOCK_TIMEOUT ( ( pdMS_TO_TICKS( CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT ) ) #endif -#if defined (CONFIG_I2C_MANAGER_1_ENABLED) - #define I2C_ONE I2C_NUM_1 +#if defined (I2C_NUM_1) && defined (CONFIG_I2C_MANAGER_1_ENABLED) +#define I2C_ONE I2C_NUM_1 #if defined (CONFIG_I2C_MANAGER_1_PULLUPS) #define I2C_MANAGER_1_PULLUPS true #else #define I2C_MANAGER_1_PULLUPS false #endif - #define I2C_MANAGER_1_TIMEOUT ( CONFIG_I2C_MANAGER_1_TIMEOUT / portTICK_PERIOD_MS ) - #define I2C_MANAGER_1_LOCK_TIMEOUT ( CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT / portTICK_PERIOD_MS ) + #define I2C_MANAGER_1_TIMEOUT ( pdMS_TO_TICKS( CONFIG_I2C_MANAGER_1_TIMEOUT ) ) + #define I2C_MANAGER_1_LOCK_TIMEOUT ( pdMS_TO_TICKS( CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT ) ) #endif #define ERROR_PORT(port, fail) { \ @@ -89,198 +89,198 @@ static const uint8_t ACK_CHECK_EN = 1; } #if defined(I2C_ZERO) && defined (I2C_ONE) - #define I2C_PORT_CHECK(port, fail) \ +#define I2C_PORT_CHECK(port, fail) \ if (port != I2C_NUM_0 && port != I2C_NUM_1) ERROR_PORT(port, fail); #else - #if defined(I2C_ZERO) - #define I2C_PORT_CHECK(port, fail) \ +#if defined(I2C_ZERO) +#define I2C_PORT_CHECK(port, fail) \ if (port != I2C_NUM_0) ERROR_PORT(port, fail); - #elif defined(I2C_ONE) - #define I2C_PORT_CHECK(port, fail) \ +#elif defined(I2C_ONE) +#define I2C_PORT_CHECK(port, fail) \ if (port != I2C_NUM_1) ERROR_PORT(port, fail); - #else - #define I2C_PORT_CHECK(port, fail) \ +#else +#define I2C_PORT_CHECK(port, fail) \ ERROR_PORT(port, fail); - #endif +#endif #endif static void i2c_send_address(i2c_cmd_handle_t cmd, uint16_t addr, i2c_rw_t rw) { - if (addr & I2C_ADDR_10) { - i2c_master_write_byte(cmd, 0xF0 | ((addr & 0x3FF) >> 7) | rw, ACK_CHECK_EN); - i2c_master_write_byte(cmd, addr & 0xFF, ACK_CHECK_EN); - } else { - i2c_master_write_byte(cmd, (addr << 1) | rw, ACK_CHECK_EN); - } + if (addr & I2C_ADDR_10) { + i2c_master_write_byte(cmd, 0xF0 | ((addr & 0x3FF) >> 7) | rw, ACK_CHECK_EN); + i2c_master_write_byte(cmd, addr & 0xFF, ACK_CHECK_EN); + } else { + i2c_master_write_byte(cmd, (addr << 1) | rw, ACK_CHECK_EN); + } } static void i2c_send_register(i2c_cmd_handle_t cmd, uint32_t reg) { - if (reg & I2C_REG_16) { - i2c_master_write_byte(cmd, (reg & 0xFF00) >> 8, ACK_CHECK_EN); - } + if (reg & I2C_REG_16) { + i2c_master_write_byte(cmd, (reg & 0xFF00) >> 8, ACK_CHECK_EN); + } i2c_master_write_byte(cmd, reg & 0xFF, ACK_CHECK_EN); } esp_err_t I2C_FN(_init)(i2c_port_t port) { - I2C_PORT_CHECK(port, ESP_FAIL); + I2C_PORT_CHECK(port, ESP_FAIL); - esp_err_t ret = ESP_OK; + esp_err_t ret = ESP_OK; - if (I2C_FN(_mutex)[port] == 0) { + if (I2C_FN(_mutex)[port] == 0) { - ESP_LOGI(TAG, "Starting I2C master at port %d.", (int)port); + ESP_LOGI(TAG, "Starting I2C master at port %d.", (int)port); - I2C_FN(_mutex)[port] = xSemaphoreCreateMutex(); + I2C_FN(_mutex)[port] = xSemaphoreCreateMutex(); - i2c_config_t conf = {0}; - - #ifdef HAS_CLK_FLAGS - conf.clk_flags = 0; - #endif + i2c_config_t conf = {0}; + +#ifdef HAS_CLK_FLAGS + conf.clk_flags = 0; +#endif - #if defined (I2C_ZERO) - if (port == I2C_NUM_0) { +#if defined (I2C_ZERO) + if (port == I2C_NUM_0) { conf.sda_io_num = CONFIG_I2C_MANAGER_0_SDA; conf.scl_io_num = CONFIG_I2C_MANAGER_0_SCL; conf.sda_pullup_en = I2C_MANAGER_0_PULLUPS ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE; conf.scl_pullup_en = conf.sda_pullup_en; conf.master.clk_speed = CONFIG_I2C_MANAGER_0_FREQ_HZ; } - #endif +#endif - #if defined (I2C_ONE) - if (port == I2C_NUM_1) { +#if defined (I2C_ONE) + if (port == I2C_NUM_1) { conf.sda_io_num = CONFIG_I2C_MANAGER_1_SDA; conf.scl_io_num = CONFIG_I2C_MANAGER_1_SCL; conf.sda_pullup_en = I2C_MANAGER_1_PULLUPS ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE; conf.scl_pullup_en = conf.sda_pullup_en; conf.master.clk_speed = CONFIG_I2C_MANAGER_1_FREQ_HZ; } - #endif +#endif - conf.mode = I2C_MODE_MASTER; + conf.mode = I2C_MODE_MASTER; - ret = i2c_param_config(port, &conf); - ret |= i2c_driver_install(port, conf.mode, 0, 0, 0); + ret = i2c_param_config(port, &conf); + ret |= i2c_driver_install(port, conf.mode, 0, 0, 0); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialise I2C port %d.", (int)port); - ESP_LOGW(TAG, "If it was already open, we'll use it with whatever settings were used " - "to open it. See I2C Manager README for details."); - } else { - ESP_LOGI(TAG, "Initialised port %d (SDA: %d, SCL: %d, speed: %lu Hz.)", - port, conf.sda_io_num, conf.scl_io_num, conf.master.clk_speed); - } + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialise I2C port %d.", (int)port); + ESP_LOGW(TAG, "If it was already open, we'll use it with whatever settings were used " + "to open it. See I2C Manager README for details."); + } else { + ESP_LOGI(TAG, "Initialised port %d (SDA: %d, SCL: %d, speed: %d Hz.)", + port, conf.sda_io_num, conf.scl_io_num, conf.master.clk_speed); + } - } + } return ret; } esp_err_t I2C_FN(_read)(i2c_port_t port, uint16_t addr, uint32_t reg, uint8_t *buffer, uint16_t size) { - I2C_PORT_CHECK(port, ESP_FAIL); + I2C_PORT_CHECK(port, ESP_FAIL); esp_err_t result; // May seem weird, but init starts with a check if it's needed, no need for that check twice. - I2C_FN(_init)(port); + I2C_FN(_init)(port); - ESP_LOGV(TAG, "Reading port %d, addr 0x%03x, reg 0x%04lx", port, addr, reg); + ESP_LOGV(TAG, "Reading port %d, addr 0x%03x, reg 0x%04x", port, addr, reg); - TickType_t timeout = 0; - #if defined (I2C_ZERO) - if (port == I2C_NUM_0) { + TickType_t timeout = 0; +#if defined (I2C_ZERO) + if (port == I2C_NUM_0) { timeout = I2C_MANAGER_0_TIMEOUT; } - #endif - #if defined (I2C_ONE) - if (port == I2C_NUM_1) { +#endif +#if defined (I2C_ONE) + if (port == I2C_NUM_1) { timeout = I2C_MANAGER_1_TIMEOUT; } - #endif +#endif - if (I2C_FN(_lock)((int)port) == ESP_OK) { - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - if (!(reg & I2C_NO_REG)) { - /* When reading specific register set the addr pointer first. */ - i2c_master_start(cmd); - i2c_send_address(cmd, addr, I2C_MASTER_WRITE); - i2c_send_register(cmd, reg); - } - /* Read size bytes from the current pointer. */ - i2c_master_start(cmd); - i2c_send_address(cmd, addr, I2C_MASTER_READ); - i2c_master_read(cmd, buffer, size, I2C_MASTER_LAST_NACK); - i2c_master_stop(cmd); - result = i2c_master_cmd_begin(port, cmd, timeout); - i2c_cmd_link_delete(cmd); - I2C_FN(_unlock)((int)port); - } else { - ESP_LOGE(TAG, "Lock could not be obtained for port %d.", (int)port); - return ESP_ERR_TIMEOUT; - } + if (I2C_FN(_lock)((int)port) == ESP_OK) { + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + if (!(reg & I2C_NO_REG)) { + /* When reading specific register set the addr pointer first. */ + i2c_master_start(cmd); + i2c_send_address(cmd, addr, I2C_MASTER_WRITE); + i2c_send_register(cmd, reg); + } + /* Read size bytes from the current pointer. */ + i2c_master_start(cmd); + i2c_send_address(cmd, addr, I2C_MASTER_READ); + i2c_master_read(cmd, buffer, size, I2C_MASTER_LAST_NACK); + i2c_master_stop(cmd); + result = i2c_master_cmd_begin(port, cmd, timeout); + i2c_cmd_link_delete(cmd); + I2C_FN(_unlock)((int)port); + } else { + ESP_LOGE(TAG, "Lock could not be obtained for port %d.", (int)port); + return ESP_ERR_TIMEOUT; + } if (result != ESP_OK) { - ESP_LOGW(TAG, "Error: %d", result); + ESP_LOGD(TAG, "Error: %d", result); } - ESP_LOG_BUFFER_HEX_LEVEL(TAG, buffer, size, ESP_LOG_VERBOSE); + ESP_LOG_BUFFER_HEX_LEVEL(TAG, buffer, size, ESP_LOG_VERBOSE); return result; } esp_err_t I2C_FN(_write)(i2c_port_t port, uint16_t addr, uint32_t reg, const uint8_t *buffer, uint16_t size) { - I2C_PORT_CHECK(port, ESP_FAIL); + I2C_PORT_CHECK(port, ESP_FAIL); esp_err_t result; // May seem weird, but init starts with a check if it's needed, no need for that check twice. - I2C_FN(_init)(port); + I2C_FN(_init)(port); - ESP_LOGV(TAG, "Writing port %d, addr 0x%03x, reg 0x%04lx", port, addr, reg); + ESP_LOGV(TAG, "Writing port %d, addr 0x%03x, reg 0x%04x", port, addr, reg); - TickType_t timeout = 0; - #if defined (I2C_ZERO) - if (port == I2C_NUM_0) { - timeout = (CONFIG_I2C_MANAGER_0_TIMEOUT) / portTICK_PERIOD_MS; + TickType_t timeout = 0; +#if defined (I2C_ZERO) + if (port == I2C_NUM_0) { + timeout = pdMS_TO_TICKS( CONFIG_I2C_MANAGER_0_TIMEOUT ); } - #endif - #if defined (I2C_ONE) - if (port == I2C_NUM_1) { - timeout = (CONFIG_I2C_MANAGER_1_TIMEOUT) / portTICK_PERIOD_MS; +#endif +#if defined (I2C_ONE) + if (port == I2C_NUM_1) { + timeout = pdMS_TO_TICKS( CONFIG_I2C_MANAGER_1_TIMEOUT ); } - #endif +#endif - if (I2C_FN(_lock)((int)port) == ESP_OK) { - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_send_address(cmd, addr, I2C_MASTER_WRITE); - if (!(reg & I2C_NO_REG)) { - i2c_send_register(cmd, reg); - } - i2c_master_write(cmd, (uint8_t *)buffer, size, ACK_CHECK_EN); - i2c_master_stop(cmd); - result = i2c_master_cmd_begin( port, cmd, timeout); - i2c_cmd_link_delete(cmd); - I2C_FN(_unlock)((int)port); - } else { - ESP_LOGE(TAG, "Lock could not be obtained for port %d.", (int)port); - return ESP_ERR_TIMEOUT; - } + if (I2C_FN(_lock)((int)port) == ESP_OK) { + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_send_address(cmd, addr, I2C_MASTER_WRITE); + if (!(reg & I2C_NO_REG)) { + i2c_send_register(cmd, reg); + } + i2c_master_write(cmd, (uint8_t *)buffer, size, ACK_CHECK_EN); + i2c_master_stop(cmd); + result = i2c_master_cmd_begin( port, cmd, timeout); + i2c_cmd_link_delete(cmd); + I2C_FN(_unlock)((int)port); + } else { + ESP_LOGE(TAG, "Lock could not be obtained for port %d.", (int)port); + return ESP_ERR_TIMEOUT; + } if (result != ESP_OK) { - ESP_LOGW(TAG, "Error: %d", result); + ESP_LOGD(TAG, "Error: %d", result); } - ESP_LOG_BUFFER_HEX_LEVEL(TAG, buffer, size, ESP_LOG_VERBOSE); + ESP_LOG_BUFFER_HEX_LEVEL(TAG, buffer, size, ESP_LOG_VERBOSE); return result; } esp_err_t I2C_FN(_close)(i2c_port_t port) { - I2C_PORT_CHECK(port, ESP_FAIL); + I2C_PORT_CHECK(port, ESP_FAIL); vSemaphoreDelete(I2C_FN(_mutex)[port]); I2C_FN(_mutex)[port] = NULL; ESP_LOGI(TAG, "Closing I2C master at port %d", port); @@ -288,59 +288,59 @@ esp_err_t I2C_FN(_close)(i2c_port_t port) { } esp_err_t I2C_FN(_lock)(i2c_port_t port) { - I2C_PORT_CHECK(port, ESP_FAIL); - ESP_LOGV(TAG, "Mutex lock set for %d.", (int)port); + I2C_PORT_CHECK(port, ESP_FAIL); + ESP_LOGV(TAG, "Mutex lock set for %d.", (int)port); - TickType_t timeout; - #if defined (I2C_ZERO) - if (port == I2C_NUM_0) { - timeout = (CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT) / portTICK_PERIOD_MS; + TickType_t timeout; +#if defined (I2C_ZERO) + if (port == I2C_NUM_0) { + timeout = pdMS_TO_TICKS( CONFIG_I2C_MANAGER_0_LOCK_TIMEOUT ); } - #endif - #if defined (I2C_ONE) - if (port == I2C_NUM_1) { - timeout = (CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT) / portTICK_PERIOD_MS; +#endif +#if defined (I2C_ONE) + if (port == I2C_NUM_1) { + timeout = pdMS_TO_TICKS( CONFIG_I2C_MANAGER_1_LOCK_TIMEOUT ); } - #endif +#endif - if (xSemaphoreTake(I2C_FN(_mutex)[port], timeout) == pdTRUE) { - return ESP_OK; - } else { - ESP_LOGE(TAG, "Removing stale mutex lock from port %d.", (int)port); - I2C_FN(_force_unlock)(port); - return (xSemaphoreTake(I2C_FN(_mutex)[port], timeout) == pdTRUE ? ESP_OK : ESP_FAIL); - } + if (xSemaphoreTake(I2C_FN(_mutex)[port], timeout) == pdTRUE) { + return ESP_OK; + } else { + ESP_LOGE(TAG, "Removing stale mutex lock from port %d.", (int)port); + I2C_FN(_force_unlock)(port); + return (xSemaphoreTake(I2C_FN(_mutex)[port], timeout) == pdTRUE ? ESP_OK : ESP_FAIL); + } } esp_err_t I2C_FN(_unlock)(i2c_port_t port) { - I2C_PORT_CHECK(port, ESP_FAIL); - ESP_LOGV(TAG, "Mutex lock removed for %d.", (int)port); - return (xSemaphoreGive(I2C_FN(_mutex)[port]) == pdTRUE) ? ESP_OK : ESP_FAIL; + I2C_PORT_CHECK(port, ESP_FAIL); + ESP_LOGV(TAG, "Mutex lock removed for %d.", (int)port); + return (xSemaphoreGive(I2C_FN(_mutex)[port]) == pdTRUE) ? ESP_OK : ESP_FAIL; } esp_err_t I2C_FN(_force_unlock)(i2c_port_t port) { - I2C_PORT_CHECK(port, ESP_FAIL); - if (I2C_FN(_mutex)[port]) { - vSemaphoreDelete(I2C_FN(_mutex)[port]); - } - I2C_FN(_mutex)[port] = xSemaphoreCreateMutex(); - return ESP_OK; + I2C_PORT_CHECK(port, ESP_FAIL); + if (I2C_FN(_mutex)[port]) { + vSemaphoreDelete(I2C_FN(_mutex)[port]); + } + I2C_FN(_mutex)[port] = xSemaphoreCreateMutex(); + return ESP_OK; } #ifdef I2C_OEM - void I2C_FN(_locking)(void* leader) { - if (leader) { - ESP_LOGI(TAG, "Now following I2C Manager for locking"); - I2C_FN(_mutex) = (SemaphoreHandle_t*)leader; - } +void I2C_FN(_locking)(void* leader) { + if (leader) { + ESP_LOGI(TAG, "Now following I2C Manager for locking"); + I2C_FN(_mutex) = (SemaphoreHandle_t*)leader; } +} #else - void* i2c_manager_locking() { +void* i2c_manager_locking() { return (void*)i2c_manager_mutex; } @@ -365,4 +365,4 @@ esp_err_t I2C_FN(_force_unlock)(i2c_port_t port) { return (void*)&_i2c_hal[port]; } -#endif +#endif \ No newline at end of file diff --git a/lvgl_i2c/i2c_manager.h b/lvgl_i2c/i2c_manager.h index f9ce5850..ddbbd337 100644 --- a/lvgl_i2c/i2c_manager.h +++ b/lvgl_i2c/i2c_manager.h @@ -29,9 +29,9 @@ extern "C" { #define STR_QUOTE(s) STR_EXPAND(STR_EXPAND(s)) #ifdef I2C_OEM - #define I2C_NAME_PREFIX CONCAT(I2C_OEM, _i2c) +#define I2C_NAME_PREFIX CONCAT(I2C_OEM, _i2c) #else - #define I2C_NAME_PREFIX i2c_manager +#define I2C_NAME_PREFIX i2c_manager #endif #define I2C_TAG STR_EXPAND(I2C_NAME_PREFIX) @@ -53,19 +53,19 @@ esp_err_t I2C_FN(_force_unlock)(i2c_port_t port); #ifdef I2C_OEM - void I2C_FN(_locking)(void* leader); +void I2C_FN(_locking)(void* leader); #else - void* i2c_manager_locking(); +void* i2c_manager_locking(); - typedef struct { - int32_t (* read)(void *handle, uint8_t address, uint8_t reg, uint8_t *buffer, uint16_t size); - int32_t (* write)(void *handle, uint8_t address, uint8_t reg, const uint8_t *buffer, uint16_t size); - void *handle; - } i2c_hal_t; +typedef struct { + int32_t (* read)(void *handle, uint8_t address, uint8_t reg, uint8_t *buffer, uint16_t size); + int32_t (* write)(void *handle, uint8_t address, uint8_t reg, const uint8_t *buffer, uint16_t size); + void *handle; +} i2c_hal_t; - void* i2c_hal(i2c_port_t port); +void* i2c_hal(i2c_port_t port); #endif @@ -73,4 +73,4 @@ esp_err_t I2C_FN(_force_unlock)(i2c_port_t port); #ifdef __cplusplus } #endif -#endif +#endif \ No newline at end of file From 4065c3bfc1b3fe090299bb2cc396ea58ee515bb6 Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 27 May 2023 13:08:59 +1000 Subject: [PATCH 09/20] fix esp_log fmt --- lvgl_i2c/i2c_manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lvgl_i2c/i2c_manager.c b/lvgl_i2c/i2c_manager.c index 6780d9fc..e7f8f019 100644 --- a/lvgl_i2c/i2c_manager.c +++ b/lvgl_i2c/i2c_manager.c @@ -168,7 +168,7 @@ esp_err_t I2C_FN(_init)(i2c_port_t port) { ESP_LOGW(TAG, "If it was already open, we'll use it with whatever settings were used " "to open it. See I2C Manager README for details."); } else { - ESP_LOGI(TAG, "Initialised port %d (SDA: %d, SCL: %d, speed: %d Hz.)", + ESP_LOGI(TAG, "Initialised port %d (SDA: %d, SCL: %d, speed: %lu Hz.)", port, conf.sda_io_num, conf.scl_io_num, conf.master.clk_speed); } @@ -186,7 +186,7 @@ esp_err_t I2C_FN(_read)(i2c_port_t port, uint16_t addr, uint32_t reg, uint8_t *b // May seem weird, but init starts with a check if it's needed, no need for that check twice. I2C_FN(_init)(port); - ESP_LOGV(TAG, "Reading port %d, addr 0x%03x, reg 0x%04x", port, addr, reg); + ESP_LOGV(TAG, "Reading port %d, addr 0x%03x, reg 0x%04lx", port, addr, reg); TickType_t timeout = 0; #if defined (I2C_ZERO) @@ -239,7 +239,7 @@ esp_err_t I2C_FN(_write)(i2c_port_t port, uint16_t addr, uint32_t reg, const uin // May seem weird, but init starts with a check if it's needed, no need for that check twice. I2C_FN(_init)(port); - ESP_LOGV(TAG, "Writing port %d, addr 0x%03x, reg 0x%04x", port, addr, reg); + ESP_LOGV(TAG, "Writing port %d, addr 0x%03x, reg 0x%04lx", port, addr, reg); TickType_t timeout = 0; #if defined (I2C_ZERO) From 26c7396892e104ef50430e083f94559f7a9603ac Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 27 May 2023 13:24:29 +1000 Subject: [PATCH 10/20] fix i2c_manager port conf check --- lvgl_i2c/i2c_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lvgl_i2c/i2c_manager.c b/lvgl_i2c/i2c_manager.c index e7f8f019..2816486f 100644 --- a/lvgl_i2c/i2c_manager.c +++ b/lvgl_i2c/i2c_manager.c @@ -58,7 +58,7 @@ static SemaphoreHandle_t* I2C_FN(_mutex) = &I2C_FN(_local_mutex)[0]; static const uint8_t ACK_CHECK_EN = 1; -#if defined (I2C_NUM_0) && defined (CONFIG_I2C_MANAGER_0_ENABLED) +#if defined (CONFIG_I2C_MANAGER_0_ENABLED) #define I2C_ZERO I2C_NUM_0 #if defined (CONFIG_I2C_MANAGER_0_PULLUPS) #define I2C_MANAGER_0_PULLUPS true @@ -71,7 +71,7 @@ static const uint8_t ACK_CHECK_EN = 1; #endif -#if defined (I2C_NUM_1) && defined (CONFIG_I2C_MANAGER_1_ENABLED) +#if defined (CONFIG_I2C_MANAGER_1_ENABLED) #define I2C_ONE I2C_NUM_1 #if defined (CONFIG_I2C_MANAGER_1_PULLUPS) #define I2C_MANAGER_1_PULLUPS true From 2ebaaf22e0d14464e73d546199eb7077adf48e4c Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 27 May 2023 15:29:12 +1000 Subject: [PATCH 11/20] CONFIG_LV_THEME_MONO -> CONFIG_LV_USE_THEME_MONO --- lvgl_helpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl_helpers.h b/lvgl_helpers.h index 0e427d70..3e7715ba 100644 --- a/lvgl_helpers.h +++ b/lvgl_helpers.h @@ -64,7 +64,7 @@ extern "C" { #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341 #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SSD1306 -#if defined (CONFIG_LV_THEME_MONO) +#if defined (CONFIG_LV_USE_THEME_MONO) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * (LV_VER_RES_MAX / 8)) #else #define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX) From 52e2a4332e1acba988ebf4f021a3e19f6d9fc50e Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 27 May 2023 17:47:56 +1000 Subject: [PATCH 12/20] set DISP_BUF_SIZE to LV_HOR_RES_MAX * LV_VER_RES_MAX --- lvgl_helpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl_helpers.h b/lvgl_helpers.h index 3e7715ba..69d8ce4e 100644 --- a/lvgl_helpers.h +++ b/lvgl_helpers.h @@ -48,7 +48,7 @@ extern "C" { #if defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7789) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7735S -#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) +#define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX) #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ST7796S #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357 From fd4119638f73f34a01642d8e834c4432abac90f2 Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 27 May 2023 18:11:46 +1000 Subject: [PATCH 13/20] add offsets for 128x128 display --- lvgl_tft/st7735s.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lvgl_tft/st7735s.h b/lvgl_tft/st7735s.h index 2d02ed05..78e1d38b 100644 --- a/lvgl_tft/st7735s.h +++ b/lvgl_tft/st7735s.h @@ -37,8 +37,19 @@ extern "C" { // https://github.com/adafruit/Adafruit-ST7735-Library // #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 / 1 offset) + +// TODO: this should be config option +#if CONFIG_LV_HOR_RES_MAX==128 && CONFIG_LV_VER_RES_MAX==128 +#define COLSTART 2 +#define ROWSTART 1 +#elif CONFIG_LV_HOR_RES_MAX==128 && CONFIG_LV_VER_RES_MAX==80 #define COLSTART 26 #define ROWSTART 1 +#else +#define COLSTART 0 +#define ROWSTART 0 +#endif + // Delay between some initialisation commands #define TFT_INIT_DELAY 0x80 From aa1dae20768f517154e09319d6c566a390f2d2e5 Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 27 May 2023 18:31:34 +1000 Subject: [PATCH 14/20] fix rowstart for 128x128 --- lvgl_tft/st7735s.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl_tft/st7735s.h b/lvgl_tft/st7735s.h index 78e1d38b..b92a68a3 100644 --- a/lvgl_tft/st7735s.h +++ b/lvgl_tft/st7735s.h @@ -41,7 +41,7 @@ extern "C" { // TODO: this should be config option #if CONFIG_LV_HOR_RES_MAX==128 && CONFIG_LV_VER_RES_MAX==128 #define COLSTART 2 -#define ROWSTART 1 +#define ROWSTART 3 #elif CONFIG_LV_HOR_RES_MAX==128 && CONFIG_LV_VER_RES_MAX==80 #define COLSTART 26 #define ROWSTART 1 From f22026caf7e751575a17ed3f268621ad90fc205e Mon Sep 17 00:00:00 2001 From: hiruna Date: Wed, 31 May 2023 01:15:28 +1000 Subject: [PATCH 15/20] use spi dma chan auto for esp32s3 --- lvgl_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvgl_helpers.c b/lvgl_helpers.c index 57ab7dd1..52b20f15 100644 --- a/lvgl_helpers.c +++ b/lvgl_helpers.c @@ -175,7 +175,7 @@ bool lvgl_spi_driver_init(int host, }; ESP_LOGI(TAG, "Initializing SPI bus..."); - #if defined (CONFIG_IDF_TARGET_ESP32C3) + #if defined (CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) dma_channel = SPI_DMA_CH_AUTO; #endif esp_err_t ret = spi_bus_initialize(host, &buscfg, (spi_dma_chan_t)dma_channel); From 16f9f93dab43f492fb444df42c61d11da790fdff Mon Sep 17 00:00:00 2001 From: hiruna Date: Wed, 31 May 2023 01:15:55 +1000 Subject: [PATCH 16/20] add disp offsets for 170x320px st7789 displays --- lvgl_tft/st7789.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lvgl_tft/st7789.c b/lvgl_tft/st7789.c index f2144b19..40451f84 100644 --- a/lvgl_tft/st7789.c +++ b/lvgl_tft/st7789.c @@ -162,8 +162,17 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo offsety1 += 40; offsety2 += 40; #endif +#elif (LV_HOR_RES_MAX == 320) && (LV_VER_RES_MAX == 170) // 1.9 inch 170×320 LCD, physically landscape + #if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT) || (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED) + offsety1 += 35; + offsety2 += 35; + #endif +#elif (LV_HOR_RES_MAX == 170) && (LV_VER_RES_MAX == 320) // 1.9 inch 170×320 LCD, physically vertical + #if (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE) || (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED) + offsetx1 += 35; + offsetx2 += 35; + #endif #endif - /*Column addresses*/ st7789_send_cmd(ST7789_CASET); data[0] = (offsetx1 >> 8) & 0xFF; From 50b212aa560dc9f92e38a0d4ef4b62e977e630b6 Mon Sep 17 00:00:00 2001 From: hiruna Date: Thu, 1 Jun 2023 20:08:43 +1000 Subject: [PATCH 17/20] change touch controller readouts to verbose logger --- lvgl_touch/ft6x36.c | 2 +- lvgl_touch/gt911.c | 2 +- lvgl_touch/ra8875_touch.c | 65 ++++++++++++++++++--------------------- lvgl_touch/xpt2046.c | 6 ++-- 4 files changed, 35 insertions(+), 40 deletions(-) diff --git a/lvgl_touch/ft6x36.c b/lvgl_touch/ft6x36.c index dae736c2..9c9dc13c 100644 --- a/lvgl_touch/ft6x36.c +++ b/lvgl_touch/ft6x36.c @@ -150,7 +150,7 @@ bool ft6x36_read(lv_indev_drv_t *drv, lv_indev_data_t *data) { data->point.x = touch_inputs.last_x; data->point.y = touch_inputs.last_y; data->state = touch_inputs.current_state; - ESP_LOGD(TAG, "X=%u Y=%u", data->point.x, data->point.y); + ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y); #if CONFIG_LV_FT6X36_COORDINATES_QUEUE xQueueOverwrite( ft6x36_touch_queue_handle, &touch_inputs ); diff --git a/lvgl_touch/gt911.c b/lvgl_touch/gt911.c index 03c3d9d4..e4c49952 100644 --- a/lvgl_touch/gt911.c +++ b/lvgl_touch/gt911.c @@ -138,7 +138,7 @@ bool gt911_read(lv_indev_drv_t *drv, lv_indev_data_t *data) { data->point.x = last_x; data->point.y = last_y; data->state = LV_INDEV_STATE_PR; - ESP_LOGI(TAG, "X=%u Y=%u", data->point.x, data->point.y); + ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y); ESP_LOGV(TAG, "X=%u Y=%u", data->point.x, data->point.y); return false; } diff --git a/lvgl_touch/ra8875_touch.c b/lvgl_touch/ra8875_touch.c index 3340e4f3..541ae09f 100644 --- a/lvgl_touch/ra8875_touch.c +++ b/lvgl_touch/ra8875_touch.c @@ -16,7 +16,7 @@ #include "../lvgl_tft/ra8875.h" #ifndef CONFIG_LV_TFT_DISPLAY_CONTROLLER_RA8875 - #error "Display controller must be RA8875" +#error "Display controller must be RA8875" #endif /********************* @@ -31,23 +31,23 @@ #define TPCR0_ADC_TIMING ((CONFIG_LV_TOUCH_RA8875_SAMPLE_TIME << 4) | CONFIG_LV_TOUCH_RA8875_ADC_CLOCK) #if LVGL_TOUCH_RA8875_WAKEUP_ENABLE - #define TPCR0_VAL (0x08 | TPCR0_ADC_TIMING) +#define TPCR0_VAL (0x08 | TPCR0_ADC_TIMING) #else - #define TPCR0_VAL (TPCR0_ADC_TIMING) +#define TPCR0_VAL (TPCR0_ADC_TIMING) #endif #if LVGL_TOUCH_RA8875_EXTERNAL_VREF - #if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE - #define TPCR1_VAL (0x24) - #else - #define TPCR1_VAL (0x20) - #endif +#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE +#define TPCR1_VAL (0x24) #else - #if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE - #define TPCR1_VAL (0x04) - #else - #define TPCR1_VAL (0x00) - #endif +#define TPCR1_VAL (0x20) +#endif +#else +#if LVGL_TOUCH_RA8875_DEBOUNCE_ENABLE +#define TPCR1_VAL (0x04) +#else +#define TPCR1_VAL (0x00) +#endif #endif /********************** @@ -58,7 +58,7 @@ * STATIC PROTOTYPES **********************/ -static void ra8875_corr(int * x, int * y); +static void ra8875_corr(int *x, int *y); /********************** * STATIC VARIABLES @@ -72,16 +72,15 @@ static void ra8875_corr(int * x, int * y); * GLOBAL FUNCTIONS **********************/ -void ra8875_touch_init(void) -{ +void ra8875_touch_init(void) { struct { uint8_t cmd; // Register address of command uint8_t data; // Value to write to register } init_cmds[] = { - {RA8875_REG_TPCR0, TPCR0_VAL}, // Touch Panel Control Register 0 (TPCR0) - {RA8875_REG_TPCR1, TPCR1_VAL}, // Touch Panel Control Register 1 (TPCR1) + {RA8875_REG_TPCR0, TPCR0_VAL}, // Touch Panel Control Register 0 (TPCR0) + {RA8875_REG_TPCR1, TPCR1_VAL}, // Touch Panel Control Register 1 (TPCR1) }; - #define INIT_CMDS_SIZE (sizeof(init_cmds)/sizeof(init_cmds[0])) +#define INIT_CMDS_SIZE (sizeof(init_cmds)/sizeof(init_cmds[0])) ESP_LOGI(TAG, "Initializing RA8875 Touch..."); @@ -92,8 +91,7 @@ void ra8875_touch_init(void) ra8875_touch_enable(true); } -void ra8875_touch_enable(bool enable) -{ +void ra8875_touch_enable(bool enable) { ESP_LOGI(TAG, "%s touch.", enable ? "Enabling" : "Disabling"); uint8_t val = enable ? (0x80 | TPCR0_VAL) : (TPCR0_VAL); ra8875_write_cmd(RA8875_REG_TPCR0, val); @@ -104,8 +102,7 @@ void ra8875_touch_enable(bool enable) * @param data store the read data here * @return false: because no more data to be read */ -bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data) -{ +bool ra8875_touch_read(lv_indev_drv_t *drv, lv_indev_data_t *data) { static int x = 0; static int y = 0; @@ -121,9 +118,9 @@ bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data) x = (x << 2) | (xy & 0x03); y = (y << 2) | ((xy >> 2) & 0x03); -#if DEBUG - ESP_LOGI(TAG, "Touch Poll Raw: %d,%d", x, y); -#endif + + ESP_LOGV(TAG, "Touch Poll Raw: %d,%d", x, y); + // Convert to display coordinates ra8875_corr(&x, &y); @@ -135,9 +132,8 @@ bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data) data->point.x = x; data->point.y = y; -#if DEBUG - ESP_LOGI(TAG, "Touch Poll - Event: %d; %d,%d", data->state, data->point.x, data->point.y); -#endif + ESP_LOGV(TAG, "Touch Poll - Event: %d; %d,%d", data->state, data->point.x, data->point.y); + return false; } @@ -147,8 +143,7 @@ bool ra8875_touch_read(lv_indev_drv_t * drv, lv_indev_data_t * data) * STATIC FUNCTIONS **********************/ -static void ra8875_corr(int * x, int * y) -{ +static void ra8875_corr(int *x, int *y) { #if RA8875_XY_SWAP != 0 int tmp = *x; *x = *y; @@ -158,17 +153,17 @@ static void ra8875_corr(int * x, int * y) if ((*x) <= RA8875_X_MIN) { (*x) = 0; } else if ((*x) >= RA8875_X_MAX) { - (*x) = LV_HOR_RES-1; + (*x) = LV_HOR_RES - 1; } else { - (*x) = (((*x) - RA8875_X_MIN) * (LV_HOR_RES-1)) / (RA8875_X_MAX - RA8875_X_MIN); + (*x) = (((*x) - RA8875_X_MIN) * (LV_HOR_RES - 1)) / (RA8875_X_MAX - RA8875_X_MIN); } if ((*y) <= RA8875_Y_MIN) { (*y) = 0; } else if ((*y) >= RA8875_Y_MAX) { - (*y) = LV_VER_RES-1; + (*y) = LV_VER_RES - 1; } else { - (*y) = (((*y) - RA8875_Y_MIN) * (LV_VER_RES-1)) / (RA8875_Y_MAX - RA8875_Y_MIN); + (*y) = (((*y) - RA8875_Y_MIN) * (LV_VER_RES - 1)) / (RA8875_Y_MAX - RA8875_Y_MIN); } #if RA8875_X_INV != 0 diff --git a/lvgl_touch/xpt2046.c b/lvgl_touch/xpt2046.c index 93b4329f..22616898 100644 --- a/lvgl_touch/xpt2046.c +++ b/lvgl_touch/xpt2046.c @@ -94,19 +94,19 @@ bool xpt2046_read(lv_indev_drv_t * drv, lv_indev_data_t * data) x = xpt2046_cmd(CMD_X_READ); y = xpt2046_cmd(CMD_Y_READ); - ESP_LOGI(TAG, "P(%d,%d)", x, y); + ESP_LOGV(TAG, "P(%d,%d)", x, y); /*Normalize Data back to 12-bits*/ x = x >> 4; y = y >> 4; - ESP_LOGI(TAG, "P_norm(%d,%d)", x, y); + ESP_LOGV(TAG, "P_norm(%d,%d)", x, y); xpt2046_corr(&x, &y); xpt2046_avg(&x, &y); last_x = x; last_y = y; - ESP_LOGI(TAG, "x = %d, y = %d", x, y); + ESP_LOGV(TAG, "x = %d, y = %d", x, y); } else { From de52f295db7e91165166eb4c9d8bf9aba43cb239 Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 3 Jun 2023 23:08:29 +1000 Subject: [PATCH 18/20] backward compatibility with esp-idf release/v4.4 --- lvgl_helpers.c | 3 +++ lvgl_tft/FT81x.c | 12 ++++++++++-- lvgl_tft/GC9A01.c | 13 ++++++++++++- lvgl_tft/esp_lcd_backlight.c | 13 ++++++++++++- lvgl_tft/hx8357.c | 13 ++++++++++++- lvgl_tft/il3820.c | 16 ++++++++++++++++ lvgl_tft/ili9163c.c | 16 ++++++++++++++-- lvgl_tft/ili9341.c | 12 ++++++++++++ lvgl_tft/ili9481.c | 13 ++++++++++++- lvgl_tft/ili9486.c | 12 ++++++++++++ lvgl_tft/ili9488.c | 14 +++++++++++++- lvgl_tft/pcd8544.c | 13 ++++++++++++- lvgl_tft/ra8875.c | 8 ++++++++ lvgl_tft/sh1107.c | 16 ++++++++++++++-- lvgl_tft/st7735s.c | 16 ++++++++++++++-- lvgl_tft/st7789.c | 12 ++++++++++++ lvgl_tft/st7796s.c | 16 ++++++++++++++-- lvgl_touch/adcraw.c | 16 ++++++++++++++-- 18 files changed, 216 insertions(+), 18 deletions(-) diff --git a/lvgl_helpers.c b/lvgl_helpers.c index 52b20f15..0d642123 100644 --- a/lvgl_helpers.c +++ b/lvgl_helpers.c @@ -23,6 +23,9 @@ #include "lvgl/lvgl.h" #endif +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) +#define SPI_HOST_MAX SOC_SPI_PERIPH_NUM +#endif /********************* * DEFINES *********************/ diff --git a/lvgl_tft/FT81x.c b/lvgl_tft/FT81x.c index 87550796..0242d7e2 100644 --- a/lvgl_tft/FT81x.c +++ b/lvgl_tft/FT81x.c @@ -7,7 +7,10 @@ #include "EVE.h" #include "EVE_commands.h" - +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /* some pre-definded colors */ #define RED 0xff0000UL #define ORANGE 0xffa500UL @@ -263,7 +266,12 @@ void TFT_bitmap_display(void) void FT81x_init(void) { #if EVE_USE_PDN - esp_rom_gpio_pad_select_gpio(EVE_PDN); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(EVE_PDN); +#else + esp_rom_gpio_pad_select_gpio(EVE_PDN); +#endif + #endif gpio_set_level(EVE_CS, 1); diff --git a/lvgl_tft/GC9A01.c b/lvgl_tft/GC9A01.c index fe5c7b8d..b27f444e 100644 --- a/lvgl_tft/GC9A01.c +++ b/lvgl_tft/GC9A01.c @@ -12,7 +12,10 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" - +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES *********************/ @@ -112,11 +115,19 @@ void GC9A01_init(void) }; //Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(GC9A01_DC); +#else esp_rom_gpio_pad_select_gpio(GC9A01_DC); +#endif gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT); #if GC9A01_USE_RST +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(GC9A01_RST); +#else esp_rom_gpio_pad_select_gpio(GC9A01_RST); +#endif gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/esp_lcd_backlight.c b/lvgl_tft/esp_lcd_backlight.c index 0da96cb6..27f15fb1 100644 --- a/lvgl_tft/esp_lcd_backlight.c +++ b/lvgl_tft/esp_lcd_backlight.c @@ -12,7 +12,10 @@ #include "driver/gpio.h" #include "esp_log.h" #include "soc/ledc_periph.h" // to invert LEDC output on IDF version < v4.3 - +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif typedef struct { bool pwm_control; // true: LEDC is used, false: GPIO is used int index; // Either GPIO or LEDC channel @@ -63,7 +66,11 @@ disp_backlight_h disp_backlight_new(const disp_backlight_config_t *config) { // Configure GPIO for output bckl_dev->index = config->gpio_num; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(config->gpio_num); +#else esp_rom_gpio_pad_select_gpio(config->gpio_num); +#endif ESP_ERROR_CHECK(gpio_set_direction(config->gpio_num, GPIO_MODE_OUTPUT)); gpio_iomux_out(config->gpio_num, SIG_GPIO_OUT_IDX, config->output_invert); } @@ -102,7 +109,11 @@ void disp_backlight_delete(disp_backlight_h bckl) if (bckl_dev->pwm_control) { ledc_stop(LEDC_LOW_SPEED_MODE, bckl_dev->index, 0); } else { +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(bckl_dev->index); +#else esp_rom_gpio_pad_select_gpio(bckl_dev->index); +#endif } free (bckl); } diff --git a/lvgl_tft/hx8357.c b/lvgl_tft/hx8357.c index 30a3e384..b5b2a9d1 100644 --- a/lvgl_tft/hx8357.c +++ b/lvgl_tft/hx8357.c @@ -21,7 +21,10 @@ #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" - +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES *********************/ @@ -160,11 +163,19 @@ static uint8_t displayType = HX8357D; void hx8357_init(void) { //Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(HX8357_DC); +#else esp_rom_gpio_pad_select_gpio(HX8357_DC); +#endif gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT); #if HX8357_USE_RST +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(HX8357_RST); +#else esp_rom_gpio_pad_select_gpio(HX8357_RST); +#endif gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/il3820.c b/lvgl_tft/il3820.c index d4ff1add..7bad8762 100644 --- a/lvgl_tft/il3820.c +++ b/lvgl_tft/il3820.c @@ -33,6 +33,10 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif #include "il3820.h" @@ -196,14 +200,26 @@ void il3820_init(void) uint8_t tmp[3] = {0}; /* Initialize non-SPI GPIOs */ +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(IL3820_DC_PIN); +#else esp_rom_gpio_pad_select_gpio(IL3820_DC_PIN); +#endif gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(IL3820_BUSY_PIN); +#else esp_rom_gpio_pad_select_gpio(IL3820_BUSY_PIN); +#endif gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT); #if IL3820_USE_RST +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(IL3820_RST_PIN); +#else esp_rom_gpio_pad_select_gpio(IL3820_RST_PIN); +#endif gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT); /* Harware reset */ diff --git a/lvgl_tft/ili9163c.c b/lvgl_tft/ili9163c.c index a4e00190..c52b6aab 100644 --- a/lvgl_tft/ili9163c.c +++ b/lvgl_tft/ili9163c.c @@ -13,6 +13,10 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "assert.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -138,9 +142,17 @@ void ili9163c_init(void) }; //Initialize non-SPI GPIOs - esp_rom_gpio_pad_select_gpio(ILI9163C_DC); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9163C_DC); +#else + esp_rom_gpio_pad_select_gpio(ILI9163C_DC); +#endif gpio_set_direction(ILI9163C_DC, GPIO_MODE_OUTPUT); - esp_rom_gpio_pad_select_gpio(ILI9163C_RST); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9163C_RST); +#else + esp_rom_gpio_pad_select_gpio(ILI9163C_RST); +#endif gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9341.c b/lvgl_tft/ili9341.c index f580e677..99ae5a24 100644 --- a/lvgl_tft/ili9341.c +++ b/lvgl_tft/ili9341.c @@ -12,6 +12,10 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -81,11 +85,19 @@ void ili9341_init(void) }; //Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9341_DC); +#else esp_rom_gpio_pad_select_gpio(ILI9341_DC); +#endif gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT); #if ILI9341_USE_RST +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9341_RST); +#else esp_rom_gpio_pad_select_gpio(ILI9341_RST); +#endif gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9481.c b/lvgl_tft/ili9481.c index b27c5177..5a2679e0 100644 --- a/lvgl_tft/ili9481.c +++ b/lvgl_tft/ili9481.c @@ -13,7 +13,10 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" - +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES *********************/ @@ -74,11 +77,19 @@ void ili9481_init(void) }; //Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9481_DC); +#else esp_rom_gpio_pad_select_gpio(ILI9481_DC); +#endif gpio_set_direction(ILI9481_DC, GPIO_MODE_OUTPUT); #if ILI9481_USE_RST +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9481_RST); +#else esp_rom_gpio_pad_select_gpio(ILI9481_RST); +#endif gpio_set_direction(ILI9481_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9486.c b/lvgl_tft/ili9486.c index 0d4a8231..ef5c3fbd 100644 --- a/lvgl_tft/ili9486.c +++ b/lvgl_tft/ili9486.c @@ -12,6 +12,10 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -66,11 +70,19 @@ void ili9486_init(void) }; //Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9486_DC); +#else esp_rom_gpio_pad_select_gpio(ILI9486_DC); +#endif gpio_set_direction(ILI9486_DC, GPIO_MODE_OUTPUT); #if ILI9486_USE_RST +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9486_RST); +#else esp_rom_gpio_pad_select_gpio(ILI9486_RST); +#endif gpio_set_direction(ILI9486_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/ili9488.c b/lvgl_tft/ili9488.c index f67a5d14..769d8683 100644 --- a/lvgl_tft/ili9488.c +++ b/lvgl_tft/ili9488.c @@ -13,6 +13,10 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -76,11 +80,19 @@ void ili9488_init(void) }; //Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9488_DC); +#else esp_rom_gpio_pad_select_gpio(ILI9488_DC); +#endif gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT); #if ILI9488_USE_RST - esp_rom_gpio_pad_select_gpio(ILI9488_RST); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ILI9488_RST); +#else + esp_rom_gpio_pad_select_gpio(ILI9488_RST); +#endif gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/pcd8544.c b/lvgl_tft/pcd8544.c index 9f5e2ff0..9dcd9357 100644 --- a/lvgl_tft/pcd8544.c +++ b/lvgl_tft/pcd8544.c @@ -14,7 +14,10 @@ #include "freertos/task.h" #include "pcd8544.h" - +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif #define TAG "lv_pcd8544" /********************** @@ -57,9 +60,17 @@ void pcd8544_init(void){ // TODO: orientation // Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(PCD8544_DC); +#else esp_rom_gpio_pad_select_gpio(PCD8544_DC); +#endif gpio_set_direction(PCD8544_DC, GPIO_MODE_OUTPUT); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(PCD8544_RST); +#else esp_rom_gpio_pad_select_gpio(PCD8544_RST); +#endif gpio_set_direction(PCD8544_RST, GPIO_MODE_OUTPUT); // Reset the display diff --git a/lvgl_tft/ra8875.c b/lvgl_tft/ra8875.c index 2a5e4559..73acd4fd 100644 --- a/lvgl_tft/ra8875.c +++ b/lvgl_tft/ra8875.c @@ -12,6 +12,10 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -151,7 +155,11 @@ void ra8875_init(void) // Initialize non-SPI GPIOs #if RA8875_USE_RST +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(RA8875_RST); +#else esp_rom_gpio_pad_select_gpio(RA8875_RST); +#endif gpio_set_direction(RA8875_RST, GPIO_MODE_OUTPUT); // Reset the RA8875 diff --git a/lvgl_tft/sh1107.c b/lvgl_tft/sh1107.c index bef776c3..622d0027 100644 --- a/lvgl_tft/sh1107.c +++ b/lvgl_tft/sh1107.c @@ -12,6 +12,10 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -92,11 +96,19 @@ void sh1107_init(void) }; //Initialize non-SPI GPIOs - esp_rom_gpio_pad_select_gpio(SH1107_DC); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(SH1107_DC); +#else + esp_rom_gpio_pad_select_gpio(SH1107_DC); +#endif gpio_set_direction(SH1107_DC, GPIO_MODE_OUTPUT); #if SH1107_USE_RST - esp_rom_gpio_pad_select_gpio(SH1107_RST); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(SH1107_RST); +#else + esp_rom_gpio_pad_select_gpio(SH1107_RST); +#endif gpio_set_direction(SH1107_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/st7735s.c b/lvgl_tft/st7735s.c index ed1f4810..e8176454 100644 --- a/lvgl_tft/st7735s.c +++ b/lvgl_tft/st7735s.c @@ -12,6 +12,10 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif #ifdef CONFIG_LV_M5STICKC_HANDLE_AXP192 #include "lvgl_i2c/i2c_manager.h" @@ -98,11 +102,19 @@ void st7735s_init(void) }; //Initialize non-SPI GPIOs - esp_rom_gpio_pad_select_gpio(ST7735S_DC); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ST7735S_DC); +#else + esp_rom_gpio_pad_select_gpio(ST7735S_DC); +#endif gpio_set_direction(ST7735S_DC, GPIO_MODE_OUTPUT); #if ST7735S_USE_RST - esp_rom_gpio_pad_select_gpio(ST7735S_RST); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ST7735S_RST); +#else + esp_rom_gpio_pad_select_gpio(ST7735S_RST); +#endif gpio_set_direction(ST7735S_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_tft/st7789.c b/lvgl_tft/st7789.c index 40451f84..361924c1 100644 --- a/lvgl_tft/st7789.c +++ b/lvgl_tft/st7789.c @@ -14,6 +14,10 @@ #include "disp_spi.h" #include "driver/gpio.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -86,11 +90,19 @@ void st7789_init(void) }; //Initialize non-SPI GPIOs +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ST7789_DC); +#else esp_rom_gpio_pad_select_gpio(ST7789_DC); +#endif gpio_set_direction(ST7789_DC, GPIO_MODE_OUTPUT); #if !defined(ST7789_SOFT_RST) +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ST7789_RST); +#else esp_rom_gpio_pad_select_gpio(ST7789_RST); +#endif gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT); #endif diff --git a/lvgl_tft/st7796s.c b/lvgl_tft/st7796s.c index 6faae1e3..072c433f 100644 --- a/lvgl_tft/st7796s.c +++ b/lvgl_tft/st7796s.c @@ -12,6 +12,10 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif /********************* * DEFINES @@ -82,11 +86,19 @@ void st7796s_init(void) }; //Initialize non-SPI GPIOs - esp_rom_gpio_pad_select_gpio(ST7796S_DC); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ST7796S_DC); +#else + esp_rom_gpio_pad_select_gpio(ST7796S_DC); +#endif gpio_set_direction(ST7796S_DC, GPIO_MODE_OUTPUT); #if ST7796S_USE_RST - esp_rom_gpio_pad_select_gpio(ST7796S_RST); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ST7796S_RST); +#else + esp_rom_gpio_pad_select_gpio(ST7796S_RST); +#endif gpio_set_direction(ST7796S_RST, GPIO_MODE_OUTPUT); //Reset the display diff --git a/lvgl_touch/adcraw.c b/lvgl_touch/adcraw.c index 77590489..e0930a5a 100644 --- a/lvgl_touch/adcraw.c +++ b/lvgl_touch/adcraw.c @@ -9,6 +9,10 @@ #include "freertos/task.h" #include "driver/gpio.h" #include +#include "esp_idf_version.h" +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5,0,0) +#include "rom/gpio.h" +#endif #if CONFIG_LV_TOUCH_CONTROLLER_ADCRAW @@ -139,10 +143,18 @@ static void setup_axis(gpio_num_t plus, gpio_num_t minus, gpio_num_t measure, gp { // Set GPIOs: // - Float "ignore" and "measure" - esp_rom_gpio_pad_select_gpio(ignore); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(ignore); +#else + esp_rom_gpio_pad_select_gpio(ignore); +#endif gpio_set_direction(ignore, GPIO_MODE_DISABLE); gpio_set_pull_mode(ignore, GPIO_FLOATING); - esp_rom_gpio_pad_select_gpio(measure); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + gpio_pad_select_gpio(measure); +#else + esp_rom_gpio_pad_select_gpio(measure); +#endif gpio_set_direction(measure, GPIO_MODE_DISABLE); gpio_set_pull_mode(measure, GPIO_FLOATING); // - Set "plus" to 1, "minus" to 0 From 66cee1b1916b629778e02aed7680dda3ee2f6a06 Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 3 Jun 2023 23:18:37 +1000 Subject: [PATCH 19/20] missing include esp_idf_version.h --- lvgl_helpers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lvgl_helpers.c b/lvgl_helpers.c index 0d642123..e2497b9e 100644 --- a/lvgl_helpers.c +++ b/lvgl_helpers.c @@ -16,6 +16,7 @@ #include "lvgl_spi_conf.h" #include "lvgl_i2c/i2c_manager.h" +#include "esp_idf_version.h" #ifdef LV_LVGL_H_INCLUDE_SIMPLE #include "lvgl.h" From a76c88fd66cf611a5ace4875c3791c778218f29b Mon Sep 17 00:00:00 2001 From: hiruna Date: Sat, 3 Jun 2023 23:28:41 +1000 Subject: [PATCH 20/20] backward compatibility with esp-idf release/v4.2 (<4.3) --- lvgl_helpers.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lvgl_helpers.c b/lvgl_helpers.c index e2497b9e..0ee795c1 100644 --- a/lvgl_helpers.c +++ b/lvgl_helpers.c @@ -182,7 +182,11 @@ bool lvgl_spi_driver_init(int host, #if defined (CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) 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, dma_channel); +#else esp_err_t ret = spi_bus_initialize(host, &buscfg, (spi_dma_chan_t)dma_channel); +#endif assert(ret == ESP_OK); return ESP_OK != ret;