Skip to content

Commit

Permalink
fix(touch): release ISR semaphore when delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Lzw655 committed Nov 8, 2024
1 parent 6cb9866 commit f341c7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/touch/ESP_PanelTouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ ESP_PanelTouch::ESP_PanelTouch(ESP_PanelBus *bus, const esp_lcd_touch_config_t &
}
}

void ESP_PanelTouch::configLevels(int reset_level, int interrupt_level)
{
config.levels.reset = reset_level;
config.levels.interrupt = interrupt_level;
}

bool ESP_PanelTouch::attachInterruptCallback(std::function<bool (void *)> callback, void *user_data)
{
ESP_PANEL_CHECK_FALSE_RET((config.interrupt_callback == onTouchInterrupt), false, "Interruption is not enabled");
Expand Down Expand Up @@ -109,6 +115,11 @@ bool ESP_PanelTouch::del(void)
ESP_PANEL_CHECK_NULL_RET(handle, false, "Invalid handle");
ESP_PANEL_CHECK_ERR_RET(esp_lcd_touch_del(handle), false, "Delete touch panel failed");

if (_isr_sem != NULL) {
vSemaphoreDelete(_isr_sem);
_isr_sem = NULL;
}

ESP_LOGD(TAG, "Touch panel @%p deleted", handle);
handle = NULL;

Expand Down
8 changes: 8 additions & 0 deletions src/touch/ESP_PanelTouch.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ class ESP_PanelTouch {
*/
virtual ~ESP_PanelTouch() = default;

/**
* @brief Configure the levels of the reset and interrupt signals
*
* @param reset_level The level of the reset signal
* @param interrupt_level The level of the interrupt signal
*/
void configLevels(int reset_level, int interrupt_level);

/**
* @brief Attach a callback function, which will be called when the refreshing is finished
*
Expand Down
1 change: 1 addition & 0 deletions test_apps/touch/i2c/main/test_i2c_touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static void run_test(shared_ptr<ESP_PanelTouch> touch_device)
CREATE_TEST_CASE(CST816S)
CREATE_TEST_CASE(FT5x06)
CREATE_TEST_CASE(GT1151)
CREATE_TEST_CASE(GT911)
CREATE_TEST_CASE(TT21100)
CREATE_TEST_CASE(ST1633)
CREATE_TEST_CASE(ST7123)

0 comments on commit f341c7b

Please sign in to comment.