From 13841d0836298ef63f1328705227ba5a39e53678 Mon Sep 17 00:00:00 2001 From: 0x1abin <270995079@qq.com> Date: Fri, 30 Sep 2016 02:44:32 +0000 Subject: [PATCH] fix inquire event conflict --- multi_button.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/multi_button.c b/multi_button.c index 93c8d98..d137ef1 100644 --- a/multi_button.c +++ b/multi_button.c @@ -80,6 +80,8 @@ void button_handler(struct Button* handle) handle->ticks = 0; handle->repeat = 1; handle->state = 1; + } else { + handle->event = (uint8_t)NONE_PRESS; } break; @@ -103,22 +105,19 @@ void button_handler(struct Button* handle) EVENT_CB(PRESS_DOWN); handle->repeat++; if(handle->repeat == 2) { - handle->event = (uint8_t)DOUBLE_CLICK; EVENT_CB(DOUBLE_CLICK); // repeat hit - } else { - handle->event = (uint8_t)PRESS_REPEAT; - } - + } EVENT_CB(PRESS_REPEAT); // repeat hit handle->ticks = 0; handle->state = 3; - } else if(handle->ticks > SHORT_TICKS) { + } else if(handle->ticks > SHORT_TICKS) { //released timeout if(handle->repeat == 1) { handle->event = (uint8_t)SINGLE_CLICK; EVENT_CB(SINGLE_CLICK); + } else if(handle->repeat == 2) { + handle->event = (uint8_t)DOUBLE_CLICK; } handle->state = 0; - handle->event = (uint8_t)NONE_PRESS; } break; @@ -131,7 +130,6 @@ void button_handler(struct Button* handle) handle->state = 2; //repeat press } else { handle->state = 0; - handle->event = (uint8_t)NONE_PRESS; } } break; @@ -146,7 +144,6 @@ void button_handler(struct Button* handle) handle->event = (uint8_t)PRESS_UP; EVENT_CB(PRESS_UP); handle->state = 0; //reset - handle->event = (uint8_t)NONE_PRESS; } break; }