Skip to content

Commit

Permalink
[update]add LONG_HOLD_CYC control LONG_PRESS_HOLD callback period.|添加…
Browse files Browse the repository at this point in the history
…宏LONG_HOLD_CYC控制长按保持事件的回调周期
  • Loading branch information
Guozhanxin committed Nov 6, 2018
1 parent 656fce2 commit 47c4133
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion multi_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ void button_handler(struct button* handle)
if(handle->button_level == handle->active_level)
{
handle->event = (uint8_t)LONG_PRESS_HOLD;
EVENT_CB(LONG_PRESS_HOLD);
if (handle->ticks % LONG_HOLD_CYC == 0)
{
EVENT_CB(LONG_PRESS_HOLD);
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions multi_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define DEBOUNCE_TICKS 3 //MAX 8
#define SHORT_TICKS (300 / TICKS_INTERVAL)
#define LONG_TICKS (1000 / TICKS_INTERVAL)
#define LONG_HOLD_CYC (500 / TICKS_INTERVAL)

typedef void (*BtnCallback)(void*);

Expand Down

0 comments on commit 47c4133

Please sign in to comment.