Modified version to work with EventQueue (outside of ISR)

Revision:
3:c7f97bebf2f7
Parent:
2:6af39916a4a2
Child:
4:8d6883cdc3c8
--- a/MultiClick.h	Mon Jun 13 09:11:53 2016 +0000
+++ b/MultiClick.h	Mon Jun 13 10:15:15 2016 +0000
@@ -1,6 +1,6 @@
 #include "mbed.h"
 
-//#define DEBUG
+#define DEBUG
 
 #ifdef DEBUG
 #define DBG_PRINT(...) printf(__VA_ARGS__)
@@ -16,16 +16,19 @@
     void attach_clicked(void (*function)(void));
     void attach_doubleclicked(void (*function)(void));
     void attach_n_clicked(void (*function)(int));
+    void attach_longpressed(void (*function)(void));
     
 private:
     void isr_pressed(void);
     void isr_released(void);
     void click_timeout( void );
     void debounce_timeout( void );
+    void longpress_timeout( void );
 
     Timer *_t;
     Timeout *_timeout;
     Timeout *_debounce_timeout;
+    Timeout *_longpress_timeout;
     InterruptIn *_iin;
     PinMode _mode;
     
@@ -36,8 +39,9 @@
     int _click_times;
     
     bool _debounce_ignore;
-    
+    bool _longpressed;
     void (*_c_callback_clicked)(void);
     void (*_c_callback_doubleclicked)(void);
     void (*_c_callback_n_clicked)(int);
+    void (*_c_callback_longpressed)(void);
 };