Skip to content

Commit 110b0a0

Browse files
committed
fix(button): fix not triggering longpress start with polling intervals over 20ms
1 parent 64848f4 commit 110b0a0

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

components/button/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# ChangeLog
22

3+
## v3.4.1 - 2024-12-6
4+
5+
### Fix:
6+
7+
* Fix the issue where `BUTTON_LONG_PRESS_START` is not triggered when the polling interval exceeds 20ms.
8+
* Remove the `BUTTON_LONG_PRESS_TOLERANCE_MS` configuration option.
9+
310
## v3.4.0 - 2024-10-22
411

512
### Enhancements:

components/button/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ menu "IoT Button"
2424
range 500 5000
2525
default 1500
2626

27-
config BUTTON_LONG_PRESS_TOLERANCE_MS
28-
int "BUTTON LONG PRESS TOLERANCE TIME (MS)"
29-
default 20
30-
3127
config BUTTON_SERIAL_TIME_MS
3228
int "BUTTON SERIAL TIME (MS)"
3329
range 2 1000

components/button/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.4.0"
1+
version: "3.4.1"
22
description: GPIO and ADC button driver
33
url: https://github.com/espressif/esp-iot-solution/tree/master/components/button
44
repository: https://github.com/espressif/esp-iot-solution.git

components/button/iot_button.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static button_power_save_config_t power_save_usr_cfg = {0};
9494
#define SHORT_TICKS (CONFIG_BUTTON_SHORT_PRESS_TIME_MS /TICKS_INTERVAL)
9595
#define LONG_TICKS (CONFIG_BUTTON_LONG_PRESS_TIME_MS /TICKS_INTERVAL)
9696
#define SERIAL_TICKS (CONFIG_BUTTON_SERIAL_TIME_MS /TICKS_INTERVAL)
97-
#define TOLERANCE CONFIG_BUTTON_LONG_PRESS_TOLERANCE_MS
97+
#define TOLERANCE (CONFIG_BUTTON_PERIOD_TIME_MS*4)
9898

9999
#define CALL_EVENT_CB(ev) \
100100
if (btn->cb_info[ev]) { \
@@ -148,7 +148,7 @@ static void button_handler(button_dev_t *btn)
148148
btn->ticks = 0;
149149
btn->state = 2;
150150

151-
} else if (btn->ticks > btn->long_press_ticks) {
151+
} else if (btn->ticks >= btn->long_press_ticks) {
152152
btn->event = (uint8_t)BUTTON_LONG_PRESS_START;
153153
btn->state = 4;
154154
/** Calling callbacks for BUTTON_LONG_PRESS_START */

components/button/test_apps/main/button_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ TEST_CASE("gpio button auto-test", "[button][iot][auto]")
595595
vTaskDelay(pdMS_TO_TICKS(100));
596596
}
597597

598-
#define TOLERANCE CONFIG_BUTTON_LONG_PRESS_TOLERANCE_MS
598+
#define TOLERANCE (CONFIG_BUTTON_PERIOD_TIME_MS * 4)
599599

600600
uint16_t long_press_time[5] = {2000, 2500, 3000, 3500, 4000};
601601
static SemaphoreHandle_t long_press_check = NULL;

0 commit comments

Comments
 (0)