@@ -218,6 +218,7 @@ extern "C" void app_main(void) {
218218 static constexpr std::string_view dev_kit = " ESP32-S3-BOX" ;
219219 gpio_num_t i2c_sda = GPIO_NUM_8;
220220 gpio_num_t i2c_scl = GPIO_NUM_18;
221+ bool touch_swap_xy = false ;
221222 int clock_speed = 60 * 1000 * 1000 ;
222223 auto spi_num = SPI2_HOST;
223224 gpio_num_t mosi = GPIO_NUM_6;
@@ -238,6 +239,7 @@ extern "C" void app_main(void) {
238239 static constexpr std::string_view dev_kit = " LILYGO T-DECK" ;
239240 gpio_num_t i2c_sda = GPIO_NUM_18;
240241 gpio_num_t i2c_scl = GPIO_NUM_8;
242+ bool touch_swap_xy = true ;
241243 int clock_speed = 40 * 1000 * 1000 ;
242244 auto spi_num = SPI2_HOST;
243245 gpio_num_t mosi = GPIO_NUM_41;
@@ -260,15 +262,6 @@ extern "C" void app_main(void) {
260262 gpio_set_direction (BOARD_POWER_ON_PIN, GPIO_MODE_OUTPUT);
261263 gpio_set_level (BOARD_POWER_ON_PIN, 1 );
262264
263- gpio_num_t TOUCH_INTERRUPT_PIN = GPIO_NUM_16;
264- // wake up the touch chip
265- gpio_set_direction (TOUCH_INTERRUPT_PIN, GPIO_MODE_OUTPUT);
266- gpio_set_level (TOUCH_INTERRUPT_PIN, 1 );
267- std::this_thread::sleep_for (20ms);
268- // now set the interrupt as input
269- gpio_set_direction (TOUCH_INTERRUPT_PIN, GPIO_MODE_INPUT);
270- std::this_thread::sleep_for (20ms);
271-
272265 gpio_num_t KEYBOARD_INTERRUPT_PIN = GPIO_NUM_46;
273266 gpio_set_direction (KEYBOARD_INTERRUPT_PIN, GPIO_MODE_INPUT);
274267#endif
@@ -392,9 +385,13 @@ extern "C" void app_main(void) {
392385#endif
393386#if CONFIG_HARDWARE_TDECK
394387 auto i2c_read = [&](uint8_t dev_addr, uint16_t reg_addr, uint8_t *data, size_t len) {
388+ uint8_t reg_addr_data[] = {
389+ (uint8_t )(reg_addr >> 8 ),
390+ (uint8_t )(reg_addr & 0xff )
391+ };
395392 auto err = i2c_master_write_read_device (I2C_PORT,
396393 dev_addr,
397- ( uint8_t *)®_addr , 2 ,
394+ reg_addr_data , 2 ,
398395 data, len,
399396 I2C_TIMEOUT_MS / portTICK_PERIOD_MS);
400397 if (err != ESP_OK) {
@@ -415,17 +412,14 @@ extern "C" void app_main(void) {
415412 .read = i2c_read,
416413 .write = i2c_write,
417414 .address = Gt911::DEFAULT_ADDRESS_1,
418- .log_level = espp::Logger::Verbosity::DEBUG
415+ .log_level = espp::Logger::Verbosity::WARN
419416 });
420417
421418 auto touchpad_read = [&](uint8_t * num_touch_points, uint16_t * x, uint16_t * y, uint8_t * btn_state) {
422419 *num_touch_points = 0 ;
423420 // get the latest data from the device
424- if (gpio_get_level (TOUCH_INTERRUPT_PIN)) {
425- logger.debug (" touchpad interrupt" );
426- if (gt911.read ()) {
427- gt911.get_touch_point (num_touch_points, x, y);
428- }
421+ if (gt911.read ()) {
422+ gt911.get_touch_point (num_touch_points, x, y);
429423 }
430424 // now hand it off
431425 *btn_state = false ; // no touchscreen button on t-deck
@@ -435,7 +429,7 @@ extern "C" void app_main(void) {
435429 logger.info (" Initializing touchpad" );
436430 auto touchpad = espp::TouchpadInput (espp::TouchpadInput::Config{
437431 .touchpad_read = touchpad_read,
438- .swap_xy = false ,
432+ .swap_xy = touch_swap_xy ,
439433 .invert_x = true ,
440434 .invert_y = false ,
441435 .log_level = espp::Logger::Verbosity::WARN
0 commit comments