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