Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)
Dependencies: UniGraphic mbed vt100
18-Jun-2018 外部センサの電源オン・オフ機能は下位互換の為に無効になっていました。 この版で再度有効にしました。
edge_sensor/edge_accel.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_ACCEL_H_ |
Rhyme | 0:846e2321c637 | 2 | #define _EDGE_ACCEL_H_ |
Rhyme | 0:846e2321c637 | 3 | #include "mbed.h" |
Rhyme | 0:846e2321c637 | 4 | #include "edge_sensor.h" |
Rhyme | 0:846e2321c637 | 5 | #include "MMA8451Q.h" |
Rhyme | 0:846e2321c637 | 6 | |
Rhyme | 0:846e2321c637 | 7 | /** |
Rhyme | 0:846e2321c637 | 8 | * edge_accel edge_sensor which manage the accelerometer sensor (MMA8451Q) |
Rhyme | 0:846e2321c637 | 9 | * @note The behavior of this class is somewhat exceptional as an edge_sensor |
Rhyme | 0:846e2321c637 | 10 | * @note it samples and accumulates data which is the abs sum of current |
Rhyme | 0:846e2321c637 | 11 | * @note values and previous values every 0.1 sec |
Rhyme | 0:846e2321c637 | 12 | * @note and in each "interval" it delivers the averaged value |
Rhyme | 0:846e2321c637 | 13 | */ |
Rhyme | 0:846e2321c637 | 14 | |
Rhyme | 0:846e2321c637 | 15 | class edge_accel : public edge_sensor { |
Rhyme | 0:846e2321c637 | 16 | public: |
Rhyme | 0:846e2321c637 | 17 | /** |
Rhyme | 0:846e2321c637 | 18 | * constructor |
Rhyme | 0:846e2321c637 | 19 | * @param the MMA8451Q object |
Rhyme | 0:846e2321c637 | 20 | */ |
Rhyme | 0:846e2321c637 | 21 | edge_accel(MMA8451Q *accel) ; |
Rhyme | 0:846e2321c637 | 22 | |
Rhyme | 0:846e2321c637 | 23 | /** |
Rhyme | 0:846e2321c637 | 24 | * destructor |
Rhyme | 0:846e2321c637 | 25 | */ |
Rhyme | 0:846e2321c637 | 26 | ~edge_accel(void) ; |
Rhyme | 0:846e2321c637 | 27 | |
Rhyme | 0:846e2321c637 | 28 | /** |
Rhyme | 0:846e2321c637 | 29 | * clear and reset interval values |
Rhyme | 0:846e2321c637 | 30 | */ |
Rhyme | 0:846e2321c637 | 31 | virtual void reset(void) ; |
Rhyme | 0:846e2321c637 | 32 | // virtual void prepare(void) ; |
Rhyme | 0:846e2321c637 | 33 | |
Rhyme | 0:846e2321c637 | 34 | /** |
Rhyme | 0:846e2321c637 | 35 | * sample calculate the average value |
Rhyme | 0:846e2321c637 | 36 | * from _accumulation and _sample_count |
Rhyme | 0:846e2321c637 | 37 | * the average value is assigned to _value |
Rhyme | 0:846e2321c637 | 38 | * and currnt _sample_count is stored in _num_sampled |
Rhyme | 0:846e2321c637 | 39 | * then both _accumuation and _sample_count will be cleared |
Rhyme | 0:846e2321c637 | 40 | * @returns 0: success non-0: failure |
Rhyme | 0:846e2321c637 | 41 | */ |
Rhyme | 0:846e2321c637 | 42 | virtual int sample(void) ; |
Rhyme | 0:846e2321c637 | 43 | |
Rhyme | 0:846e2321c637 | 44 | /** |
Rhyme | 0:846e2321c637 | 45 | * deliver the value to the afero cloud |
Rhyme | 0:846e2321c637 | 46 | */ |
Rhyme | 0:846e2321c637 | 47 | virtual int deliver(void) ; |
Rhyme | 0:846e2321c637 | 48 | |
Rhyme | 0:846e2321c637 | 49 | /** |
Rhyme | 0:846e2321c637 | 50 | * show the data in the display (TFT) |
Rhyme | 0:846e2321c637 | 51 | */ |
Rhyme | 0:846e2321c637 | 52 | virtual void show(void) ; |
Rhyme | 0:846e2321c637 | 53 | |
Rhyme | 0:846e2321c637 | 54 | /** |
Rhyme | 0:846e2321c637 | 55 | * accum this is the real sampling |
Rhyme | 0:846e2321c637 | 56 | * and the differences of sampled values |
Rhyme | 0:846e2321c637 | 57 | * and previous values are calcurated and accumulated |
Rhyme | 0:846e2321c637 | 58 | * @returns 0: success non-0: failure |
Rhyme | 0:846e2321c637 | 59 | */ |
Rhyme | 0:846e2321c637 | 60 | int accum(void) ; |
Rhyme | 0:846e2321c637 | 61 | |
Rhyme | 0:846e2321c637 | 62 | /** |
Rhyme | 0:846e2321c637 | 63 | * Clear internal values |
Rhyme | 0:846e2321c637 | 64 | */ |
Rhyme | 0:846e2321c637 | 65 | void clear_value(void) ; |
Rhyme | 0:846e2321c637 | 66 | |
Rhyme | 0:846e2321c637 | 67 | private: |
Rhyme | 0:846e2321c637 | 68 | MMA8451Q *_accel ; |
Rhyme | 0:846e2321c637 | 69 | float _value ; |
Rhyme | 0:846e2321c637 | 70 | int32_t _num_sampled ; |
Rhyme | 0:846e2321c637 | 71 | int32_t _sample_count ; |
Rhyme | 0:846e2321c637 | 72 | int32_t _accumulation ; |
Rhyme | 0:846e2321c637 | 73 | int16_t _prev_x ; |
Rhyme | 0:846e2321c637 | 74 | int16_t _prev_y ; |
Rhyme | 0:846e2321c637 | 75 | int16_t _prev_z ; |
Rhyme | 0:846e2321c637 | 76 | } ; |
Rhyme | 0:846e2321c637 | 77 | |
Rhyme | 0:846e2321c637 | 78 | #endif /* _EDGE_ACCEL_H_ */ |