Modified version to work with EventQueue (outside of ISR)

Revision:
1:67d677ad73e7
Parent:
0:9c5c674dcaea
Child:
2:6af39916a4a2
--- a/MultiClick.h	Fri Jun 10 08:09:22 2016 +0000
+++ b/MultiClick.h	Mon Jun 13 08:30:29 2016 +0000
@@ -1,5 +1,13 @@
 #include "mbed.h"
 
+#define DEBUG
+
+#ifdef DEBUG
+#define DBG_PRINT(...) printf(__VA_ARGS__)
+#else
+#define DBG_PRINT(...)
+#endif
+
 class MultiClick
 {
 public:
@@ -10,18 +18,25 @@
     void attach_n_clicked(void (*function)(int));
     
 private:
-    void isr(void);
+    void isr_pressed(void);
+    void isr_released(void);
     void click_timeout( void );
-    
+    void debounce_timeout( void );
+
+    Timer *_t;
     Timeout *_timeout;
+    Timeout *_debounce_timeout;
     InterruptIn *_iin;
     PinMode _mode;
-
-    float _click_interval;
-    int _longpress;
     
+    int _debounce_ignore_us;
+    int _pressed_time;
+    int _click_interval_us;
+    int _longpress_us;
     int _click_times;
     
+    bool _debounce_ignore;
+    
     void (*_c_callback_clicked)(void);
     void (*_c_callback_doubleclicked)(void);
     void (*_c_callback_n_clicked)(int);