blob: e99c767fb7d8dca4513a41e0443e24a0a16f275f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#ifndef __BUTTONHANDLER_H__
#define __BUTTONHANDLER_H__
#include "mbed.h"
#include "rtos.h"
#define buttonSignal (int32_t)0x01
class ButtonHandler {
public:
typedef enum {
none = 0,
sw1_press,
sw1_hold,
sw2_press
} ButtonEvent;
ButtonHandler(osThreadId main);
~ButtonHandler();
ButtonEvent getButtonEvent();
void sw1_fall();
void sw1_rise();
void sw2_fall();
void sw2_rise();
osThreadId _main;
Thread _thread;
InterruptIn _sw1;
InterruptIn _sw2;
Timer _sw1_timer;
Timer _sw2_timer;
time_t _sw1_time;
time_t _sw2_time;
bool _sw1_running;
bool _sw2_running;
ButtonEvent _event;
time_t _debounce_time;
time_t _hold_threshold;
};
#endif
|