Skip to content

Commit 71df3ba

Browse files
authored
Merge pull request #2 from Guozhanxin/master
[update]add LONG_HOLD_CYC control LONG_PRESS_HOLD callback period.|
2 parents 656fce2 + 47c4133 commit 71df3ba

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

multi_button.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ void button_handler(struct button* handle)
178178
if(handle->button_level == handle->active_level)
179179
{
180180
handle->event = (uint8_t)LONG_PRESS_HOLD;
181-
EVENT_CB(LONG_PRESS_HOLD);
181+
if (handle->ticks % LONG_HOLD_CYC == 0)
182+
{
183+
EVENT_CB(LONG_PRESS_HOLD);
184+
}
182185
}
183186
else
184187
{

multi_button.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define DEBOUNCE_TICKS 3 //MAX 8
1010
#define SHORT_TICKS (300 / TICKS_INTERVAL)
1111
#define LONG_TICKS (1000 / TICKS_INTERVAL)
12+
#define LONG_HOLD_CYC (500 / TICKS_INTERVAL)
1213

1314
typedef void (*BtnCallback)(void*);
1415

0 commit comments

Comments
 (0)