Fixes and cleanup (#266)

- Fix issue with GT911 driver: fixed a crash and an init issue
- Cleanup of unused code
This commit is contained in:
Ken Van Hoeylandt 2025-03-31 15:59:50 +02:00 committed by GitHub
parent 3f1bfee3f5
commit eb4e9f9649
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 24 additions and 68 deletions

View File

@ -4,7 +4,7 @@ dependencies:
espressif/esp_lcd_touch: "1.1.2" espressif/esp_lcd_touch: "1.1.2"
atanisoft/esp_lcd_touch_xpt2046: "1.0.5" atanisoft/esp_lcd_touch_xpt2046: "1.0.5"
espressif/esp_lcd_touch_cst816s: "1.0.3" espressif/esp_lcd_touch_cst816s: "1.0.3"
espressif/esp_lcd_touch_gt911: "1.1.1~2" espressif/esp_lcd_touch_gt911: "1.1.3"
espressif/esp_lcd_touch_ft5x06: "1.0.6~1" espressif/esp_lcd_touch_ft5x06: "1.0.6~1"
espressif/esp_io_expander: "1.0.1" espressif/esp_io_expander: "1.0.1"
espressif/esp_io_expander_tca95xx_16bit: "1.0.1" espressif/esp_io_expander_tca95xx_16bit: "1.0.1"

View File

@ -1,6 +1,7 @@
#include "Gt911Touch.h" #include "Gt911Touch.h"
#include <Tactility/Log.h> #include <Tactility/Log.h>
#include <Tactility/hal/i2c/I2c.h>
#include <esp_lcd_touch_gt911.h> #include <esp_lcd_touch_gt911.h>
#include <esp_err.h> #include <esp_err.h>
@ -9,7 +10,21 @@
#define TAG "GT911" #define TAG "GT911"
bool Gt911Touch::start(lv_display_t* display) { bool Gt911Touch::start(lv_display_t* display) {
const esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
/**
* When the interrupt pin is low, the address is 0x5D. Otherwise it is 0x14.
* There is not reset pin, and the current driver fails when you only specify the interrupt pin.
* Because of that, we don't use the interrupt pin and we'll simply scan the bus instead:
*/
if (tt::hal::i2c::masterHasDeviceAtAddress(configuration->port, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS)) {
io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS;
} else if (tt::hal::i2c::masterHasDeviceAtAddress(configuration->port, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP)) {
io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP;
} else {
TT_LOG_E(TAG, "No device found on I2C bus");
return false;
}
if (esp_lcd_new_panel_io_i2c(configuration->port, &io_config, &ioHandle) != ESP_OK) { if (esp_lcd_new_panel_io_i2c(configuration->port, &io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Touch IO I2C creation failed"); TT_LOG_E(TAG, "Touch IO I2C creation failed");
@ -67,10 +82,6 @@ void Gt911Touch::cleanup() {
if (deviceHandle != nullptr) { if (deviceHandle != nullptr) {
lv_indev_delete(deviceHandle); lv_indev_delete(deviceHandle);
deviceHandle = nullptr; deviceHandle = nullptr;
}
if (touchHandle != nullptr) {
esp_lcd_touch_del(touchHandle);
touchHandle = nullptr; touchHandle = nullptr;
} }

View File

@ -1,55 +0,0 @@
#pragma once
#include "Tactility/app/AppInstance.h"
#include "Tactility/app/AppManifest.h"
#include "Tactility/service/loader/Loader.h"
#include <Tactility/DispatcherThread.h>
#include <Tactility/EventFlag.h>
#include <Tactility/MessageQueue.h>
#include <Tactility/PubSub.h>
#include <Tactility/RtosCompatSemaphore.h>
#include <Tactility/Thread.h>
#include <stack>
#include <utility>
namespace tt::service::loader {
// region LoaderMessage
class LoaderMessageAppStart {
public:
std::string id;
std::shared_ptr<const Bundle> _Nullable parameters;
LoaderMessageAppStart() = default;
LoaderMessageAppStart(LoaderMessageAppStart& other) = default;
LoaderMessageAppStart(const std::string& id, std::shared_ptr<const Bundle> parameters) :
id(id),
parameters(std::move(parameters))
{}
~LoaderMessageAppStart() = default;
};
class LoaderMessageAppStop {
public:
std::string id;
LoaderMessageAppStop() = default;
LoaderMessageAppStop(LoaderMessageAppStop& other) = default;
LoaderMessageAppStop(const std::string& id) : id(id) {}
~LoaderMessageAppStop() = default;
};
// endregion LoaderMessage
struct Loader {
};
} // namespace

View File

@ -2,7 +2,7 @@
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "Tactility/lvgl/Statusbar.h" #include "Tactility/lvgl/Statusbar.h"
#include "Tactility/lvgl/Style.h" #include "Tactility/lvgl/Style.h"
#include "Tactility/service/loader/Loader_i.h" #include "Tactility/service/loader/Loader.h"
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <Tactility/RtosCompat.h> #include <Tactility/RtosCompat.h>

View File

@ -1,10 +1,14 @@
#include "Tactility/service/loader/Loader.h"
#include "Tactility/app/AppInstance.h"
#include "Tactility/app/AppManifest.h" #include "Tactility/app/AppManifest.h"
#include "Tactility/app/ManifestRegistry.h" #include "Tactility/app/ManifestRegistry.h"
#include "Tactility/service/loader/Loader_i.h"
#include <Tactility/RtosCompat.h>
#include <Tactility/DispatcherThread.h>
#include <Tactility/service/ServiceManifest.h> #include <Tactility/service/ServiceManifest.h>
#include <Tactility/service/ServiceRegistry.h> #include <Tactility/service/ServiceRegistry.h>
#include <Tactility/RtosCompat.h>
#include <stack>
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/TactilityHeadless.h> #include <Tactility/TactilityHeadless.h>
@ -252,7 +256,6 @@ void LoaderService::transitionAppToState(const std::shared_ptr<app::AppInstance>
} }
void LoaderService::startApp(const std::string& id, std::shared_ptr<const Bundle> parameters) { void LoaderService::startApp(const std::string& id, std::shared_ptr<const Bundle> parameters) {
auto message = std::make_shared<LoaderMessageAppStart>(id, std::move(parameters));
dispatcherThread->dispatch([this, id, parameters]() { dispatcherThread->dispatch([this, id, parameters]() {
onStartAppMessage(id, parameters); onStartAppMessage(id, parameters);
}); });

View File

@ -844,7 +844,6 @@ static void dispatchDisconnectButKeepActive(std::shared_ptr<Wifi> wifi) {
static bool shouldScanForAutoConnect(std::shared_ptr<Wifi> wifi) { static bool shouldScanForAutoConnect(std::shared_ptr<Wifi> wifi) {
auto lock = wifi->dataMutex.asScopedLock(); auto lock = wifi->dataMutex.asScopedLock();
if (!lock.lock(100)) { if (!lock.lock(100)) {
TT_LOG_W(TAG, "Auto-connect can't lock");
return false; return false;
} }
@ -853,7 +852,6 @@ static bool shouldScanForAutoConnect(std::shared_ptr<Wifi> wifi) {
!wifi->pause_auto_connect; !wifi->pause_auto_connect;
if (!is_radio_in_scannable_state) { if (!is_radio_in_scannable_state) {
TT_LOG_W(TAG, "Auto-connect: radio state not ok (%d, %d, %d)", (int)wifi->getRadioState(), wifi->isScanActive(), wifi->pause_auto_connect);
return false; return false;
} }
@ -862,7 +860,6 @@ static bool shouldScanForAutoConnect(std::shared_ptr<Wifi> wifi) {
bool no_recent_scan = (current_time - wifi->last_scan_time) > (AUTO_SCAN_INTERVAL / portTICK_PERIOD_MS); bool no_recent_scan = (current_time - wifi->last_scan_time) > (AUTO_SCAN_INTERVAL / portTICK_PERIOD_MS);
if (!scan_time_has_looped && !no_recent_scan) { if (!scan_time_has_looped && !no_recent_scan) {
TT_LOG_W(TAG, "Auto-connect: scan time looped = %d, no recent scan = %d", scan_time_has_looped, no_recent_scan);
} }
return scan_time_has_looped || no_recent_scan; return scan_time_has_looped || no_recent_scan;