Radio control: use the Jeti protocol to communicate between a DIY sensor and a Jeti receiver (using 9 bits one wire serial)
core.h@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 | #ifndef CORE_H |
robertspil | 0:32193823db59 | 2 | #define CORE_H |
robertspil | 0:32193823db59 | 3 | #include "mbed.h" |
robertspil | 0:32193823db59 | 4 | #define B_RIGHT 0xE0 |
robertspil | 0:32193823db59 | 5 | #define B_LEFT 0x70 |
robertspil | 0:32193823db59 | 6 | #define B_UP 0xD0 |
robertspil | 0:32193823db59 | 7 | #define B_DOWN 0xB0 |
robertspil | 0:32193823db59 | 8 | #define B_ERASE 0x60 |
robertspil | 0:32193823db59 | 9 | int GetTicker(); |
robertspil | 0:32193823db59 | 10 | class JetiC { // free-wheeling communication with the JetiBox |
robertspil | 0:32193823db59 | 11 | /* use : |
robertspil | 0:32193823db59 | 12 | constructor initialize a first message |
robertspil | 0:32193823db59 | 13 | loop until isAnswer()==True |
robertspil | 0:32193823db59 | 14 | process the answer : select() + display() |
robertspil | 0:32193823db59 | 15 | getSensor() |
robertspil | 0:32193823db59 | 16 | |
robertspil | 0:32193823db59 | 17 | */ |
robertspil | 0:32193823db59 | 18 | public: |
robertspil | 0:32193823db59 | 19 | JetiC(); |
robertspil | 0:32193823db59 | 20 | bool isAnswer(); //-> true after the Get from Rx ; reset when the call isAnswer() returned true |
robertspil | 0:32193823db59 | 21 | int current_node; |
robertspil | 0:32193823db59 | 22 | int buttons; //answer from the jei box buttons |
robertspil | 0:32193823db59 | 23 | //void write_buffer(); |
robertspil | 0:32193823db59 | 24 | void display(); //format the buffer for the current node and the current sensor data |
robertspil | 0:32193823db59 | 25 | void select( ); // process the answer to select a new current_node |
robertspil | 0:32193823db59 | 26 | void debug_display(); |
robertspil | 0:32193823db59 | 27 | //-----various utility functions to fill the buffer------------------------------- |
robertspil | 0:32193823db59 | 28 | void clear(); |
robertspil | 0:32193823db59 | 29 | void print(char); |
robertspil | 0:32193823db59 | 30 | void print(long value, uint8_t len); // len = total length |
robertspil | 0:32193823db59 | 31 | void printf(float value, uint8_t decimals, uint8_t len); // 2nd argument = number of decimals |
robertspil | 0:32193823db59 | 32 | void print_p(const char *); //const char * const mystrings[] = {"aaa","zzzz"}; |
robertspil | 0:32193823db59 | 33 | void setPos(int);//set the position of the "cursor" |
robertspil | 0:32193823db59 | 34 | |
robertspil | 0:32193823db59 | 35 | private: |
robertspil | 0:32193823db59 | 36 | |
robertspil | 0:32193823db59 | 37 | //Timer loop; |
robertspil | 0:32193823db59 | 38 | void printNumber( int value, uint8_t pos, uint8_t len); |
robertspil | 0:32193823db59 | 39 | int pos; |
robertspil | 0:32193823db59 | 40 | int mode; //0 = normal message 1=special sequence to quit the sensor going left through the expander |
robertspil | 0:32193823db59 | 41 | |
robertspil | 0:32193823db59 | 42 | //this class is in the file JetiC.cpp, with the interrupt routines and their specific data |
robertspil | 0:32193823db59 | 43 | }; |
robertspil | 0:32193823db59 | 44 | |
robertspil | 0:32193823db59 | 45 | // common data |
robertspil | 0:32193823db59 | 46 | struct instr_data{ |
robertspil | 0:32193823db59 | 47 | JetiC* jetiptr; //pointer to the JetiBox object..or NULL |
robertspil | 0:32193823db59 | 48 | // Sensor* sensorptr ; // pointer to the Sensor Object |
robertspil | 0:32193823db59 | 49 | |
robertspil | 0:32193823db59 | 50 | }; |
robertspil | 0:32193823db59 | 51 | #endif |
robertspil | 0:32193823db59 | 52 |