Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)
Dependencies: UniGraphic mbed vt100
18-Jun-2018 外部センサの電源オン・オフ機能は下位互換の為に無効になっていました。 この版で再度有効にしました。
edge_sensor/edge_pressure.h@1:8d65cfc3a2e2, 2018-06-18 (annotated)
- Committer:
- Rhyme
- Date:
- Mon Jun 18 01:56:00 2018 +0000
- Revision:
- 1:8d65cfc3a2e2
- Parent:
- 0:846e2321c637
External sensor power on/off function enabled. (Previously disabled)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:846e2321c637 | 1 | #ifndef _EDGE_PRESSURE_H_ |
Rhyme | 0:846e2321c637 | 2 | #define _EDGE_PRESSURE_H_ |
Rhyme | 0:846e2321c637 | 3 | #include "mbed.h" |
Rhyme | 0:846e2321c637 | 4 | #include "edge_sensor.h" |
Rhyme | 0:846e2321c637 | 5 | #include "PSE530.h" |
Rhyme | 0:846e2321c637 | 6 | |
Rhyme | 0:846e2321c637 | 7 | /** |
Rhyme | 0:846e2321c637 | 8 | * edge_pressure edge_sensor for measuring gas presssure |
Rhyme | 0:846e2321c637 | 9 | */ |
Rhyme | 0:846e2321c637 | 10 | |
Rhyme | 0:846e2321c637 | 11 | class edge_pressure : public edge_sensor { |
Rhyme | 0:846e2321c637 | 12 | public: |
Rhyme | 0:846e2321c637 | 13 | /** |
Rhyme | 0:846e2321c637 | 14 | * constructor |
Rhyme | 0:846e2321c637 | 15 | * @param *pse PSE530 pressure sensor object |
Rhyme | 0:846e2321c637 | 16 | */ |
Rhyme | 0:846e2321c637 | 17 | edge_pressure(PSE530 *pse, DigitalOut *en) ; |
Rhyme | 0:846e2321c637 | 18 | |
Rhyme | 0:846e2321c637 | 19 | /** |
Rhyme | 0:846e2321c637 | 20 | * destructor |
Rhyme | 0:846e2321c637 | 21 | */ |
Rhyme | 0:846e2321c637 | 22 | ~edge_pressure(void) ; |
Rhyme | 0:846e2321c637 | 23 | |
Rhyme | 0:846e2321c637 | 24 | /** |
Rhyme | 0:846e2321c637 | 25 | * reset and clear internal values |
Rhyme | 0:846e2321c637 | 26 | */ |
Rhyme | 0:846e2321c637 | 27 | virtual void reset(void) ; |
Rhyme | 0:846e2321c637 | 28 | |
Rhyme | 0:846e2321c637 | 29 | /** |
Rhyme | 0:846e2321c637 | 30 | * prepare for sampling (not used) |
Rhyme | 0:846e2321c637 | 31 | */ |
Rhyme | 0:846e2321c637 | 32 | virtual void prepare(void) ; |
Rhyme | 0:846e2321c637 | 33 | |
Rhyme | 0:846e2321c637 | 34 | /** |
Rhyme | 0:846e2321c637 | 35 | * sample the value |
Rhyme | 0:846e2321c637 | 36 | * @returns 0: success non-0: failure |
Rhyme | 0:846e2321c637 | 37 | */ |
Rhyme | 0:846e2321c637 | 38 | virtual int sample(void) ; |
Rhyme | 0:846e2321c637 | 39 | |
Rhyme | 0:846e2321c637 | 40 | /** |
Rhyme | 0:846e2321c637 | 41 | * deliver the sampled value to afero cloud |
Rhyme | 0:846e2321c637 | 42 | */ |
Rhyme | 0:846e2321c637 | 43 | virtual int deliver(void) ; |
Rhyme | 0:846e2321c637 | 44 | |
Rhyme | 0:846e2321c637 | 45 | /** |
Rhyme | 0:846e2321c637 | 46 | * show the value in the display (TFT) |
Rhyme | 0:846e2321c637 | 47 | */ |
Rhyme | 0:846e2321c637 | 48 | virtual void show(void) ; |
Rhyme | 0:846e2321c637 | 49 | // virtual void send_config(void) ; /* send config data to cloud */ |
Rhyme | 0:846e2321c637 | 50 | // virtual void recv_config(void) ; /* receive config data from cloud */ |
Rhyme | 0:846e2321c637 | 51 | |
Rhyme | 0:846e2321c637 | 52 | /** |
Rhyme | 0:846e2321c637 | 53 | * get_value sample sensor value and calcurate it to the metric value |
Rhyme | 0:846e2321c637 | 54 | * @returns measured value in kgf/cm2 |
Rhyme | 0:846e2321c637 | 55 | */ |
Rhyme | 0:846e2321c637 | 56 | float get_value(void) ; |
Rhyme | 0:846e2321c637 | 57 | |
Rhyme | 0:846e2321c637 | 58 | /** |
Rhyme | 0:846e2321c637 | 59 | * Set threshold mode |
Rhyme | 0:846e2321c637 | 60 | * @param mode int 0: absolute value 1: relative value in percent |
Rhyme | 0:846e2321c637 | 61 | */ |
Rhyme | 0:846e2321c637 | 62 | void set_thr_mode(int mode) { _thr_mode = mode ; } |
Rhyme | 0:846e2321c637 | 63 | |
Rhyme | 0:846e2321c637 | 64 | /** |
Rhyme | 0:846e2321c637 | 65 | * Get threshold mode |
Rhyme | 0:846e2321c637 | 66 | * @returns the mode 0: absolute value 1: relative value in percent |
Rhyme | 0:846e2321c637 | 67 | */ |
Rhyme | 0:846e2321c637 | 68 | int get_thr_mode(void) { return _thr_mode ; } |
Rhyme | 0:846e2321c637 | 69 | |
Rhyme | 0:846e2321c637 | 70 | /** |
Rhyme | 0:846e2321c637 | 71 | * Set higher threshold |
Rhyme | 0:846e2321c637 | 72 | * @param thr_high int16_t the higher threshold |
Rhyme | 0:846e2321c637 | 73 | */ |
Rhyme | 0:846e2321c637 | 74 | void set_thr_high(int16_t thr_high) ; |
Rhyme | 0:846e2321c637 | 75 | |
Rhyme | 0:846e2321c637 | 76 | /** |
Rhyme | 0:846e2321c637 | 77 | * Get higher threshold, the value is calcurated with expected value |
Rhyme | 0:846e2321c637 | 78 | * @param expected float the expected pressure value for current temperature |
Rhyme | 0:846e2321c637 | 79 | */ |
Rhyme | 0:846e2321c637 | 80 | float get_thr_high(float expected) ; |
Rhyme | 0:846e2321c637 | 81 | |
Rhyme | 0:846e2321c637 | 82 | /** |
Rhyme | 0:846e2321c637 | 83 | * Set lower threshold |
Rhyme | 0:846e2321c637 | 84 | * @param thr_low int16_t the lower threshold |
Rhyme | 0:846e2321c637 | 85 | */ |
Rhyme | 0:846e2321c637 | 86 | void set_thr_low(int16_t thr_low) ; |
Rhyme | 0:846e2321c637 | 87 | |
Rhyme | 0:846e2321c637 | 88 | /** |
Rhyme | 0:846e2321c637 | 89 | * Get lower threshold, the value is calcurated with expected value |
Rhyme | 0:846e2321c637 | 90 | * @param expected float the expected pressure value for current temperature |
Rhyme | 0:846e2321c637 | 91 | */ |
Rhyme | 0:846e2321c637 | 92 | float get_thr_low(float expected) ; |
Rhyme | 0:846e2321c637 | 93 | |
Rhyme | 0:846e2321c637 | 94 | /** |
Rhyme | 0:846e2321c637 | 95 | * draw triangle pointer for GAS pressure mode display |
Rhyme | 0:846e2321c637 | 96 | */ |
Rhyme | 0:846e2321c637 | 97 | |
Rhyme | 0:846e2321c637 | 98 | void drawPointer(int c) ; |
Rhyme | 0:846e2321c637 | 99 | |
Rhyme | 0:846e2321c637 | 100 | private: |
Rhyme | 0:846e2321c637 | 101 | PSE530 *_pse ; |
Rhyme | 0:846e2321c637 | 102 | DigitalOut *_en ; |
Rhyme | 0:846e2321c637 | 103 | float _value ; |
Rhyme | 0:846e2321c637 | 104 | float _thr_high ; |
Rhyme | 0:846e2321c637 | 105 | float _thr_low ; |
Rhyme | 0:846e2321c637 | 106 | int _thr_mode ; |
Rhyme | 0:846e2321c637 | 107 | float _expected ; |
Rhyme | 0:846e2321c637 | 108 | float _higher ; |
Rhyme | 0:846e2321c637 | 109 | float _lower ; |
Rhyme | 0:846e2321c637 | 110 | } ; |
Rhyme | 0:846e2321c637 | 111 | |
Rhyme | 0:846e2321c637 | 112 | float temp2expected(float temp) ; |
Rhyme | 0:846e2321c637 | 113 | extern float *current_temp ; |
Rhyme | 0:846e2321c637 | 114 | |
Rhyme | 0:846e2321c637 | 115 | #endif /* _EDGE_PRESSURE_H_ */ |