From ec90198dbf7ad5cd76cddb5060b44d58879969db Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Thu, 2 Jan 2025 22:04:20 +0100 Subject: [PATCH] Upgrade to ESP-IDF 5.3.2 (#145) This also fixes the touch driver issue. I also fixed an unrelated touch driver cleanup issue. --- .github/actions/build-firmware/action.yml | 2 +- .github/actions/build-sdk/action.yml | 2 +- App/idf_component.yml | 2 +- Boards/LilygoTdeck/Source/hal/TdeckTouch.cpp | 53 ++++++++----------- Boards/LilygoTdeck/Source/hal/TdeckTouch.h | 1 + .../M5stackCoreS3/Source/hal/CoreS3Touch.cpp | 30 +++++++---- Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h | 4 ++ Boards/YellowBoard/Source/hal/YellowTouch.cpp | 31 +++++++---- Boards/YellowBoard/Source/hal/YellowTouch.h | 4 ++ 9 files changed, 73 insertions(+), 56 deletions(-) diff --git a/.github/actions/build-firmware/action.yml b/.github/actions/build-firmware/action.yml index bcca421a..49edaa72 100644 --- a/.github/actions/build-firmware/action.yml +++ b/.github/actions/build-firmware/action.yml @@ -20,7 +20,7 @@ runs: - name: 'Build' uses: espressif/esp-idf-ci-action@main with: - esp_idf_version: v5.3.1 + esp_idf_version: v5.3.2 target: ${{ inputs.arch }} path: './' - name: 'Release' diff --git a/.github/actions/build-sdk/action.yml b/.github/actions/build-sdk/action.yml index 59d6b893..ed792fbd 100644 --- a/.github/actions/build-sdk/action.yml +++ b/.github/actions/build-sdk/action.yml @@ -20,7 +20,7 @@ runs: - name: 'Build' uses: espressif/esp-idf-ci-action@main with: - esp_idf_version: v5.3.1 + esp_idf_version: v5.3.2 target: ${{ inputs.arch }} path: './' - name: 'Release' diff --git a/App/idf_component.yml b/App/idf_component.yml index 84cc49e7..06b8eb02 100644 --- a/App/idf_component.yml +++ b/App/idf_component.yml @@ -4,4 +4,4 @@ dependencies: espressif/esp_lcd_touch_gt911: "1.1.1~2" espressif/esp_lcd_touch_ft5x06: "1.0.6~1" espressif/esp_lcd_touch: "1.1.2" - idf: '5.3.1' + idf: '5.3.2' diff --git a/Boards/LilygoTdeck/Source/hal/TdeckTouch.cpp b/Boards/LilygoTdeck/Source/hal/TdeckTouch.cpp index 34b9db85..579c8e06 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckTouch.cpp +++ b/Boards/LilygoTdeck/Source/hal/TdeckTouch.cpp @@ -3,7 +3,6 @@ #include "esp_err.h" #include "esp_lcd_touch_gt911.h" #include "Log.h" -#include "kernel/Kernel.h" #include "esp_lvgl_port.h" #define TAG "tdeck_touch" @@ -16,25 +15,10 @@ bool TdeckTouch::start(lv_display_t* display) { const esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); - // TODO: Revert on new ESP-IDF version - static_assert(ESP_IDF_VERSION == ESP_IDF_VERSION_VAL(5, 3, 1)); - esp_lcd_new_panel_io_i2c( - (esp_lcd_i2c_bus_handle_t)TDECK_TOUCH_I2C_BUS_HANDLE, - &io_config, - &ioHandle - ); - /* - if ( - esp_lcd_new_panel_io_i2c( - (esp_lcd_i2c_bus_handle_t)TDECK_TOUCH_I2C_BUS_HANDLE, - &touch_io_config, - &ioHandle - ) != ESP_OK - ) { + if (esp_lcd_new_panel_io_i2c(TDECK_TOUCH_I2C_BUS_HANDLE, &io_config, &ioHandle) != ESP_OK) { TT_LOG_E(TAG, "touch io i2c creation failed"); return false; } - */ esp_lcd_touch_config_t config = { .x_max = TDECK_TOUCH_X_MAX, @@ -58,7 +42,7 @@ bool TdeckTouch::start(lv_display_t* display) { if (esp_lcd_touch_new_i2c_gt911(ioHandle, &config, &touchHandle) != ESP_OK) { TT_LOG_E(TAG, "GT199 driver init failed"); - // TODO: De-init IO + cleanup(); return false; } @@ -71,6 +55,7 @@ bool TdeckTouch::start(lv_display_t* display) { deviceHandle = lvgl_port_add_touch(&touch_cfg); if (deviceHandle == nullptr) { TT_LOG_E(TAG, "Adding touch failed"); + cleanup(); return false; } @@ -78,19 +63,23 @@ bool TdeckTouch::start(lv_display_t* display) { } bool TdeckTouch::stop() { - if (esp_lcd_touch_del(touchHandle) == ESP_OK) { - touchHandle = nullptr; - } else { - TT_LOG_E(TAG, "Deleting driver failed"); - return false; - } - - if (esp_lcd_panel_io_del(ioHandle) == ESP_OK) { - ioHandle = nullptr; - } else { - TT_LOG_E(TAG, "Deleting IO handle failed"); - return false; - } - + cleanup(); return true; } + +void TdeckTouch::cleanup() { + if (deviceHandle != nullptr) { + lv_indev_delete(deviceHandle); + deviceHandle = nullptr; + } + + if (touchHandle != nullptr) { + esp_lcd_touch_del(touchHandle); + touchHandle = nullptr; + } + + if (ioHandle != nullptr) { + esp_lcd_panel_io_del(ioHandle); + ioHandle = nullptr; + } +} diff --git a/Boards/LilygoTdeck/Source/hal/TdeckTouch.h b/Boards/LilygoTdeck/Source/hal/TdeckTouch.h index e35f9b7f..fa97a456 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckTouch.h +++ b/Boards/LilygoTdeck/Source/hal/TdeckTouch.h @@ -10,6 +10,7 @@ private: esp_lcd_panel_io_handle_t _Nullable ioHandle = nullptr; esp_lcd_touch_handle_t _Nullable touchHandle = nullptr; lv_indev_t* _Nullable deviceHandle = nullptr; + void cleanup(); public: bool start(lv_display_t* display) override; bool stop() override; diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.cpp b/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.cpp index b8f40769..efd69017 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.cpp +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.cpp @@ -10,20 +10,13 @@ bool CoreS3Touch::start(lv_display_t* display) { TT_LOG_I(TAG, "Starting"); - esp_lcd_panel_io_handle_t ioHandle; - esp_lcd_touch_handle_t touchHandle; esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG(); - // TODO: Check when ESP-IDF publishes fix (5.3.2 or 5.4.x) - static_assert(ESP_IDF_VERSION == ESP_IDF_VERSION_VAL(5, 3, 1)); - esp_lcd_new_panel_io_i2c(I2C_NUM_0, &touch_io_config, &ioHandle); - /* if (esp_lcd_new_panel_io_i2c(I2C_NUM_0, &touch_io_config, &ioHandle) != ESP_OK) { TT_LOG_E(TAG, "Touch I2C IO init failed"); return false; } - */ esp_lcd_touch_config_t config = { .x_max = 320, @@ -47,6 +40,7 @@ bool CoreS3Touch::start(lv_display_t* display) { if (esp_lcd_touch_new_i2c_ft5x06(ioHandle, &config, &touchHandle) != ESP_OK) { TT_LOG_E(TAG, "Driver init failed"); + cleanup(); return false; } @@ -58,6 +52,7 @@ bool CoreS3Touch::start(lv_display_t* display) { deviceHandle = lvgl_port_add_touch(&touch_cfg); if (deviceHandle == nullptr) { TT_LOG_E(TAG, "Adding touch failed"); + cleanup(); return false; } @@ -66,8 +61,23 @@ bool CoreS3Touch::start(lv_display_t* display) { } bool CoreS3Touch::stop() { - tt_assert(deviceHandle != nullptr); - lv_indev_delete(deviceHandle); - deviceHandle = nullptr; + cleanup(); return true; } + +void CoreS3Touch::cleanup() { + if (deviceHandle != nullptr) { + lv_indev_delete(deviceHandle); + deviceHandle = nullptr; + } + + if (touchHandle != nullptr) { + esp_lcd_touch_del(touchHandle); + touchHandle = nullptr; + } + + if (ioHandle != nullptr) { + esp_lcd_panel_io_del(ioHandle); + ioHandle = nullptr; + } +} \ No newline at end of file diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h b/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h index 8edb2dbd..9cca7aa8 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h @@ -2,10 +2,14 @@ #include "hal/Touch.h" #include "TactilityCore.h" +#include class CoreS3Touch : public tt::hal::Touch { private: + esp_lcd_panel_io_handle_t ioHandle = nullptr; + esp_lcd_touch_handle_t touchHandle = nullptr; lv_indev_t* _Nullable deviceHandle = nullptr; + void cleanup(); public: bool start(lv_display_t* display) override; bool stop() override; diff --git a/Boards/YellowBoard/Source/hal/YellowTouch.cpp b/Boards/YellowBoard/Source/hal/YellowTouch.cpp index 0a5e8466..7da3e993 100644 --- a/Boards/YellowBoard/Source/hal/YellowTouch.cpp +++ b/Boards/YellowBoard/Source/hal/YellowTouch.cpp @@ -11,20 +11,12 @@ bool YellowTouch::start(lv_display_t* display) { TT_LOG_I(TAG, "Starting"); - esp_lcd_panel_io_handle_t ioHandle; - esp_lcd_touch_handle_t touchHandle; - const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG(); - // TODO: Check when ESP-IDF publishes fix (5.3.2 or 5.4.x) - static_assert(ESP_IDF_VERSION == ESP_IDF_VERSION_VAL(5, 3, 1)); - esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TWODOTFOUR_TOUCH_I2C_PORT, &touch_io_config, &ioHandle); - /* if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TWODOTFOUR_TOUCH_I2C_PORT, &touch_io_config, &ioHandle) != ESP_OK) { TT_LOG_E(TAG, "Touch I2C IO init failed"); return false; } - */ esp_lcd_touch_config_t config = { .x_max = 240, @@ -48,6 +40,7 @@ bool YellowTouch::start(lv_display_t* display) { if (esp_lcd_touch_new_i2c_cst816s(ioHandle, &config, &touchHandle) != ESP_OK) { TT_LOG_E(TAG, "Driver init failed"); + cleanup(); return false; } @@ -59,6 +52,7 @@ bool YellowTouch::start(lv_display_t* display) { deviceHandle = lvgl_port_add_touch(&touch_cfg); if (deviceHandle == nullptr) { TT_LOG_E(TAG, "Adding touch failed"); + cleanup(); return false; } @@ -67,8 +61,23 @@ bool YellowTouch::start(lv_display_t* display) { } bool YellowTouch::stop() { - tt_assert(deviceHandle != nullptr); - lv_indev_delete(deviceHandle); - deviceHandle = nullptr; + cleanup(); return true; } + +void YellowTouch::cleanup() { + if (deviceHandle != nullptr) { + lv_indev_delete(deviceHandle); + deviceHandle = nullptr; + } + + if (touchHandle != nullptr) { + esp_lcd_touch_del(touchHandle); + touchHandle = nullptr; + } + + if (ioHandle != nullptr) { + esp_lcd_panel_io_del(ioHandle); + ioHandle = nullptr; + } +} diff --git a/Boards/YellowBoard/Source/hal/YellowTouch.h b/Boards/YellowBoard/Source/hal/YellowTouch.h index 9323caf5..55e8ab7f 100644 --- a/Boards/YellowBoard/Source/hal/YellowTouch.h +++ b/Boards/YellowBoard/Source/hal/YellowTouch.h @@ -2,10 +2,14 @@ #include "hal/Touch.h" #include "TactilityCore.h" +#include class YellowTouch : public tt::hal::Touch { private: + esp_lcd_panel_io_handle_t ioHandle = nullptr; + esp_lcd_touch_handle_t touchHandle = nullptr; lv_indev_t* _Nullable deviceHandle = nullptr; + void cleanup(); public: bool start(lv_display_t* display) override; bool stop() override;