![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dd
Dependencies: xtoff2 RF24Network mbed
Fork of xtoff3 by
Ontvanger.h@13:f54dfb74247e, 2018-03-21 (annotated)
- Committer:
- pietor
- Date:
- Wed Mar 21 16:22:28 2018 +0000
- Revision:
- 13:f54dfb74247e
- Parent:
- 12:a3dd2ebf8f93
- Child:
- 14:3e69c8a9c730
Werkend 21/03: Added Messages
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pietor | 4:7ebc3b421306 | 1 | #ifndef Ontvanger_h |
pietor | 4:7ebc3b421306 | 2 | #define Ontvanger_h |
pietor | 4:7ebc3b421306 | 3 | #include "mbed.h" |
pietor | 4:7ebc3b421306 | 4 | #include <RF24Network.h> |
pietor | 4:7ebc3b421306 | 5 | #include <RF24.h> |
pietor | 4:7ebc3b421306 | 6 | |
pietor | 4:7ebc3b421306 | 7 | #define nrf_CE p9 |
pietor | 4:7ebc3b421306 | 8 | #define nrf_CSN p8 |
pietor | 4:7ebc3b421306 | 9 | #define spi_SCK p7 |
pietor | 4:7ebc3b421306 | 10 | #define spi_MOSI p5 |
pietor | 4:7ebc3b421306 | 11 | #define spi_MISO p6 |
pietor | 4:7ebc3b421306 | 12 | |
pietor | 11:77018fac195e | 13 | #ifdef PRINT_ENABLE |
pietor | 11:77018fac195e | 14 | #define IF_PRINT_ENABLE(x) ({x;}) |
pietor | 11:77018fac195e | 15 | #else |
pietor | 11:77018fac195e | 16 | #define IF_PRINT_ENABLE(x) |
pietor | 11:77018fac195e | 17 | #endif |
pietor | 11:77018fac195e | 18 | |
pietor | 11:77018fac195e | 19 | |
pietor | 11:77018fac195e | 20 | //Identification verzender/ontvanger |
pietor | 4:7ebc3b421306 | 21 | const uint16_t this_node = 00; |
pietor | 4:7ebc3b421306 | 22 | const uint16_t other_node = 01; |
pietor | 4:7ebc3b421306 | 23 | |
pietor | 9:e14f65b8ffc2 | 24 | |
pietor | 11:77018fac195e | 25 | // |
pietor | 7:8515f205483b | 26 | struct payload_t { |
pietor | 4:7ebc3b421306 | 27 | bool reedsensor; |
pietor | 13:f54dfb74247e | 28 | float gram; |
pietor | 13:f54dfb74247e | 29 | bool messageAvailable; |
pietor | 13:f54dfb74247e | 30 | char messageIndex; |
pietor | 4:7ebc3b421306 | 31 | }; |
pietor | 4:7ebc3b421306 | 32 | |
pietor | 8:c43411433ce1 | 33 | enum State2 {init_state, |
pietor | 8:c43411433ce1 | 34 | send_state, |
pietor | 12:a3dd2ebf8f93 | 35 | receive_state, |
pietor | 8:c43411433ce1 | 36 | }; |
pietor | 8:c43411433ce1 | 37 | |
pietor | 7:8515f205483b | 38 | enum State {State_init, |
pietor | 7:8515f205483b | 39 | State_tare, |
pietor | 7:8515f205483b | 40 | State_position, |
pietor | 7:8515f205483b | 41 | State_read, |
pietor | 7:8515f205483b | 42 | State_send, |
pietor | 12:a3dd2ebf8f93 | 43 | State_receive, |
pietor | 12:a3dd2ebf8f93 | 44 | State_calibrate |
pietor | 7:8515f205483b | 45 | }; |
pietor | 7:8515f205483b | 46 | |
pietor | 7:8515f205483b | 47 | struct state_Packet { |
pietor | 13:f54dfb74247e | 48 | char setState; |
pietor | 7:8515f205483b | 49 | }; |
pietor | 4:7ebc3b421306 | 50 | |
pietor | 4:7ebc3b421306 | 51 | |
pietor | 4:7ebc3b421306 | 52 | class Ontvanger |
pietor | 4:7ebc3b421306 | 53 | { |
pietor | 4:7ebc3b421306 | 54 | private: |
pietor | 4:7ebc3b421306 | 55 | |
pietor | 4:7ebc3b421306 | 56 | |
pietor | 4:7ebc3b421306 | 57 | public: |
pietor | 4:7ebc3b421306 | 58 | Ontvanger(); |
pietor | 4:7ebc3b421306 | 59 | void update(); |
pietor | 4:7ebc3b421306 | 60 | bool available(); |
pietor | 7:8515f205483b | 61 | bool write(state_Packet message); |
pietor | 4:7ebc3b421306 | 62 | payload_t read(); |
pietor | 10:0a4c465f7838 | 63 | bool isValid(); |
pietor | 10:0a4c465f7838 | 64 | bool testRPD(); |
pietor | 13:f54dfb74247e | 65 | void printMessage(char index); |
pietor | 4:7ebc3b421306 | 66 | }; |
pietor | 4:7ebc3b421306 | 67 | |
pietor | 4:7ebc3b421306 | 68 | #endif |
pietor | 4:7ebc3b421306 | 69 | |
pietor | 4:7ebc3b421306 | 70 | |
pietor | 4:7ebc3b421306 | 71 | |
pietor | 4:7ebc3b421306 | 72 | |
pietor | 4:7ebc3b421306 | 73 |