Browse Source

[update]add LONG_HOLD_CYC control LONG_PRESS_HOLD callback period.|添加宏LONG_HOLD_CYC控制长按保持事件的回调周期

guozhanxin 7 năm trước cách đây
mục cha
commit
47c4133d2e
2 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 4 1
      multi_button.c
  2. 1 0
      multi_button.h

+ 4 - 1
multi_button.c

@@ -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 
         {

+ 1 - 0
multi_button.h

@@ -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*);