![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
in d mix
Dependencies: xtoff2 RF24Network mbed
Fork of RF24Network_Receive by
Ontvanger.h@11:77018fac195e, 2018-03-09 (annotated)
- Committer:
- pietor
- Date:
- Fri Mar 09 12:22:27 2018 +0000
- Revision:
- 11:77018fac195e
- Parent:
- 10:0a4c465f7838
- Child:
- 12:a3dd2ebf8f93
9/03 test
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 | 8:c43411433ce1 | 28 | float milligram; |
pietor | 4:7ebc3b421306 | 29 | }; |
pietor | 4:7ebc3b421306 | 30 | |
pietor | 8:c43411433ce1 | 31 | enum State2 {init_state, |
pietor | 8:c43411433ce1 | 32 | send_state, |
pietor | 8:c43411433ce1 | 33 | receive_state |
pietor | 8:c43411433ce1 | 34 | }; |
pietor | 8:c43411433ce1 | 35 | |
pietor | 7:8515f205483b | 36 | enum State {State_init, |
pietor | 7:8515f205483b | 37 | State_tare, |
pietor | 7:8515f205483b | 38 | State_position, |
pietor | 7:8515f205483b | 39 | State_read, |
pietor | 7:8515f205483b | 40 | State_send, |
pietor | 7:8515f205483b | 41 | State_receive |
pietor | 7:8515f205483b | 42 | }; |
pietor | 7:8515f205483b | 43 | |
pietor | 7:8515f205483b | 44 | struct state_Packet { |
pietor | 7:8515f205483b | 45 | State setState; |
pietor | 7:8515f205483b | 46 | }; |
pietor | 4:7ebc3b421306 | 47 | |
pietor | 4:7ebc3b421306 | 48 | |
pietor | 4:7ebc3b421306 | 49 | class Ontvanger |
pietor | 4:7ebc3b421306 | 50 | { |
pietor | 4:7ebc3b421306 | 51 | private: |
pietor | 4:7ebc3b421306 | 52 | |
pietor | 4:7ebc3b421306 | 53 | |
pietor | 4:7ebc3b421306 | 54 | public: |
pietor | 4:7ebc3b421306 | 55 | Ontvanger(); |
pietor | 4:7ebc3b421306 | 56 | void update(); |
pietor | 4:7ebc3b421306 | 57 | bool available(); |
pietor | 7:8515f205483b | 58 | bool write(state_Packet message); |
pietor | 4:7ebc3b421306 | 59 | payload_t read(); |
pietor | 10:0a4c465f7838 | 60 | bool isValid(); |
pietor | 10:0a4c465f7838 | 61 | bool testRPD(); |
pietor | 4:7ebc3b421306 | 62 | }; |
pietor | 4:7ebc3b421306 | 63 | |
pietor | 4:7ebc3b421306 | 64 | #endif |
pietor | 4:7ebc3b421306 | 65 | |
pietor | 4:7ebc3b421306 | 66 | |
pietor | 4:7ebc3b421306 | 67 | |
pietor | 4:7ebc3b421306 | 68 | |
pietor | 4:7ebc3b421306 | 69 |