Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SoftSerial SDFileSystem mbed wave_player
Relay.h@24:d91e9b3b5bd5, 2017-05-17 (annotated)
- Committer:
- Thomas Cauwelier
- Date:
- Wed May 17 00:10:42 2017 +0200
- Revision:
- 24:d91e9b3b5bd5
- Child:
- 29:c2d95d88ee0b
add relay logic
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 1 | // |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 2 | // Created by thoma on 16-May-17. |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 3 | // |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 4 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 5 | #ifndef VISIBLE_LIGHT_COMMUNICATION_RELAY_H |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 6 | #define VISIBLE_LIGHT_COMMUNICATION_RELAY_H |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 7 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 8 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 9 | #include "mbed.h" |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 10 | #include "MySoftSerial.h" |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 11 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 12 | class Relay { |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 13 | public: |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 14 | Relay(PinName tx_luart, int baudrate_luart, PinName tx_usb, PinName rx_usb, int baudrate_usb); |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 15 | void run(); |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 16 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 17 | private: |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 18 | MySoftSerial softSerial; |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 19 | Serial usb; |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 20 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 21 | static const int SEND_FILE = 0b00001111; |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 22 | static const int SET_VOLUME = 0b00110011; |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 23 | static const int ACK = 0b11111111; |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 24 | int buffer[64]; |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 25 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 26 | void handle_type(); |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 27 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 28 | void set_volume(); |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 29 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 30 | void send_file(); |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 31 | }; |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 32 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 33 | |
| Thomas Cauwelier |
24:d91e9b3b5bd5 | 34 | #endif //VISIBLE_LIGHT_COMMUNICATION_RELAY_H |