Grove driver, I2C migrations, bugfixes and docs (#532)

This commit is contained in:
Ken Van Hoeylandt
2026-06-19 00:52:31 +02:00
committed by GitHub
parent 8dabda2b5b
commit a35c88c8fd
74 changed files with 937 additions and 483 deletions
+21 -9
View File
@@ -1,31 +1,43 @@
#include "Gt911Touch.h"
#include <Tactility/Logger.h>
#include <Tactility/hal/i2c/I2c.h>
#include <esp_lcd_io_i2c.h>
#include <esp_lcd_touch_gt911.h>
#include <esp_err.h>
#include <tactility/device.h>
#include <tactility/driver.h>
#include <tactility/drivers/esp32_i2c.h>
#include <tactility/drivers/esp32_i2c_master.h>
#include <tactility/drivers/i2c_controller.h>
static const auto LOGGER = tt::Logger("GT911");
bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
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)) {
auto* i2c = configuration->i2cController;
if (i2c_controller_has_device_at_address(i2c, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS, pdMS_TO_TICKS(10)) == ERROR_NONE) {
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)) {
} else if (i2c_controller_has_device_at_address(i2c, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP, pdMS_TO_TICKS(10)) == ERROR_NONE) {
io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP;
} else {
LOGGER.error("No device found on I2C bus");
return false;
}
return esp_lcd_new_panel_io_i2c(configuration->port, &io_config, &outHandle) == ESP_OK;
auto* driver = device_get_driver(i2c);
if (driver_is_compatible(driver, "espressif,esp32-i2c")) {
auto port = static_cast<const Esp32I2cConfig*>(i2c->config)->port;
return esp_lcd_new_panel_io_i2c_v1(port, &io_config, &outHandle) == ESP_OK;
} else if (driver_is_compatible(driver, "espressif,esp32-i2c-master")) {
auto bus = esp32_i2c_master_get_bus_handle(i2c);
return esp_lcd_new_panel_io_i2c_v2(bus, &io_config, &outHandle) == ESP_OK;
}
LOGGER.error("Unsupported I2C driver");
return false;
}
bool Gt911Touch::createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& configuration, esp_lcd_touch_handle_t& panelHandle) {