espressif / esp-bsp

Board support components for Espressif development boards
Other
188 stars 97 forks source link

esp_lcd_touch_gt911 - Touch buttons not working (BSP-502) #331

Open chewhs00 opened 4 months ago

chewhs00 commented 4 months ago

Board

Custom board

Hardware Description

Module: ESP32-S3-WROOM-2 (Octal SPI), 32MB flash, 8MB PSRAM Compiler: xtensa-esp32s3-elf-gcc (crosstool-NG esp-12.2.0_20230208) 12.2.0 espressif/esp_lcd_touch: component_hash: d4d8f2dc33205797169a97a02e0d89a8982f59fe0509129b54422052b8522f59 source: service_url: https://api.components.espressif.com/ type: service version: 1.1.1 espressifesp_lcd_touch_gt911: component_hash: null source: path: /home/hian/esp/projects/cq50-idf5.1/components/espressifesp_lcd_touch_gt911 type: local version: 1.1.0 idf: component_hash: null source: type: idf version: 5.1.1 lvgl/lvgl: component_hash: 948bff879a345149b83065535bbc4a026ce9f47498a22881e432a264b9098015 source: service_url: https://api.components.espressif.com/ type: service version: 8.3.11 manifest_hash: 7b2ebc9db852776c29c4ccc0ebb1d97eb22f359e564723e1935582025185a84f target: esp32s3 version: 1.0.0

IDE Name

Eclipse

Operating System

Ubuntu 20.04.5 LTS

Description

Cap-touch button not detected from static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp)

#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
      } else if ((buf[0] & 0x10) == 0x10) {
          /* Read all keys */
          uint8_t key_max = ((ESP_GT911_TOUCH_MAX_BUTTONS < CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS) ? \
                             (ESP_GT911_TOUCH_MAX_BUTTONS) : (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS));
          err = touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_READ_KEY_REG, &buf[0], key_max);
          ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!");

          /* Clear all */
          touch_gt911_i2c_write(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, clear);
          ESP_RETURN_ON_ERROR(err, TAG, "I2C write error!");

          portENTER_CRITICAL(&tp->data.lock);

          /* Buttons count */
          tp->data.buttons = key_max;
          for (i = 0; i < key_max; i++) {
              tp->data.button[i].status = buf[0] ? 1 : 0;
          }

          portEXIT_CRITICAL(&tp->data.lock);
  #endif

Shouldn't buf[] on line tp->data.button[i].status = buf[0] ? 1 : 0; use index i as opposed to 0? Regardless, ESP_LCD_TOUCH_GT911_READ_KEY_REG[] are just button s' index during configuration, and does not report actual button trigger status. On my application, with CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS = 4, instead of reading from ESP_LCD_TOUCH_GT911_READ_KEY_REG[] to find out which button(s) is pressed, the actual status is reported at register ESP_LCD_TOUCH_GT911_READ_XY_REG + 1, which only reports single button index at a time. Multiple buttons pressed simultaneously may not get reported on my current register configurations.

Sketch

CONFIG_ESP_LCD_TOUCH_MAX_POINTS = 1
CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS = 4
GT911_TOTAL_REGISTER_CONFIG = 184
static const uint8_t GT911_CFG[GT911_TOTAL_REGISTER_CONFIG] = {
    0x48, 0x40, 0x01, 0xE0, 0x01, 0x0A, 0x05, 0x01, 0x01, 0x08, 0x28, 0x05, 0x50, 0x32, 0x03, 0x05,
    0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x05, 0x00, 0x00, 0x00, 0x00, 0x86, 0x26, 0x08, 0x19, 0x16,
    0x12, 0x0C, 0x00, 0x00, 0x00, 0x9B, 0x04, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x64, 0x32,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x28, 0x10, 0x18,
    0xF0, 0x4A, 0x3A, 0xFF, 0xFF, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x02,
    0x04, 0x06, 0x08, 0x0A, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

The readout from registers starting from ESP_LCD_TOUCH_GT911_READ_XY_REG each time an interrupt signal is received and the above api is called:

90 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
I (11744) view_control_process_events: display-button: {"time_stamp":10,"cause":0,"level":"info","data":{"button_triggered":1}}
00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

90 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
I (13755) view_control_process_events: display-button: {"time_stamp":12,"cause":0,"level":"info","data":{"button_triggered":2}}
00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

90 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
I (15701) view_control_process_events: display-button: {"time_stamp":14,"cause":0,"level":"info","data":{"button_triggered":4}}
00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

90 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
I (17377) view_control_process_events: display-button: {"time_stamp":15,"cause":0,"level":"info","data":{"button_triggered":8}}
00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Other Steps to Reproduce

No response

I have checked existing issues, README.md and ESP32 Forum

tore-espressif commented 1 month ago

Hello @chewhs00 , I'm sorry for the late reply, this really seems like a bug.

If I remember correctly, we did not test the driver with multiple buttons :(