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: UniGraphic mbed vt100
edge_sensor.h
00001 #ifndef _EDGE_SENSOR_H_ 00002 #define _EDGE_SENSOR_H_ 00003 /** 00004 * edge_sensor super class of each sensor manager class 00005 */ 00006 #include "edge_time.h" 00007 #include "afLib.h" 00008 #include "af_mgr.h" 00009 #include <ILI9341.h> 00010 #include "edge_chart.h" 00011 00012 class edge_sensor { 00013 public: 00014 /** 00015 * constructor 00016 */ 00017 edge_sensor() ; 00018 00019 /** 00020 * destructor 00021 */ 00022 ~edge_sensor() ; 00023 00024 /** 00025 * reset reset property valuse of edge_sensor 00026 */ 00027 virtual void reset(void) ; 00028 00029 /** 00030 * enable the edge_sensor 00031 */ 00032 virtual void enable(void) ; 00033 00034 /** 00035 * disable the edge_sensor 00036 */ 00037 virtual void disable(void) ; 00038 00039 /** 00040 * test if the edge_sensor is enabled (or not) 00041 * @returns true: the sensor is enabled false: the sensor is disabled 00042 */ 00043 virtual bool isEnabled(void) ; 00044 00045 /** 00046 * prepare the sensor for sampling 00047 */ 00048 virtual void prepare(void) ; 00049 00050 /** 00051 * sample trigger sampling action of the sensor and acquire the data 00052 * @returns 0:success non-0:failure 00053 */ 00054 virtual int sample(void) ; 00055 00056 00057 /** 00058 * deliver the sampled data to the afero cloud via setAttributes 00059 */ 00060 virtual int deliver(void) ; 00061 00062 /** 00063 * show the value(s) to the display (TFT) 00064 */ 00065 virtual void show(void) ; 00066 00067 /** 00068 * toJson convert sampled data to json format 00069 * @param buf char* string buf to store the json string 00070 */ 00071 virtual void toJson(char *buf) ; 00072 00073 /** 00074 * display timestamp in human readable format 00075 * @parm ts int32_t timestamp value to display 00076 */ 00077 virtual void displayTime(int32_t ts) ; 00078 00079 /** 00080 * setInterval assign sampling interval time (in sec) 00081 * @param interval uint16_t the value to assign 00082 */ 00083 void setInterval(uint16_t interval) ; 00084 00085 /** 00086 * getInterval get sampling interval time (in sec) 00087 * @returns the interval time in uint16_t 00088 */ 00089 uint16_t getInterval(void) ; 00090 00091 /** 00092 * getStatus get current status of the state machine 00093 * @returns current status as int 00094 */ 00095 int getStatus(void) ; 00096 00097 /** 00098 * advanceStatus proceed status into the next state 00099 * @returns advanced status 00100 */ 00101 int advanceStatus(void) ; 00102 00103 /** 00104 * runStateMachine run the statemachine for single cycle 00105 * @returns the result status 00106 */ 00107 virtual int runStateMachine(void) ; 00108 protected: 00109 uint16_t _id ; 00110 bool _enable ; 00111 uint32_t _interval ; 00112 int _status ; 00113 int _error_count ; 00114 int _sample_error ; 00115 int _prev_status ; 00116 uint32_t _end_interval ; 00117 uint32_t _sampled_time ; 00118 char _str_buf[256] ; 00119 } ; 00120 00121 /* may be, we had better use enum here */ 00122 #define EDGE_SENSOR_INACTIVE 0 00123 #define EDGE_SENSOR_WAIT 1 00124 #define EDGE_SENSOR_READY 2 00125 #define EDGE_SENSOR_PREPARED 3 00126 #define EDGE_SENSOR_SAMPLED 4 00127 #define EDGE_SENSOR_DELIVERED 5 00128 #define EDGE_SENSOR_DISPLAYED 6 00129 00130 /* Y position of SUMMARY MODE */ 00131 #define EDGE_SUMMARY_X 10 00132 #define EDGE_SUMMARY_TIME_Y 10 00133 #define EDGE_SUMMARY_ACCEL_Y 45 00134 #define EDGE_SUMMARY_PRESS_Y 80 00135 #define EDGE_SUMMARY_COLOR1_Y 115 00136 #define EDGE_SUMMARY_COLOR2_Y 150 00137 #define EDGE_SUMMARY_TEMP_Y 185 00138 00139 #define EDGE_SAMPLE_SUCCESS 0 00140 #define SAMPLE_ERROR_TOLERANCE 3 00141 00142 extern ILI9341 *display ; 00143 extern int display_mode ; 00144 extern const unsigned char Arial12x12[] ; 00145 extern const unsigned char Arial24x23[] ; 00146 extern const unsigned char Arial28x28[] ; 00147 00148 #endif /* _EDGE_SENSOR_H_ */
Generated on Fri Jul 15 2022 06:01:06 by
1.7.2