mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-15 19:34:03 +00:00
add skip calibration and wakeup channel, fix isr in sleep mode
This commit is contained in:
@@ -40,6 +40,7 @@ static bool button_object_check_channel(touch_pad_t channel_num);
|
||||
static esp_err_t button_object_set_threshold(void);
|
||||
static void button_object_process_state(void);
|
||||
static void button_object_update_state(touch_pad_t channel_num, te_state_t channel_state);
|
||||
static te_button_handle_t button_object_search_channel_handle(touch_pad_t channel_num);
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
|
||||
esp_err_t touch_button_install(const touch_button_global_config_t *global_config)
|
||||
@@ -268,6 +269,21 @@ static void button_object_update_state(touch_pad_t channel_num, te_state_t chann
|
||||
}
|
||||
}
|
||||
|
||||
static te_button_handle_t button_object_search_channel_handle(touch_pad_t channel_num)
|
||||
{
|
||||
te_button_handle_list_t *item;
|
||||
te_button_handle_t button_handle = NULL;
|
||||
SLIST_FOREACH(item, &s_te_btn_obj->handle_list, next) {
|
||||
touch_pad_t button_channel = item->button_handle->device->channel;
|
||||
if (channel_num == button_channel) {
|
||||
button_handle = item->button_handle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return button_handle;
|
||||
}
|
||||
|
||||
static esp_err_t button_object_add_instance(te_button_handle_t button_handle)
|
||||
{
|
||||
te_button_handle_list_t *item = (te_button_handle_list_t *)calloc(1, sizeof(te_button_handle_list_t));
|
||||
@@ -296,6 +312,20 @@ static esp_err_t button_object_remove_instance(te_button_handle_t button_handle)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool button_object_handle_check(touch_elem_handle_t element_handle)
|
||||
{
|
||||
te_button_handle_list_t *item;
|
||||
xSemaphoreTake(s_te_btn_obj->mutex, portMAX_DELAY);
|
||||
SLIST_FOREACH(item, &s_te_btn_obj->handle_list, next) {
|
||||
if (element_handle == item->button_handle) {
|
||||
xSemaphoreGive(s_te_btn_obj->mutex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
xSemaphoreGive(s_te_btn_obj->mutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool button_channel_check(te_button_handle_t button_handle, touch_pad_t channel_num)
|
||||
{
|
||||
return (channel_num == button_handle->device->channel);
|
||||
@@ -346,6 +376,13 @@ static inline void button_dispatch(te_button_handle_t button_handle, touch_elem_
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TE_SKIP_DSLEEP_WAKEUP_CALIBRATION
|
||||
void button_config_wakeup_calibration(te_button_handle_t button_handle, bool en)
|
||||
{
|
||||
button_handle->device->is_use_last_threshold = en;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Button process
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user