Modified version to work with EventQueue (outside of ISR)
MultiClick.h
- Committer:
- ohtsuka
- Date:
- 2016-06-15
- Revision:
- 5:cb4d45f41e17
- Parent:
- 4:8d6883cdc3c8
- Child:
- 7:7d56935ba84d
File content as of revision 5:cb4d45f41e17:
#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)); void attach_longpressed(void (*function)(void)); private: void isr_pressed(void); void click_detect_timeout( void ); void press_check_func( void ); Timer *_t; Ticker *_press_check; Timeout *_click_detect_timeout; InterruptIn *_iin; PinMode _mode; int _shortpress_num; int _longpress_num; int _press_check_interval_us; int _click_interval_us; int _click_times; int _pressed_count; bool _longpressed; void (*_c_callback_clicked)(void); void (*_c_callback_doubleclicked)(void); void (*_c_callback_n_clicked)(int); void (*_c_callback_longpressed)(void); };