Modified version to work with EventQueue (outside of ISR)

Revision:
5:cb4d45f41e17
Parent:
4:8d6883cdc3c8
Child:
7:7d56935ba84d
--- a/MultiClick.h	Wed Jun 15 05:17:19 2016 +0000
+++ b/MultiClick.h	Wed Jun 15 08:55:09 2016 +0000
@@ -1,6 +1,6 @@
 #include "mbed.h"
 
-#define DEBUG
+//#define DEBUG
 
 #ifdef DEBUG
 #define DBG_PRINT(...) printf(__VA_ARGS__)
@@ -20,26 +20,23 @@
     
 private:
     void isr_pressed(void);
-    void isr_released(void);
-    void click_timeout( void );
-    void debounce_timeout( void );
-    void longpress_timeout( void );
+    void click_detect_timeout( void );
+    void press_check_func( void );
 
     Timer *_t;
-    Timeout *_timeout;
-    Timeout *_debounce_timeout;
-    Timeout *_longpress_timeout;
+    Ticker *_press_check;
+    Timeout *_click_detect_timeout;
     InterruptIn *_iin;
     PinMode _mode;
     
-    int _debounce_ignore_us;
-    int _pressed_time;
+    int _shortpress_num;
+    int _longpress_num;
+
+    int _press_check_interval_us;
     int _click_interval_us;
-    int _longpress_us;
     int _click_times;
     
-//    bool _pressed;
-    bool _debounce_ignore;
+    int _pressed_count;
     bool _longpressed;
     
     void (*_c_callback_clicked)(void);