Modified version to work with EventQueue (outside of ISR)
MultiClick.h
- Committer:
- ohtsuka
- Date:
- 2016-06-13
- Revision:
- 2:6af39916a4a2
- Parent:
- 1:67d677ad73e7
- Child:
- 3:c7f97bebf2f7
File content as of revision 2:6af39916a4a2:
#include "mbed.h" //#define DEBUG #ifdef DEBUG #define DBG_PRINT(...) printf(__VA_ARGS__) #else #define DBG_PRINT(...) #endif class MultiClick { public: MultiClick(PinName pin); MultiClick(PinName pin, PinMode m); void attach_clicked(void (*function)(void)); void attach_doubleclicked(void (*function)(void)); void attach_n_clicked(void (*function)(int)); private: 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; 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); };