Skip to content

Commit 80809e4

Browse files
lboueLzw655
authored andcommitted
fix(gt911): allow to set the GT911 touch device address by @lboue (#86)
closes #86 closes #85
1 parent 57465a0 commit 80809e4

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* fix(examples): fix `LVGL_PORT_ROTATION_DEGREE` issue by @lboue (#76)
88
* fix(examples): fix issue with I2C.ino EXAMPLE_TOUCH_ADDRESS missing as variable by @lboue (#84)
9+
* fix(gt911): allow to set the GT911 touch device address by @lboue (#86)
910

1011
## v0.1.5 - 2024-07-09
1112

src/touch/ESP_PanelTouch.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ ESP_PanelTouch::ESP_PanelTouch(ESP_PanelBus *bus, const esp_lcd_touch_config_t &
7878
}
7979
}
8080

81+
ESP_PanelTouch::ESP_PanelTouch(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config, int address):
82+
bus(bus),
83+
config(config),
84+
handle(NULL),
85+
_swap_xy(false),
86+
_mirror_x(false),
87+
_mirror_y(false),
88+
_tp_points_num(0),
89+
_tp_buttons_state{0},
90+
onTouchInterruptCallback(NULL),
91+
_isr_sem(NULL),
92+
callback_data(CALLBACK_DATA_DEFAULT())
93+
{
94+
if ((config.int_gpio_num != GPIO_NUM_NC) && (config.interrupt_callback == NULL) && (config.user_data == NULL)) {
95+
this->config.interrupt_callback = onTouchInterrupt;
96+
this->config.user_data = &callback_data;
97+
}
98+
}
99+
81100
bool ESP_PanelTouch::attachInterruptCallback(std::function<bool (void *)> callback, void *user_data)
82101
{
83102
ESP_PANEL_CHECK_FALSE_RET((config.interrupt_callback == onTouchInterrupt), false, "Interruption is not enabled");

src/touch/ESP_PanelTouch.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ class ESP_PanelTouch {
7878
*/
7979
ESP_PanelTouch(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config);
8080

81+
/**
82+
* @brief Construct a new touch device in a complex way, the `init()` function should be called after this function
83+
*
84+
* @param bus Pointer to panel bus
85+
* @param config Touch device configuration
86+
* @param address The address of the touch device, default set to `0` to use the default address
87+
*/
88+
ESP_PanelTouch(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config, int address);
89+
8190
/**
8291
* @brief Destroy the LCD device
8392
*

src/touch/GT911.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ ESP_PanelTouch_GT911::ESP_PanelTouch_GT911(ESP_PanelBus *bus, const esp_lcd_touc
1919
{
2020
}
2121

22+
ESP_PanelTouch_GT911::ESP_PanelTouch_GT911(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config, int address):
23+
ESP_PanelTouch(bus, config, address)
24+
{
25+
}
26+
2227
ESP_PanelTouch_GT911::~ESP_PanelTouch_GT911()
2328
{
2429
ESP_PANEL_ENABLE_TAG_DEBUG_LOG();

src/touch/GT911.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ class ESP_PanelTouch_GT911 : public ESP_PanelTouch {
3333
*
3434
* @param bus Pointer to panel bus
3535
* @param config Touch device configuration
36-
* @param address The address of the touch device, default set to `0` to use the default address
3736
*/
3837
ESP_PanelTouch_GT911(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config);
3938

39+
/**
40+
* @brief Construct a new touch device in a complex way, the `init()` function should be called after this function
41+
*
42+
* @param bus Pointer to panel bus
43+
* @param config Touch device configuration
44+
* @param address The address of the touch device, default set to `0` to use the default address
45+
*/
46+
ESP_PanelTouch_GT911(ESP_PanelBus *bus, const esp_lcd_touch_config_t &config, int address);
47+
4048
/**
4149
* @brief Destroy the LCD device
4250
*

0 commit comments

Comments
 (0)