bzr branch
http://bzr.ed.am/elec/propeller-clock
56
by edam
updated software to include drawing abstraction infrastructure |
1 |
#include <map> |
2 |
||
3 |
class Button |
|
4 |
{ |
|
5 |
public: |
|
6 |
||
7 |
/** |
|
8 |
* Constructor. |
|
9 |
* |
|
10 |
* @param pin the pin to monitor |
|
11 |
*/ |
|
12 |
Button( int pin ); |
|
13 |
||
14 |
/** |
|
15 |
* Add a duration at which the specified event id should be triggered. |
|
16 |
* |
|
17 |
* @oaram duration the time at which the event should be triggered |
|
18 |
* @param event_id a unique identifier for the event (not 0) |
|
19 |
*/ |
|
20 |
void add_event_at( int duration, int event_id ); |
|
21 |
||
22 |
/** |
|
23 |
* Update internal state |
|
24 |
*/ |
|
25 |
int update(); |
|
26 |
||
27 |
/** |
|
28 |
* Retrieve the event id of the event that was triggered at the last |
|
29 |
* update, if there was one. |
|
30 |
* |
|
31 |
* @return event id, or 0 |
|
32 |
*/ |
|
33 |
int get_triggered_event(); |
|
34 |
||
35 |
protected: |
|
36 |
||
37 |
/** pin */ |
|
38 |
int _pin; |
|
39 |
||
40 |
/** last state */ |
|
41 |
bool _last_state; |
|
42 |
||
43 |
/** milliseconds since last state change */ |
|
44 |
int _last_millis; |
|
45 |
||
46 |
/** triggered event */ |
|
47 |
int _event_id; |
|
48 |
||
49 |
/** press events durations -> event ids */ |
|
50 |
std::map< int, int > _press_events; |
|
51 |
||
52 |
}; |