TOF based Presence Detector
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/blinker.h@29:eceecbe28088, 2018-08-20 (annotated)
- Committer:
- hux
- Date:
- Mon Aug 20 16:43:10 2018 +0000
- Revision:
- 29:eceecbe28088
- Parent:
- 28:a23b16555909
made in Shanghai
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 28:a23b16555909 | 1 | // blinker.h - blinking sequences for LED1 |
hux | 28:a23b16555909 | 2 | #ifndef _BLINKER_H_ |
hux | 28:a23b16555909 | 3 | #define _BLINKER_H_ |
hux | 28:a23b16555909 | 4 | |
hux | 28:a23b16555909 | 5 | #include <mbed.h> |
hux | 28:a23b16555909 | 6 | |
hux | 28:a23b16555909 | 7 | # define BLINKER_SEQUENCE_IDLE "x " |
hux | 28:a23b16555909 | 8 | # define BLINKER_SEQUENCE_ADVERTISE "x xxx " |
hux | 28:a23b16555909 | 9 | # define BLINKER_SEQUENCE_CONNECTED " xxx " |
hux | 28:a23b16555909 | 10 | # define BLINKER_SEQUENCE_ACTION "x x x x x " |
hux | 28:a23b16555909 | 11 | # define BLINKER_SEQUENCE_ERROR "x x x x xxx " |
hux | 28:a23b16555909 | 12 | # define BLINKER_SEQUENCE_TRANSITION "x x x " |
hux | 28:a23b16555909 | 13 | |
hux | 28:a23b16555909 | 14 | class Blinker |
hux | 28:a23b16555909 | 15 | { |
hux | 28:a23b16555909 | 16 | public: // construction |
hux | 28:a23b16555909 | 17 | Blinker() {} // nothing to do |
hux | 28:a23b16555909 | 18 | |
hux | 28:a23b16555909 | 19 | public: |
hux | 28:a23b16555909 | 20 | void morse(const char *pattern, double periode = 0.2); |
hux | 28:a23b16555909 | 21 | void blink(const char *pattern, const char* next, double interval = 0.2); |
hux | 28:a23b16555909 | 22 | void blink(const char *pattern, double periode = 0.2); |
hux | 28:a23b16555909 | 23 | |
hux | 28:a23b16555909 | 24 | void idle(const char *action = BLINKER_SEQUENCE_IDLE) |
hux | 28:a23b16555909 | 25 | { |
hux | 28:a23b16555909 | 26 | blink(action,BLINKER_SEQUENCE_IDLE); |
hux | 28:a23b16555909 | 27 | } |
hux | 28:a23b16555909 | 28 | |
hux | 28:a23b16555909 | 29 | void advertise(const char *action = BLINKER_SEQUENCE_ADVERTISE) |
hux | 28:a23b16555909 | 30 | { |
hux | 28:a23b16555909 | 31 | blink(action,BLINKER_SEQUENCE_ADVERTISE); |
hux | 28:a23b16555909 | 32 | } |
hux | 28:a23b16555909 | 33 | |
hux | 28:a23b16555909 | 34 | void connected(const char *action = BLINKER_SEQUENCE_ACTION) |
hux | 28:a23b16555909 | 35 | { |
hux | 28:a23b16555909 | 36 | blink(action, BLINKER_SEQUENCE_CONNECTED); |
hux | 28:a23b16555909 | 37 | } |
hux | 28:a23b16555909 | 38 | |
hux | 28:a23b16555909 | 39 | void action() // 'action' blink sequence |
hux | 28:a23b16555909 | 40 | { |
hux | 28:a23b16555909 | 41 | blink(BLINKER_SEQUENCE_ACTION, BLINKER_SEQUENCE_IDLE); |
hux | 28:a23b16555909 | 42 | } |
hux | 28:a23b16555909 | 43 | |
hux | 28:a23b16555909 | 44 | void blinkError(const char *action = BLINKER_SEQUENCE_ERROR) |
hux | 28:a23b16555909 | 45 | { |
hux | 28:a23b16555909 | 46 | blink(action,BLINKER_SEQUENCE_ERROR); |
hux | 28:a23b16555909 | 47 | } |
hux | 28:a23b16555909 | 48 | |
hux | 28:a23b16555909 | 49 | void blink() // stop blinking |
hux | 28:a23b16555909 | 50 | { |
hux | 28:a23b16555909 | 51 | blink(""); // empty blinking pattern |
hux | 28:a23b16555909 | 52 | } |
hux | 28:a23b16555909 | 53 | }; |
hux | 28:a23b16555909 | 54 | |
hux | 28:a23b16555909 | 55 | #endif // _BLINKER_H_ |