Radio control: use the Jeti protocol to communicate between a DIY sensor and a Jeti receiver (using 9 bits one wire serial)
main.cpp@0:32193823db59, 2013-10-29 (annotated)
- Committer:
- robertspil
- Date:
- Tue Oct 29 19:39:38 2013 +0000
- Revision:
- 0:32193823db59
Initial release -tested with 1768 and 11U34
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robertspil | 0:32193823db59 | 1 | /* main program to communicate between a sensor and a Jeti Duplex receiver |
robertspil | 0:32193823db59 | 2 | Sensor assembly = pcb with processor and sensors |
robertspil | 0:32193823db59 | 3 | processor MBED lpc1768 or LPC11u34 |
robertspil | 0:32193823db59 | 4 | |
robertspil | 0:32193823db59 | 5 | Organization of the program files |
robertspil | 0:32193823db59 | 6 | main.cpp = main program - add here the s |
robertspil | 0:32193823db59 | 7 | core.h = main header file |
robertspil | 0:32193823db59 | 8 | JetiC.cpp = serial communication with jeti |
robertspil | 0:32193823db59 | 9 | |
robertspil | 0:32193823db59 | 10 | depending on the sensors |
robertspil | 0:32193823db59 | 11 | JetiMenu.cpp = Jeti Box menu for the sensor assembly |
robertspil | 0:32193823db59 | 12 | Sensor.h Sensor.cpp = read the physical sensors and compute the measures |
robertspil | 0:32193823db59 | 13 | libraries , provided by external sources, the internet community.. |
robertspil | 0:32193823db59 | 14 | one library for each sensor |
robertspil | 0:32193823db59 | 15 | |
robertspil | 0:32193823db59 | 16 | */ |
robertspil | 0:32193823db59 | 17 | #include "core.h" |
robertspil | 0:32193823db59 | 18 | #include <new> //needed for the nothrow |
robertspil | 0:32193823db59 | 19 | struct instr_data rc; //common sensor data |
robertspil | 0:32193823db59 | 20 | void init() { |
robertspil | 0:32193823db59 | 21 | rc.jetiptr = new(nothrow) JetiC(); // initialize and start the messages to the JetiBox |
robertspil | 0:32193823db59 | 22 | //rc.sensorptr = new(nothrow) Sensor(); |
robertspil | 0:32193823db59 | 23 | |
robertspil | 0:32193823db59 | 24 | } |
robertspil | 0:32193823db59 | 25 | |
robertspil | 0:32193823db59 | 26 | int main() { |
robertspil | 0:32193823db59 | 27 | init(); |
robertspil | 0:32193823db59 | 28 | while(true) { //vey simple scheduler for the sensors |
robertspil | 0:32193823db59 | 29 | if (rc.jetiptr->isAnswer()){ //process the answer from the JetiBox |
robertspil | 0:32193823db59 | 30 | //add here the code to read the sensors |
robertspil | 0:32193823db59 | 31 | //rc.jetiptr->select(); // process the answer code and/or choose a node |
robertspil | 0:32193823db59 | 32 | //rc.jetiptr->display(); //prepare the message for this node |
robertspil | 0:32193823db59 | 33 | rc.jetiptr->debug_display(); //replace the select / display above with a simple debug without any sensor |
robertspil | 0:32193823db59 | 34 | } |
robertspil | 0:32193823db59 | 35 | } |
robertspil | 0:32193823db59 | 36 | } |