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: xtoff RF24Network mbed
Transmitter.h
00001 #ifndef Transmitter_h 00002 #define Transmitter_h 00003 #include "mbed.h" 00004 #include <RF24Network.h> 00005 #include <RF24.h> 00006 00007 #define nrf_CE D4 00008 #define nrf_CSN D3 00009 #define spi_SCK A1 00010 #define spi_MOSI A6 00011 #define spi_MISO A5 00012 00013 #define INIT '1' 00014 #define TARE '2' 00015 #define TARE_FIRST '3' 00016 #define TARE_COMPLETE '4' 00017 #define TARE_ERROR '5' 00018 #define POSITION '6' 00019 #define POSITION_WAIT '7' 00020 #define POSITION_ERROR '8' 00021 #define READ '9' 00022 #define RECEIVE 'a' 00023 #define STARTUP 'b' 00024 #define STARTUP_SUCCES 'c' 00025 #define BATTERY 'd' 00026 00027 00028 #ifdef PRINT_ENABLE 00029 #define IF_PRINT_ENABLE(x) ({x;}) 00030 #else 00031 #define IF_PRINT_ENABLE(x) 00032 #endif 00033 00034 //Identificatie verzender/ontvanger 00035 const uint16_t this_node = 01; 00036 const uint16_t other_node = 00; 00037 00038 struct payload_t { 00039 bool reedsensor; 00040 float gram; 00041 bool messageAvailable; 00042 char messageIndex; 00043 }; 00044 00045 enum State {State_init, 00046 State_tare, 00047 State_position, 00048 State_read, 00049 State_receive, 00050 State_calibrate 00051 }; 00052 00053 struct state_Packet { 00054 char setstate; 00055 }; 00056 00057 00058 class Verzender 00059 { 00060 private: 00061 00062 00063 public: 00064 Verzender(); 00065 00066 /** 00067 Update to receive a message available for this node 00068 */ 00069 void update(); 00070 00071 00072 /** 00073 Send a message to the receiver 00074 00075 @param message of type payload_t 00076 */ 00077 bool write(payload_t message); 00078 00079 00080 /** 00081 Test whether there is a message available for this node 00082 */ 00083 bool available(); 00084 00085 00086 /** 00087 Read a message to the receiver 00088 00089 @return message of type state_packet 00090 */ 00091 state_Packet read(); 00092 00093 00094 /*messageIndex: 00095 0: Nothing wrong 00096 1: Tare first 00097 2: Error on Position 00098 3: Bad Tare value (<2.5V) 00099 */ 00100 void sendMessage(char index); 00101 00102 void Verzender::printDetails(); 00103 }; 00104 00105 #endif 00106 00107 00108 00109 00110
Generated on Mon Jul 18 2022 01:26:17 by
1.7.2