Release candidate version. The pointer in GAS Pressure display is changed to a triangle.
Dependencies: UniGraphic mbed vt100
Please note, at 2-Mar-2018 the current version of mbed-lib has a defect in Ticker.
https://os.mbed.com/forum/bugs-suggestions/topic/29287/
So, mbed lib version 157 is intentionally being used.
Please do not update mbed library until the problem in the above URL is fixed.
In this version, format of GAS Pressure Display has been changed.
moto
edge_sensor/edge_sensor.h@0:774324cbc5a6, 2018-03-02 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Mar 02 07:56:09 2018 +0000
- Revision:
- 0:774324cbc5a6
Release candidate version. GAS Pressure pointer is now a triangle.; Some source file clean-up was done.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:774324cbc5a6 | 1 | #ifndef _EDGE_SENSOR_H_ |
Rhyme | 0:774324cbc5a6 | 2 | #define _EDGE_SENSOR_H_ |
Rhyme | 0:774324cbc5a6 | 3 | /** |
Rhyme | 0:774324cbc5a6 | 4 | * edge_sensor super class of each sensor manager class |
Rhyme | 0:774324cbc5a6 | 5 | */ |
Rhyme | 0:774324cbc5a6 | 6 | #include "edge_time.h" |
Rhyme | 0:774324cbc5a6 | 7 | #include "afLib.h" |
Rhyme | 0:774324cbc5a6 | 8 | #include "af_mgr.h" |
Rhyme | 0:774324cbc5a6 | 9 | #include <ILI9341.h> |
Rhyme | 0:774324cbc5a6 | 10 | #include "edge_chart.h" |
Rhyme | 0:774324cbc5a6 | 11 | |
Rhyme | 0:774324cbc5a6 | 12 | class edge_sensor { |
Rhyme | 0:774324cbc5a6 | 13 | public: |
Rhyme | 0:774324cbc5a6 | 14 | /** |
Rhyme | 0:774324cbc5a6 | 15 | * constructor |
Rhyme | 0:774324cbc5a6 | 16 | */ |
Rhyme | 0:774324cbc5a6 | 17 | edge_sensor() ; |
Rhyme | 0:774324cbc5a6 | 18 | |
Rhyme | 0:774324cbc5a6 | 19 | /** |
Rhyme | 0:774324cbc5a6 | 20 | * destructor |
Rhyme | 0:774324cbc5a6 | 21 | */ |
Rhyme | 0:774324cbc5a6 | 22 | ~edge_sensor() ; |
Rhyme | 0:774324cbc5a6 | 23 | |
Rhyme | 0:774324cbc5a6 | 24 | /** |
Rhyme | 0:774324cbc5a6 | 25 | * reset reset property valuse of edge_sensor |
Rhyme | 0:774324cbc5a6 | 26 | */ |
Rhyme | 0:774324cbc5a6 | 27 | virtual void reset(void) ; |
Rhyme | 0:774324cbc5a6 | 28 | |
Rhyme | 0:774324cbc5a6 | 29 | /** |
Rhyme | 0:774324cbc5a6 | 30 | * assign _id manually |
Rhyme | 0:774324cbc5a6 | 31 | */ |
Rhyme | 0:774324cbc5a6 | 32 | virtual void setId(uint16_t id) { _id = id ; } |
Rhyme | 0:774324cbc5a6 | 33 | |
Rhyme | 0:774324cbc5a6 | 34 | virtual uint16_t getId(void) { return _id ; } |
Rhyme | 0:774324cbc5a6 | 35 | |
Rhyme | 0:774324cbc5a6 | 36 | /** |
Rhyme | 0:774324cbc5a6 | 37 | * enable the edge_sensor |
Rhyme | 0:774324cbc5a6 | 38 | */ |
Rhyme | 0:774324cbc5a6 | 39 | virtual void enable(void) ; |
Rhyme | 0:774324cbc5a6 | 40 | |
Rhyme | 0:774324cbc5a6 | 41 | /** |
Rhyme | 0:774324cbc5a6 | 42 | * disable the edge_sensor |
Rhyme | 0:774324cbc5a6 | 43 | */ |
Rhyme | 0:774324cbc5a6 | 44 | virtual void disable(void) ; |
Rhyme | 0:774324cbc5a6 | 45 | |
Rhyme | 0:774324cbc5a6 | 46 | /** |
Rhyme | 0:774324cbc5a6 | 47 | * test if the edge_sensor is enabled (or not) |
Rhyme | 0:774324cbc5a6 | 48 | * @returns true: the sensor is enabled false: the sensor is disabled |
Rhyme | 0:774324cbc5a6 | 49 | */ |
Rhyme | 0:774324cbc5a6 | 50 | virtual bool isEnabled(void) ; |
Rhyme | 0:774324cbc5a6 | 51 | |
Rhyme | 0:774324cbc5a6 | 52 | /** |
Rhyme | 0:774324cbc5a6 | 53 | * prepare the sensor for sampling |
Rhyme | 0:774324cbc5a6 | 54 | */ |
Rhyme | 0:774324cbc5a6 | 55 | virtual void prepare(void) ; |
Rhyme | 0:774324cbc5a6 | 56 | |
Rhyme | 0:774324cbc5a6 | 57 | /** |
Rhyme | 0:774324cbc5a6 | 58 | * sample trigger sampling action of the sensor and acquire the data |
Rhyme | 0:774324cbc5a6 | 59 | * @returns 0:success non-0:failure |
Rhyme | 0:774324cbc5a6 | 60 | */ |
Rhyme | 0:774324cbc5a6 | 61 | virtual int sample(void) ; |
Rhyme | 0:774324cbc5a6 | 62 | |
Rhyme | 0:774324cbc5a6 | 63 | |
Rhyme | 0:774324cbc5a6 | 64 | /** |
Rhyme | 0:774324cbc5a6 | 65 | * deliver the sampled data to the afero cloud via setAttributes |
Rhyme | 0:774324cbc5a6 | 66 | */ |
Rhyme | 0:774324cbc5a6 | 67 | virtual int deliver(void) ; |
Rhyme | 0:774324cbc5a6 | 68 | |
Rhyme | 0:774324cbc5a6 | 69 | /** |
Rhyme | 0:774324cbc5a6 | 70 | * show the value(s) to the display (TFT) |
Rhyme | 0:774324cbc5a6 | 71 | */ |
Rhyme | 0:774324cbc5a6 | 72 | virtual void show(void) ; |
Rhyme | 0:774324cbc5a6 | 73 | |
Rhyme | 0:774324cbc5a6 | 74 | /** |
Rhyme | 0:774324cbc5a6 | 75 | * toJson convert sampled data to json format |
Rhyme | 0:774324cbc5a6 | 76 | * @param buf char* string buf to store the json string |
Rhyme | 0:774324cbc5a6 | 77 | */ |
Rhyme | 0:774324cbc5a6 | 78 | virtual void toJson(char *buf) ; |
Rhyme | 0:774324cbc5a6 | 79 | |
Rhyme | 0:774324cbc5a6 | 80 | /** |
Rhyme | 0:774324cbc5a6 | 81 | * display timestamp in human readable format |
Rhyme | 0:774324cbc5a6 | 82 | * @parm ts int32_t timestamp value to display |
Rhyme | 0:774324cbc5a6 | 83 | */ |
Rhyme | 0:774324cbc5a6 | 84 | virtual void displayTime(int32_t ts) ; |
Rhyme | 0:774324cbc5a6 | 85 | |
Rhyme | 0:774324cbc5a6 | 86 | /** |
Rhyme | 0:774324cbc5a6 | 87 | * setInterval assign sampling interval time (in sec) |
Rhyme | 0:774324cbc5a6 | 88 | * @param interval uint16_t the value to assign |
Rhyme | 0:774324cbc5a6 | 89 | */ |
Rhyme | 0:774324cbc5a6 | 90 | void setInterval(uint16_t interval) ; |
Rhyme | 0:774324cbc5a6 | 91 | |
Rhyme | 0:774324cbc5a6 | 92 | /** |
Rhyme | 0:774324cbc5a6 | 93 | * getInterval get sampling interval time (in sec) |
Rhyme | 0:774324cbc5a6 | 94 | * @returns the interval time in uint16_t |
Rhyme | 0:774324cbc5a6 | 95 | */ |
Rhyme | 0:774324cbc5a6 | 96 | uint16_t getInterval(void) ; |
Rhyme | 0:774324cbc5a6 | 97 | |
Rhyme | 0:774324cbc5a6 | 98 | /** |
Rhyme | 0:774324cbc5a6 | 99 | * getStatus get current status of the state machine |
Rhyme | 0:774324cbc5a6 | 100 | * @returns current status as int |
Rhyme | 0:774324cbc5a6 | 101 | */ |
Rhyme | 0:774324cbc5a6 | 102 | int getStatus(void) ; |
Rhyme | 0:774324cbc5a6 | 103 | |
Rhyme | 0:774324cbc5a6 | 104 | /** |
Rhyme | 0:774324cbc5a6 | 105 | * advanceStatus proceed status into the next state |
Rhyme | 0:774324cbc5a6 | 106 | * @returns advanced status |
Rhyme | 0:774324cbc5a6 | 107 | */ |
Rhyme | 0:774324cbc5a6 | 108 | int advanceStatus(void) ; |
Rhyme | 0:774324cbc5a6 | 109 | |
Rhyme | 0:774324cbc5a6 | 110 | /** |
Rhyme | 0:774324cbc5a6 | 111 | * runStateMachine run the statemachine for single cycle |
Rhyme | 0:774324cbc5a6 | 112 | * @returns the result status |
Rhyme | 0:774324cbc5a6 | 113 | */ |
Rhyme | 0:774324cbc5a6 | 114 | virtual int runStateMachine(void) ; |
Rhyme | 0:774324cbc5a6 | 115 | protected: |
Rhyme | 0:774324cbc5a6 | 116 | uint16_t _id ; |
Rhyme | 0:774324cbc5a6 | 117 | bool _enable ; |
Rhyme | 0:774324cbc5a6 | 118 | uint32_t _interval ; |
Rhyme | 0:774324cbc5a6 | 119 | int _status ; |
Rhyme | 0:774324cbc5a6 | 120 | int _error_count ; |
Rhyme | 0:774324cbc5a6 | 121 | int _sample_error ; |
Rhyme | 0:774324cbc5a6 | 122 | int _prev_status ; |
Rhyme | 0:774324cbc5a6 | 123 | uint32_t _end_interval ; |
Rhyme | 0:774324cbc5a6 | 124 | uint32_t _sampled_time ; |
Rhyme | 0:774324cbc5a6 | 125 | char _str_buf[256] ; |
Rhyme | 0:774324cbc5a6 | 126 | } ; |
Rhyme | 0:774324cbc5a6 | 127 | |
Rhyme | 0:774324cbc5a6 | 128 | /* may be, we had better use enum here */ |
Rhyme | 0:774324cbc5a6 | 129 | #define EDGE_SENSOR_INACTIVE 0 |
Rhyme | 0:774324cbc5a6 | 130 | #define EDGE_SENSOR_WAIT 1 |
Rhyme | 0:774324cbc5a6 | 131 | #define EDGE_SENSOR_READY 2 |
Rhyme | 0:774324cbc5a6 | 132 | #define EDGE_SENSOR_PREPARED 3 |
Rhyme | 0:774324cbc5a6 | 133 | #define EDGE_SENSOR_SAMPLED 4 |
Rhyme | 0:774324cbc5a6 | 134 | #define EDGE_SENSOR_DELIVERED 5 |
Rhyme | 0:774324cbc5a6 | 135 | #define EDGE_SENSOR_DISPLAYED 6 |
Rhyme | 0:774324cbc5a6 | 136 | |
Rhyme | 0:774324cbc5a6 | 137 | /* _id numbers for sensors */ |
Rhyme | 0:774324cbc5a6 | 138 | #define SENSOR_ID_ACCEL 0 |
Rhyme | 0:774324cbc5a6 | 139 | #define SENSOR_ID_COLOR1 1 |
Rhyme | 0:774324cbc5a6 | 140 | #define SENSOR_ID_COLOR2 2 |
Rhyme | 0:774324cbc5a6 | 141 | #define SENSOR_ID_TEMP 3 |
Rhyme | 0:774324cbc5a6 | 142 | #define SENSOR_ID_PRESS 4 |
Rhyme | 0:774324cbc5a6 | 143 | |
Rhyme | 0:774324cbc5a6 | 144 | /* Y position of SUMMARY MODE */ |
Rhyme | 0:774324cbc5a6 | 145 | #define EDGE_SUMMARY_X 10 |
Rhyme | 0:774324cbc5a6 | 146 | #define EDGE_SUMMARY_TIME_Y 10 |
Rhyme | 0:774324cbc5a6 | 147 | #define EDGE_SUMMARY_ACCEL_Y 45 |
Rhyme | 0:774324cbc5a6 | 148 | #define EDGE_SUMMARY_PRESS_Y 80 |
Rhyme | 0:774324cbc5a6 | 149 | #define EDGE_SUMMARY_COLOR1_Y 115 |
Rhyme | 0:774324cbc5a6 | 150 | #define EDGE_SUMMARY_COLOR2_Y 150 |
Rhyme | 0:774324cbc5a6 | 151 | #define EDGE_SUMMARY_TEMP_Y 185 |
Rhyme | 0:774324cbc5a6 | 152 | |
Rhyme | 0:774324cbc5a6 | 153 | #define EDGE_SAMPLE_SUCCESS 0 |
Rhyme | 0:774324cbc5a6 | 154 | #define SAMPLE_ERROR_TOLERANCE 3 |
Rhyme | 0:774324cbc5a6 | 155 | |
Rhyme | 0:774324cbc5a6 | 156 | extern ILI9341 *display ; |
Rhyme | 0:774324cbc5a6 | 157 | extern int display_mode ; |
Rhyme | 0:774324cbc5a6 | 158 | extern const unsigned char Arial12x12[] ; |
Rhyme | 0:774324cbc5a6 | 159 | extern const unsigned char Arial24x23[] ; |
Rhyme | 0:774324cbc5a6 | 160 | extern const unsigned char Arial28x28[] ; |
Rhyme | 0:774324cbc5a6 | 161 | |
Rhyme | 0:774324cbc5a6 | 162 | #endif /* _EDGE_SENSOR_H_ */ |