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:
committed by
GitHub
parent
3f1bfee3f5
commit
eb4e9f9649
@@ -1,6 +1,7 @@
|
||||
#include "Gt911Touch.h"
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/hal/i2c/I2c.h>
|
||||
|
||||
#include <esp_lcd_touch_gt911.h>
|
||||
#include <esp_err.h>
|
||||
@@ -9,7 +10,21 @@
|
||||
#define TAG "GT911"
|
||||
|
||||
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) {
|
||||
TT_LOG_E(TAG, "Touch IO I2C creation failed");
|
||||
@@ -67,10 +82,6 @@ void Gt911Touch::cleanup() {
|
||||
if (deviceHandle != nullptr) {
|
||||
lv_indev_delete(deviceHandle);
|
||||
deviceHandle = nullptr;
|
||||
}
|
||||
|
||||
if (touchHandle != nullptr) {
|
||||
esp_lcd_touch_del(touchHandle);
|
||||
touchHandle = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user