修复了SW2 双击后抖动,

icon 文件改为每帧只加载一次,整帧绘制期间复用,不再每 8 行重复读取。
This commit is contained in:
CSBOOK\44744
2026-06-28 19:16:17 +08:00
parent 4c6bb66f7c
commit 21e5d43766
4 changed files with 115 additions and 20 deletions
@@ -44,6 +44,10 @@
#define CONFIG_TQ_KEY_DOUBLE_CLICK_MS 300
#endif
#ifndef CONFIG_TQ_KEY_POST_DOUBLE_CLICK_SUPPRESS_MS
#define CONFIG_TQ_KEY_POST_DOUBLE_CLICK_SUPPRESS_MS 450
#endif
#ifndef CONFIG_TQ_KEY_INPUT_POLL_MS
#define CONFIG_TQ_KEY_INPUT_POLL_MS 20
#endif
@@ -105,6 +109,7 @@ typedef struct {
int64_t inactive_since_ms;
int64_t press_start_ms;
int64_t click_deadline_ms;
int64_t suppress_until_ms;
} control_plane_key_state_t;
static const control_plane_key_config_t s_key_configs[] = {
@@ -312,6 +317,9 @@ static void control_plane_handle_debounced_transition(const control_plane_key_co
if (config->enable_double_click && state->click_pending && now_ms <= state->click_deadline_ms) {
state->click_pending = false;
state->debounce_pending = false;
state->press_start_ms = 0;
state->suppress_until_ms = now_ms + CONFIG_TQ_KEY_POST_DOUBLE_CLICK_SUPPRESS_MS;
control_plane_emit_key_event(config,
CONTROL_PLANE_KEY_EVENT_DOUBLE_CLICK,
level,
@@ -344,6 +352,11 @@ static void control_plane_process_key_timers(void)
continue;
}
if (state->suppress_until_ms > 0 && now_ms < state->suppress_until_ms) {
state->debounce_pending = false;
continue;
}
if (state->wait_inactive_before_press) {
const int level = gpio_get_level(config->gpio_num);
const bool pressed = control_plane_key_level_is_pressed(config, level);
@@ -469,6 +482,21 @@ static void control_plane_key_input_task(void *arg)
}
control_plane_key_state_t *state = &s_key_states[index];
if (state->suppress_until_ms > 0 && irq_event.timestamp_ms < state->suppress_until_ms) {
const bool pressed = control_plane_key_level_is_pressed(config, irq_event.level);
state->raw_level = irq_event.level;
state->debounce_pending = false;
if (!pressed) {
state->debounced_pressed = false;
}
ESP_LOGD(TAG,
"suppressed gpio change key=%s gpio=%d level=%d",
control_plane_key_id_name(config->key_id),
(int)irq_event.gpio_num,
irq_event.level);
continue;
}
state->raw_level = irq_event.level;
state->debounce_pending = true;
state->debounce_deadline_ms = irq_event.timestamp_ms + config->debounce_ms;