@@ -21,35 +21,34 @@ Button event
2121
2222Triggering conditions for each button event are enlisted in the table below:
2323
24-
25- +--------------------------+-----------------------------------+
26- | Event | Trigger Condition |
27- +==========================+===================================+
28- | BUTTON_PRESS_DOWN | Pressed |
29- +--------------------------+-----------------------------------+
30- | BUTTON_PRESS_UP | Released |
31- +--------------------------+-----------------------------------+
32- | BUTTON_PRESS_REPEAT | Pressed and released >= 2 times |
33- +--------------------------+-----------------------------------+
34- | BUTTON_PRESS_REPEAT_DONE | Repeated press completed |
35- +--------------------------+-----------------------------------+
36- | BUTTON_SINGLE_CLICK | Pressed and released once |
37- +--------------------------+-----------------------------------+
38- | BUTTON_DOUBLE_CLICK | Pressed and released twice |
39- +--------------------------+-----------------------------------+
40- | BUTTON_MULTIPLE_CLICK | Pressed and released N times |
41- | | specified, triggers when achieved |
42- +--------------------------+-----------------------------------+
43- | BUTTON_LONG_PRESS_START | Instant when held for a threshold |
44- | | duration of time |
45- +--------------------------+-----------------------------------+
46- | BUTTON_LONG_PRESS_HOLD | Triggered continuously during |
47- | | long press |
48- +--------------------------+-----------------------------------+
49- | BUTTON_LONG_PRESS_UP | Released after a long press |
50- +--------------------------+-----------------------------------+
51- | BUTTON_PRESS_REPEAT_DONE | Repeated press and release ended |
52- +--------------------------+-----------------------------------+
24+ +--------------------------+--------------------------------------+
25+ | Event | Trigger Condition |
26+ +==========================+======================================+
27+ | BUTTON_PRESS_DOWN | Pressed |
28+ +--------------------------+--------------------------------------+
29+ | BUTTON_PRESS_UP | Released |
30+ +--------------------------+--------------------------------------+
31+ | BUTTON_PRESS_REPEAT | Pressed and released >= 2 times |
32+ +--------------------------+--------------------------------------+
33+ | BUTTON_PRESS_REPEAT_DONE | Repeated press completed |
34+ +--------------------------+--------------------------------------+
35+ | BUTTON_SINGLE_CLICK | Pressed and released once |
36+ +--------------------------+--------------------------------------+
37+ | BUTTON_DOUBLE_CLICK | Pressed and released twice |
38+ +--------------------------+--------------------------------------+
39+ | BUTTON_MULTIPLE_CLICK | Pressed and released N times |
40+ | | specified, triggers when achieved |
41+ +--------------------------+--------------------------------------+
42+ | BUTTON_LONG_PRESS_START | Instant when held for a threshold |
43+ | | duration of time |
44+ +--------------------------+--------------------------------------+
45+ | BUTTON_LONG_PRESS_HOLD | Triggered continuously during |
46+ | | long press |
47+ +--------------------------+--------------------------------------+
48+ | BUTTON_LONG_PRESS_UP | Released after a long press |
49+ +--------------------------+--------------------------------------+
50+ | BUTTON_PRESS_REPEAT_DONE | Repeated press and release ended |
51+ +--------------------------+--------------------------------------+
5352
5453Each button supports **call-back ** and **pooling ** mode.
5554
@@ -277,6 +276,25 @@ As shown, low-power mode results in more power savings.
277276 };
278277 button_handle_t btn = iot_button_create(&btn_cfg);
279278
279+ When to Enter Light Sleep
280+
281+ - Using Auto Light Sleep: The device will enter Light Sleep automatically after the button closes the esp_timer.
282+
283+ - User-Controlled Light Sleep: The device can enter Light Sleep when ``enter_power_save_cb `` is called.
284+
285+ .. code :: c
286+
287+ void btn_enter_power_save(void *usr_data)
288+ {
289+ ESP_LOGI(TAG, "Can enter power save now");
290+ }
291+
292+ button_power_save_config_t config = {
293+ .enter_power_save_cb = btn_enter_power_save,
294+ };
295+
296+ iot_button_register_power_save_cb(&config);
297+
280298 Stop and resume
281299^^^^^^^^^^^^^^^^^
282300
0 commit comments