An updated and more polished version of the earlier TeaBasic. This is now finished and works like a treat.
DebouncedIn.h@0:36264f703f1c, 2011-06-29 (annotated)
- Committer:
- Eggotape
- Date:
- Wed Jun 29 13:20:33 2011 +0000
- Revision:
- 0:36264f703f1c
Haven\t tried it with water yet, so may want to consider slowing the Servo down to avoid splashing.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Eggotape | 0:36264f703f1c | 1 | #include "mbed.h" |
Eggotape | 0:36264f703f1c | 2 | |
Eggotape | 0:36264f703f1c | 3 | class DebouncedIn { |
Eggotape | 0:36264f703f1c | 4 | public: |
Eggotape | 0:36264f703f1c | 5 | DebouncedIn(PinName in); |
Eggotape | 0:36264f703f1c | 6 | |
Eggotape | 0:36264f703f1c | 7 | int read (void); |
Eggotape | 0:36264f703f1c | 8 | operator int(); |
Eggotape | 0:36264f703f1c | 9 | |
Eggotape | 0:36264f703f1c | 10 | int rising(void); |
Eggotape | 0:36264f703f1c | 11 | int falling(void); |
Eggotape | 0:36264f703f1c | 12 | int steady(void); |
Eggotape | 0:36264f703f1c | 13 | |
Eggotape | 0:36264f703f1c | 14 | private : |
Eggotape | 0:36264f703f1c | 15 | // objects |
Eggotape | 0:36264f703f1c | 16 | DigitalIn _in; |
Eggotape | 0:36264f703f1c | 17 | Ticker _ticker; |
Eggotape | 0:36264f703f1c | 18 | |
Eggotape | 0:36264f703f1c | 19 | // function to take a sample, and update flags |
Eggotape | 0:36264f703f1c | 20 | void _sample(void); |
Eggotape | 0:36264f703f1c | 21 | |
Eggotape | 0:36264f703f1c | 22 | // counters and flags |
Eggotape | 0:36264f703f1c | 23 | int _samples; |
Eggotape | 0:36264f703f1c | 24 | int _output; |
Eggotape | 0:36264f703f1c | 25 | int _output_last; |
Eggotape | 0:36264f703f1c | 26 | int _rising_flag; |
Eggotape | 0:36264f703f1c | 27 | int _falling_flag; |
Eggotape | 0:36264f703f1c | 28 | int _state_counter; |
Eggotape | 0:36264f703f1c | 29 | |
Eggotape | 0:36264f703f1c | 30 | }; |
Eggotape | 0:36264f703f1c | 31 |