A program to test a library with which a mbed receives a char, or a line until enter as a command, and execute registered functions. If nothing is registered, the library function just echo the command.
Dependencies: mbed SerialInputReactionHandler
main.cpp@0:27eb52652bc3, 2020-10-21 (annotated)
- Committer:
- aktk
- Date:
- Wed Oct 21 18:08:17 2020 +0000
- Revision:
- 0:27eb52652bc3
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aktk | 0:27eb52652bc3 | 1 | #include "mbed.h" |
aktk | 0:27eb52652bc3 | 2 | #include "SerialInputReactionHandler.h" |
aktk | 0:27eb52652bc3 | 3 | |
aktk | 0:27eb52652bc3 | 4 | int main() |
aktk | 0:27eb52652bc3 | 5 | { |
aktk | 0:27eb52652bc3 | 6 | // Initialise the digital pin LED1 as an output |
aktk | 0:27eb52652bc3 | 7 | DigitalOut led(LED1); |
aktk | 0:27eb52652bc3 | 8 | SerialInputReactionHandler reactor; |
aktk | 0:27eb52652bc3 | 9 | Serial pc(USBTX, USBRX, 921600); |
aktk | 0:27eb52652bc3 | 10 | |
aktk | 0:27eb52652bc3 | 11 | pc.attach(callback(&reactor, &SerialInputReactionHandler::key_bind)); |
aktk | 0:27eb52652bc3 | 12 | |
aktk | 0:27eb52652bc3 | 13 | while (true) { |
aktk | 0:27eb52652bc3 | 14 | led = !led; |
aktk | 0:27eb52652bc3 | 15 | wait(.5); |
aktk | 0:27eb52652bc3 | 16 | } |
aktk | 0:27eb52652bc3 | 17 | } |