From 49f55189d8a4f55d0c56226fc78fe922bea20fef Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Mon, 25 Sep 2023 07:59:40 -0500 Subject: [PATCH 1/4] feat(t-deck): WIP t-deck support * Added gt911 component for t-deck touchscreen (does not seem to work yet) * Updated config and code to work for t-deck screen --- CMakeLists.txt | 2 +- components/gt911/CMakeLists.txt | 4 + components/gt911/include/gt911.hpp | 257 +++++++++++++++++++++++++++++ main/Kconfig.projbuild | 2 + main/main.cpp | 110 ++++++++++-- 5 files changed, 364 insertions(+), 11 deletions(-) create mode 100644 components/gt911/CMakeLists.txt create mode 100644 components/gt911/include/gt911.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 33bc29a..19d9168 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(EXTRA_COMPONENT_DIRS set( COMPONENTS - "main esptool_py driver lwip button display display_drivers input_drivers logger lvgl mdns socket task tt21100 wifi gui" + "main esptool_py driver lwip button display display_drivers input_drivers logger lvgl mdns socket task tt21100 gt911 wifi gui" CACHE STRING "List of components to include" ) diff --git a/components/gt911/CMakeLists.txt b/components/gt911/CMakeLists.txt new file mode 100644 index 0000000..17999ce --- /dev/null +++ b/components/gt911/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register( + INCLUDE_DIRS "include" + REQUIRES "logger" + ) diff --git a/components/gt911/include/gt911.hpp b/components/gt911/include/gt911.hpp new file mode 100644 index 0000000..bd34108 --- /dev/null +++ b/components/gt911/include/gt911.hpp @@ -0,0 +1,257 @@ +#pragma once + +#include + +#include "logger.hpp" + +class Gt911 { +public: + static constexpr uint8_t DEFAULT_ADDRESS_1 = 0x5D; + static constexpr uint8_t DEFAULT_ADDRESS_2 = 0x14; + + typedef std::function read_fn; + typedef std::function write_fn; + + struct Config { + read_fn read; + write_fn write; + uint8_t address = DEFAULT_ADDRESS_1; /**< Which address to use for this chip? */ + espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN}; /**< Log verbosity for the input driver. */ + }; + + Gt911(const Config& config) + : read_(config.read), + write_(config.write), + address_(config.address), + logger_({.tag = "Gt911", .level = config.log_level}) { + init(); + } + + bool read() { + static constexpr size_t DATA_LEN = CONTACT_SIZE * MAX_CONTACTS; + static uint8_t data[DATA_LEN]; + read(Registers::POINT_INFO, data, DATA_LEN); + num_touch_points_ = data[0] & 0x0f; + if (num_touch_points_ > 0) { + logger_.debug("Got {} touch points", num_touch_points_); + // convert the data pointer to a GTPoint* + GTPoint* point = (GTPoint*)&data[1]; + x_ = point->x; + y_ = point->y; + logger_.debug("Touch at ({}, {})", x_, y_); + } + write(Registers::POINT_INFO, 0x00); // sync signal + + return num_touch_points_ > 0; + } + + uint8_t get_num_touch_points() { + return num_touch_points_; + } + + void get_touch_point(uint8_t *num_touch_points, uint16_t *x, uint16_t *y) { + *num_touch_points = get_num_touch_points(); + if (*num_touch_points != 0) { + *x = x_; + *y = y_; + logger_.info("Got touch ({}, {})", *x, *y); + } + } + + uint8_t get_home_button_state() { + return home_button_pressed_; + } + +protected: + void init() { + using namespace std::chrono_literals; + /* + */ + // write 0x02 (software reset) to GT911 COMMAND register + write(Registers::COMMAND, 0x02); + // delay 200 ms + std::this_thread::sleep_for(200ms); + // val = read SWITCH_1 + uint8_t val = read(Registers::SWITCH_1); + val &= 0xFC; + val |= 0x03; + // write back val to switch 1 + write(Registers::SWITCH_1, val); + // delay 200 ms + std::this_thread::sleep_for(200ms); + } + + static constexpr int CONTACT_SIZE = 8; + static constexpr int MAX_CONTACTS = 5; + static constexpr int CONFIG_MAX_LEN = 240; + static constexpr int CONFIG_911_LEN = 186; + static constexpr int CONFIG_967_LEN = 228; + + enum class Registers : uint16_t { + COMMAND = 0x8040, + CONFIG = 0x8047, + SWITCH_1 = 0x804D, + SWITCH_2 = 0x804E, + REFRESH_RATE = 0x8056, + DATA = 0x8140, + POINT_INFO = 0x814E, + POINTS = 0x814F, + POINT_1 = 0x814F, + POINT_2 = 0x8157, + POINT_3 = 0x815F, + POINT_4 = 0x8167, + POINT_5 = 0x816F, + }; + + // From Goodix library + struct GTInfo { + // 0x8140-0x814A + char productId[4]; + uint16_t fwId; + uint16_t xResolution; + uint16_t yResolution; + uint8_t vendorId; + } __attribute__((packed)); + + struct GTPoint { + // 0x814F-0x8156, ... 0x8176 (5 points) + uint8_t trackId; + uint16_t x; + uint16_t y; + uint16_t area; + uint8_t reserved; + } __attribute__((packed)); + + struct GTLevelConfig { + uint8_t touch; // Threshold of touch grow out of nothing + uint8_t leave; // Threshold of touch decrease to nothing + } __attribute__((packed)); + + struct GTStylusConfig { + uint8_t txGain; + uint8_t rxGain; + uint8_t dumpShift; + GTLevelConfig level; + uint8_t control; //Pen mode escape time out period (Unit: Sec) + } __attribute__((packed)); + + struct GTFreqHoppingConfig { + uint16_t hoppingBitFreq; + uint8_t hoppingFactor; + } __attribute__((packed)); + + struct GTKeyConfig { + // Key position: 0-255 valid + // 0 means no touch, it means independent touch key when 4 of the keys are 8 multiples + uint8_t pos1; + uint8_t pos2; + uint8_t pos3; + uint8_t pos4; + uint8_t area; + GTLevelConfig level; + uint8_t sens12; + uint8_t sens34; + uint8_t restrain; + } __attribute__((packed)); + + struct GTConfig { + // start at 0x8047 + uint8_t configVersion; + uint16_t xResolution; + uint16_t yResolution; + // 0x804C + uint8_t touchNumber; // 3:0 Touch No.: 1~10 + + // 7:6 Reserved, 5:4 Stretch rank, 3 X2Y, 2 Sito + // 1:0 INT trig method: 00-rising, 01-falling, 02-low level, 03-high level enquiry + uint8_t moduleSwitch1; + uint8_t moduleSwitch2; // bit0 TouchKey + uint8_t shakeCount; // 3:0 Finger shake count + // 0x8050 + // 7:6 First filter, 5:0 Normal filter (filtering value of original coordinate window, coefficiency is 1) + uint8_t filter; + uint8_t largeTouch; + uint8_t noiseReduction; + GTLevelConfig screenLevel; + + uint8_t lowPowerControl; // Time to low power consumption (0~15s) + uint8_t refreshRate; // Coordinate report rate (Cycle: 5+N ms) + uint8_t xThreshold; //res + uint8_t yThreshold; //res + uint8_t xSpeedLimit; //res + uint8_t ySpeedLimit; //res + uint8_t vSpace; // 4bit top/bottom (coefficient 32) + uint8_t hSpace; // 4bit left/right + //0x805D-0x8061 + uint8_t stretchRate; //Level of weak stretch (Strtch X/16 Pitch) + uint8_t stretchR0; // Interval 1 coefficient + uint8_t stretchR1; // Interval 2 coefficient + uint8_t stretchR2; // Interval 3 coefficient + uint8_t stretchRM; // All intervals base number + + uint8_t drvGroupANum; + uint8_t drvGroupBNum; + uint8_t sensorNum; + uint8_t freqAFactor; + uint8_t freqBFactor; + // 0x8067 + uint16_t pannelBitFreq; //Baseband of Driver group A\B (1526HZ> 8; + d[1] = reg_addr & 0xFF; + memcpy(&d[2], data, len); + write_(address_, d, d_len); + } + + uint8_t read(Registers reg) { + uint8_t val = 0x00; + read(reg, &val, 1); + return val; + } + + void read(Registers reg, uint8_t* data, size_t len) { + uint16_t reg_addr = (uint16_t)reg; + read_(address_, reg_addr, data, len); + } + + read_fn read_; + write_fn write_; + uint8_t address_; + std::atomic home_button_pressed_{false}; + std::atomic num_touch_points_; + std::atomic x_; + std::atomic y_; + espp::Logger logger_; +}; diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 5fb266e..8be4e1c 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -9,6 +9,8 @@ menu "Wireless Debug Display Configuration" bool "ESP32 WROVER KIT V4" config HARDWARE_BOX bool "ESP BOX" + config HARDWARE_TDECK + bool "LILYGO T DECK" endchoice config DEBUG_SERVER_PORT diff --git a/main/main.cpp b/main/main.cpp index 31e07c4..c0bcbf5 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -22,6 +22,12 @@ static constexpr int DC_PIN_NUM = 21; #include "touchpad_input.hpp" #include "tt21100.hpp" static constexpr int DC_PIN_NUM = 4; +#elif CONFIG_HARDWARE_TDECK +#include +#include "st7789.hpp" +#include "touchpad_input.hpp" +#include "gt911.hpp" +static constexpr int DC_PIN_NUM = 11; #else #error "Misconfigured hardware!" #endif @@ -122,7 +128,7 @@ void IRAM_ATTR lcd_send_lines(int xs, int ys, int xe, int ye, const uint8_t *dat #if CONFIG_HARDWARE_WROVER_KIT trans[0].tx_data[0] = (uint8_t)espp::Ili9341::Command::caset; #endif -#if CONFIG_HARDWARE_BOX +#if CONFIG_HARDWARE_BOX || CONFIG_HARDWARE_TDECK trans[0].tx_data[0] = (uint8_t)espp::St7789::Command::caset; #endif trans[1].tx_data[0] = (xs) >> 8; @@ -132,7 +138,7 @@ void IRAM_ATTR lcd_send_lines(int xs, int ys, int xe, int ye, const uint8_t *dat #if CONFIG_HARDWARE_WROVER_KIT trans[2].tx_data[0] = (uint8_t)espp::Ili9341::Command::raset; #endif -#if CONFIG_HARDWARE_BOX +#if CONFIG_HARDWARE_BOX || CONFIG_HARDWARE_TDECK trans[2].tx_data[0] = (uint8_t)espp::St7789::Command::raset; #endif trans[3].tx_data[0] = (ys) >> 8; @@ -142,7 +148,7 @@ void IRAM_ATTR lcd_send_lines(int xs, int ys, int xe, int ye, const uint8_t *dat #if CONFIG_HARDWARE_WROVER_KIT trans[4].tx_data[0] = (uint8_t)espp::Ili9341::Command::ramwr; #endif -#if CONFIG_HARDWARE_BOX +#if CONFIG_HARDWARE_BOX || CONFIG_HARDWARE_TDECK trans[4].tx_data[0] = (uint8_t)espp::St7789::Command::ramwr; #endif trans[5].tx_buffer = data; @@ -175,7 +181,7 @@ extern "C" void app_main(void) { return std::chrono::duration(now - start).count(); }; - espp::Logger logger({.tag = "WirelessDebugDisplay", .level = espp::Logger::Verbosity::DEBUG}); + espp::Logger logger({.tag = "WirelessDebugDisplay", .level = espp::Logger::Verbosity::INFO}); logger.info("Bootup"); @@ -210,6 +216,8 @@ extern "C" void app_main(void) { #endif #if CONFIG_HARDWARE_BOX static constexpr std::string_view dev_kit = "ESP32-S3-BOX"; + gpio_num_t i2c_sda = GPIO_NUM_8; + gpio_num_t i2c_scl = GPIO_NUM_18; int clock_speed = 60 * 1000 * 1000; auto spi_num = SPI2_HOST; gpio_num_t mosi = GPIO_NUM_6; @@ -221,10 +229,49 @@ extern "C" void app_main(void) { size_t width = 320; size_t height = 240; size_t pixel_buffer_size = width * 50; + bool backlight_value = true; bool invert_colors = true; auto flush_cb = espp::St7789::flush; auto rotation = espp::Display::Rotation::LANDSCAPE; #endif +#if CONFIG_HARDWARE_TDECK + static constexpr std::string_view dev_kit = "LILYGO T-DECK"; + gpio_num_t i2c_sda = GPIO_NUM_18; + gpio_num_t i2c_scl = GPIO_NUM_8; + int clock_speed = 40 * 1000 * 1000; + auto spi_num = SPI2_HOST; + gpio_num_t mosi = GPIO_NUM_41; + gpio_num_t sclk = GPIO_NUM_40; + gpio_num_t spics = GPIO_NUM_12; + gpio_num_t reset = GPIO_NUM_NC; // not connected according to Setup210_LilyGo_T_Deck.h + gpio_num_t dc_pin = (gpio_num_t)DC_PIN_NUM; + gpio_num_t backlight = GPIO_NUM_42; + size_t width = 320; + size_t height = 240; + size_t pixel_buffer_size = width * 50; + bool backlight_value = true; + bool invert_colors = false; + auto flush_cb = espp::St7789::flush; + auto rotation = espp::Display::Rotation::LANDSCAPE_INVERTED; + + // peripheral power on t-deck requires the power pin to be set (gpio 10) + // so set up gpio output and set it high + gpio_num_t BOARD_POWER_ON_PIN = GPIO_NUM_10; + gpio_set_direction(BOARD_POWER_ON_PIN, GPIO_MODE_OUTPUT); + gpio_set_level(BOARD_POWER_ON_PIN, 1); + + gpio_num_t TOUCH_INTERRUPT_PIN = GPIO_NUM_16; + // wake up the touch chip + gpio_set_direction(TOUCH_INTERRUPT_PIN, GPIO_MODE_OUTPUT); + gpio_set_level(TOUCH_INTERRUPT_PIN, 1); + std::this_thread::sleep_for(20ms); + // now set the interrupt as input + gpio_set_direction(TOUCH_INTERRUPT_PIN, GPIO_MODE_INPUT); + std::this_thread::sleep_for(20ms); + + gpio_num_t KEYBOARD_INTERRUPT_PIN = GPIO_NUM_46; + gpio_set_direction(KEYBOARD_INTERRUPT_PIN, GPIO_MODE_INPUT); +#endif logger.info("Initializing display drivers for {}", dev_kit); // create the spi host @@ -262,7 +309,7 @@ extern "C" void app_main(void) { .backlight_pin = backlight, .invert_colors = invert_colors}); #endif -#if CONFIG_HARDWARE_BOX +#if CONFIG_HARDWARE_BOX || CONFIG_HARDWARE_TDECK // initialize the controller espp::St7789::initialize(espp::display_drivers::Config{ .lcd_write = lcd_write, @@ -270,8 +317,8 @@ extern "C" void app_main(void) { .reset_pin = reset, .data_command_pin = dc_pin, .backlight_pin = backlight, - .backlight_on_value = invert_colors, - .invert_colors = true, + .backlight_on_value = backlight_value, + .invert_colors = invert_colors, .mirror_x = true, .mirror_y = true, }); @@ -306,7 +353,7 @@ extern "C" void app_main(void) { .log_level = espp::Logger::Verbosity::WARN, }); #endif -#if CONFIG_HARDWARE_BOX +#if CONFIG_HARDWARE_BOX || CONFIG_HARDWARE_TDECK // initialize the i2c bus to read the touchpad driver (tt21100) static constexpr auto I2C_PORT = I2C_NUM_0; static constexpr int I2C_FREQ_HZ = (400*1000); @@ -314,8 +361,8 @@ extern "C" void app_main(void) { logger.info("initializing i2c driver..."); i2c_config_t i2c_cfg; memset(&i2c_cfg, 0, sizeof(i2c_cfg)); - i2c_cfg.sda_io_num = GPIO_NUM_8; - i2c_cfg.scl_io_num = GPIO_NUM_18; + i2c_cfg.sda_io_num = i2c_sda; + i2c_cfg.scl_io_num = i2c_scl; i2c_cfg.mode = I2C_MODE_MASTER; i2c_cfg.sda_pullup_en = GPIO_PULLUP_ENABLE; i2c_cfg.scl_pullup_en = GPIO_PULLUP_ENABLE; @@ -325,6 +372,7 @@ extern "C" void app_main(void) { i2c_err = i2c_driver_install(I2C_PORT, I2C_MODE_MASTER, 0, 0, 0); // buff len (x2), default flags if (i2c_err != ESP_OK) logger.error("install i2c driver failed"); +#if CONFIG_HARDWARE_BOX auto i2c_read = [&](uint8_t dev_addr, uint8_t *data, size_t len) { i2c_master_read_from_device(I2C_PORT, dev_addr, data, len, I2C_TIMEOUT_MS / portTICK_PERIOD_MS); }; @@ -341,6 +389,48 @@ extern "C" void app_main(void) { tt21100.get_touch_point(num_touch_points, x, y); *btn_state = tt21100.get_home_button_state(); }; +#endif +#if CONFIG_HARDWARE_TDECK + auto i2c_read = [&](uint8_t dev_addr, uint16_t reg_addr, uint8_t *data, size_t len) { + auto err = i2c_master_write_read_device(I2C_PORT, + dev_addr, + (uint8_t*)®_addr, 2, + data, len, + I2C_TIMEOUT_MS / portTICK_PERIOD_MS); + if (err != ESP_OK) { + logger.error("Could not write read device: {:#02x} at register: {:#02x}, error: {}", + dev_addr, reg_addr, esp_err_to_name(err)); + } + }; + auto i2c_write = [&](uint8_t dev_addr, uint8_t *data, size_t len) { + auto err = i2c_master_write_to_device(I2C_PORT, dev_addr, data, len, I2C_TIMEOUT_MS / portTICK_PERIOD_MS); + if (err != ESP_OK) { + logger.error("Could not write to device: {:#02x} error: {}", + dev_addr, esp_err_to_name(err)); + } + }; + logger.info("Initializing GT911"); + // implement GT911 + auto gt911 = Gt911(Gt911::Config{ + .read = i2c_read, + .write = i2c_write, + .address = Gt911::DEFAULT_ADDRESS_1, + .log_level = espp::Logger::Verbosity::DEBUG + }); + + auto touchpad_read = [&](uint8_t* num_touch_points, uint16_t* x, uint16_t* y, uint8_t* btn_state) { + *num_touch_points = 0; + // get the latest data from the device + if (gpio_get_level(TOUCH_INTERRUPT_PIN)) { + logger.debug("touchpad interrupt"); + if (gt911.read()) { + gt911.get_touch_point(num_touch_points, x, y); + } + } + // now hand it off + *btn_state = false; // no touchscreen button on t-deck + }; +#endif logger.info("Initializing touchpad"); auto touchpad = espp::TouchpadInput(espp::TouchpadInput::Config{ From f2f3302dd3bf9027944608c875c4b237e1623432 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Mon, 25 Sep 2023 08:07:49 -0500 Subject: [PATCH 2/4] submodule(espp): update --- components/espp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/espp b/components/espp index c9b6fc7..bdf81e7 160000 --- a/components/espp +++ b/components/espp @@ -1 +1 @@ -Subproject commit c9b6fc750dfad132d08765e57752ca59988f23f7 +Subproject commit bdf81e745a95f3bb8330ec3352ccf6a1bd9b5732 From 6db2f2f819cfc36af856c83a60c23a5cf097746f Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Tue, 26 Sep 2023 08:49:44 -0500 Subject: [PATCH 3/4] fix(gt911): working gt911 driver --- components/gt911/include/gt911.hpp | 5 +++-- main/main.cpp | 28 +++++++++++----------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/components/gt911/include/gt911.hpp b/components/gt911/include/gt911.hpp index bd34108..4e843fa 100644 --- a/components/gt911/include/gt911.hpp +++ b/components/gt911/include/gt911.hpp @@ -30,12 +30,13 @@ class Gt911 { bool read() { static constexpr size_t DATA_LEN = CONTACT_SIZE * MAX_CONTACTS; static uint8_t data[DATA_LEN]; - read(Registers::POINT_INFO, data, DATA_LEN); + read(Registers::POINT_INFO, data, 1); num_touch_points_ = data[0] & 0x0f; if (num_touch_points_ > 0) { logger_.debug("Got {} touch points", num_touch_points_); + read(Registers::POINTS, data, CONTACT_SIZE * num_touch_points_); // convert the data pointer to a GTPoint* - GTPoint* point = (GTPoint*)&data[1]; + GTPoint* point = (GTPoint*)&data[0]; x_ = point->x; y_ = point->y; logger_.debug("Touch at ({}, {})", x_, y_); diff --git a/main/main.cpp b/main/main.cpp index c0bcbf5..e79d8fe 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -218,6 +218,7 @@ extern "C" void app_main(void) { static constexpr std::string_view dev_kit = "ESP32-S3-BOX"; gpio_num_t i2c_sda = GPIO_NUM_8; gpio_num_t i2c_scl = GPIO_NUM_18; + bool touch_swap_xy = false; int clock_speed = 60 * 1000 * 1000; auto spi_num = SPI2_HOST; gpio_num_t mosi = GPIO_NUM_6; @@ -238,6 +239,7 @@ extern "C" void app_main(void) { static constexpr std::string_view dev_kit = "LILYGO T-DECK"; gpio_num_t i2c_sda = GPIO_NUM_18; gpio_num_t i2c_scl = GPIO_NUM_8; + bool touch_swap_xy = true; int clock_speed = 40 * 1000 * 1000; auto spi_num = SPI2_HOST; gpio_num_t mosi = GPIO_NUM_41; @@ -260,15 +262,6 @@ extern "C" void app_main(void) { gpio_set_direction(BOARD_POWER_ON_PIN, GPIO_MODE_OUTPUT); gpio_set_level(BOARD_POWER_ON_PIN, 1); - gpio_num_t TOUCH_INTERRUPT_PIN = GPIO_NUM_16; - // wake up the touch chip - gpio_set_direction(TOUCH_INTERRUPT_PIN, GPIO_MODE_OUTPUT); - gpio_set_level(TOUCH_INTERRUPT_PIN, 1); - std::this_thread::sleep_for(20ms); - // now set the interrupt as input - gpio_set_direction(TOUCH_INTERRUPT_PIN, GPIO_MODE_INPUT); - std::this_thread::sleep_for(20ms); - gpio_num_t KEYBOARD_INTERRUPT_PIN = GPIO_NUM_46; gpio_set_direction(KEYBOARD_INTERRUPT_PIN, GPIO_MODE_INPUT); #endif @@ -392,9 +385,13 @@ extern "C" void app_main(void) { #endif #if CONFIG_HARDWARE_TDECK auto i2c_read = [&](uint8_t dev_addr, uint16_t reg_addr, uint8_t *data, size_t len) { + uint8_t reg_addr_data[] = { + (uint8_t)(reg_addr >> 8), + (uint8_t)(reg_addr & 0xff) + }; auto err = i2c_master_write_read_device(I2C_PORT, dev_addr, - (uint8_t*)®_addr, 2, + reg_addr_data, 2, data, len, I2C_TIMEOUT_MS / portTICK_PERIOD_MS); if (err != ESP_OK) { @@ -415,17 +412,14 @@ extern "C" void app_main(void) { .read = i2c_read, .write = i2c_write, .address = Gt911::DEFAULT_ADDRESS_1, - .log_level = espp::Logger::Verbosity::DEBUG + .log_level = espp::Logger::Verbosity::WARN }); auto touchpad_read = [&](uint8_t* num_touch_points, uint16_t* x, uint16_t* y, uint8_t* btn_state) { *num_touch_points = 0; // get the latest data from the device - if (gpio_get_level(TOUCH_INTERRUPT_PIN)) { - logger.debug("touchpad interrupt"); - if (gt911.read()) { - gt911.get_touch_point(num_touch_points, x, y); - } + if (gt911.read()) { + gt911.get_touch_point(num_touch_points, x, y); } // now hand it off *btn_state = false; // no touchscreen button on t-deck @@ -435,7 +429,7 @@ extern "C" void app_main(void) { logger.info("Initializing touchpad"); auto touchpad = espp::TouchpadInput(espp::TouchpadInput::Config{ .touchpad_read = touchpad_read, - .swap_xy = false, + .swap_xy = touch_swap_xy, .invert_x = true, .invert_y = false, .log_level = espp::Logger::Verbosity::WARN From c7f3fd2e35c37a9f4c258d56fc0fb13f643e0ebb Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Tue, 26 Sep 2023 08:52:30 -0500 Subject: [PATCH 4/4] cleanup(gt911): comment out unneeded code --- components/gt911/include/gt911.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/gt911/include/gt911.hpp b/components/gt911/include/gt911.hpp index 4e843fa..eedf898 100644 --- a/components/gt911/include/gt911.hpp +++ b/components/gt911/include/gt911.hpp @@ -65,9 +65,8 @@ class Gt911 { protected: void init() { + /* NOTE: this doesn't seem to be needed using namespace std::chrono_literals; - /* - */ // write 0x02 (software reset) to GT911 COMMAND register write(Registers::COMMAND, 0x02); // delay 200 ms @@ -80,6 +79,7 @@ class Gt911 { write(Registers::SWITCH_1, val); // delay 200 ms std::this_thread::sleep_for(200ms); + */ } static constexpr int CONTACT_SIZE = 8;