Color sensor reset at the end of calibration added. sensor id auto assignment was changed to be a fixed value assignment to avoid sensor id shift when some sensor is absent.
Dependencies: UniGraphic mbed vt100
edge_sensor/edge_accel.h@0:ce97f6d34336, 2018-02-23 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Feb 23 05:40:22 2018 +0000
- Revision:
- 0:ce97f6d34336
color sensor reset was added at the end of calibration
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:ce97f6d34336 | 1 | #ifndef _EDGE_ACCEL_H_ |
Rhyme | 0:ce97f6d34336 | 2 | #define _EDGE_ACCEL_H_ |
Rhyme | 0:ce97f6d34336 | 3 | #include "mbed.h" |
Rhyme | 0:ce97f6d34336 | 4 | #include "edge_sensor.h" |
Rhyme | 0:ce97f6d34336 | 5 | #include "MMA8451Q.h" |
Rhyme | 0:ce97f6d34336 | 6 | |
Rhyme | 0:ce97f6d34336 | 7 | /** |
Rhyme | 0:ce97f6d34336 | 8 | * edge_accel edge_sensor which manage the accelerometer sensor (MMA8451Q) |
Rhyme | 0:ce97f6d34336 | 9 | * @note The behavior of this class is somewhat exceptional as an edge_sensor |
Rhyme | 0:ce97f6d34336 | 10 | * @note it samples and accumulates data which is the abs sum of current |
Rhyme | 0:ce97f6d34336 | 11 | * @note values and previous values every 0.1 sec |
Rhyme | 0:ce97f6d34336 | 12 | * @note and in each "interval" it delivers the averaged value |
Rhyme | 0:ce97f6d34336 | 13 | */ |
Rhyme | 0:ce97f6d34336 | 14 | |
Rhyme | 0:ce97f6d34336 | 15 | class edge_accel : public edge_sensor { |
Rhyme | 0:ce97f6d34336 | 16 | public: |
Rhyme | 0:ce97f6d34336 | 17 | /** |
Rhyme | 0:ce97f6d34336 | 18 | * constructor |
Rhyme | 0:ce97f6d34336 | 19 | * @param the MMA8451Q object |
Rhyme | 0:ce97f6d34336 | 20 | */ |
Rhyme | 0:ce97f6d34336 | 21 | edge_accel(MMA8451Q *accel) ; |
Rhyme | 0:ce97f6d34336 | 22 | |
Rhyme | 0:ce97f6d34336 | 23 | /** |
Rhyme | 0:ce97f6d34336 | 24 | * destructor |
Rhyme | 0:ce97f6d34336 | 25 | */ |
Rhyme | 0:ce97f6d34336 | 26 | ~edge_accel(void) ; |
Rhyme | 0:ce97f6d34336 | 27 | |
Rhyme | 0:ce97f6d34336 | 28 | /** |
Rhyme | 0:ce97f6d34336 | 29 | * clear and reset interval values |
Rhyme | 0:ce97f6d34336 | 30 | */ |
Rhyme | 0:ce97f6d34336 | 31 | virtual void reset(void) ; |
Rhyme | 0:ce97f6d34336 | 32 | // virtual void prepare(void) ; |
Rhyme | 0:ce97f6d34336 | 33 | |
Rhyme | 0:ce97f6d34336 | 34 | /** |
Rhyme | 0:ce97f6d34336 | 35 | * sample calculate the average value |
Rhyme | 0:ce97f6d34336 | 36 | * from _accumulation and _sample_count |
Rhyme | 0:ce97f6d34336 | 37 | * the average value is assigned to _value |
Rhyme | 0:ce97f6d34336 | 38 | * and currnt _sample_count is stored in _num_sampled |
Rhyme | 0:ce97f6d34336 | 39 | * then both _accumuation and _sample_count will be cleared |
Rhyme | 0:ce97f6d34336 | 40 | * @returns 0: success non-0: failure |
Rhyme | 0:ce97f6d34336 | 41 | */ |
Rhyme | 0:ce97f6d34336 | 42 | virtual int sample(void) ; |
Rhyme | 0:ce97f6d34336 | 43 | |
Rhyme | 0:ce97f6d34336 | 44 | /** |
Rhyme | 0:ce97f6d34336 | 45 | * deliver the value to the afero cloud |
Rhyme | 0:ce97f6d34336 | 46 | */ |
Rhyme | 0:ce97f6d34336 | 47 | virtual int deliver(void) ; |
Rhyme | 0:ce97f6d34336 | 48 | |
Rhyme | 0:ce97f6d34336 | 49 | /** |
Rhyme | 0:ce97f6d34336 | 50 | * show the data in the display (TFT) |
Rhyme | 0:ce97f6d34336 | 51 | */ |
Rhyme | 0:ce97f6d34336 | 52 | virtual void show(void) ; |
Rhyme | 0:ce97f6d34336 | 53 | |
Rhyme | 0:ce97f6d34336 | 54 | /** |
Rhyme | 0:ce97f6d34336 | 55 | * accum this is the real sampling |
Rhyme | 0:ce97f6d34336 | 56 | * and the differences of sampled values |
Rhyme | 0:ce97f6d34336 | 57 | * and previous values are calcurated and accumulated |
Rhyme | 0:ce97f6d34336 | 58 | * @returns 0: success non-0: failure |
Rhyme | 0:ce97f6d34336 | 59 | */ |
Rhyme | 0:ce97f6d34336 | 60 | int accum(void) ; |
Rhyme | 0:ce97f6d34336 | 61 | |
Rhyme | 0:ce97f6d34336 | 62 | /** |
Rhyme | 0:ce97f6d34336 | 63 | * Clear internal values |
Rhyme | 0:ce97f6d34336 | 64 | */ |
Rhyme | 0:ce97f6d34336 | 65 | void clear_value(void) ; |
Rhyme | 0:ce97f6d34336 | 66 | |
Rhyme | 0:ce97f6d34336 | 67 | private: |
Rhyme | 0:ce97f6d34336 | 68 | MMA8451Q *_accel ; |
Rhyme | 0:ce97f6d34336 | 69 | float _value ; |
Rhyme | 0:ce97f6d34336 | 70 | int32_t _num_sampled ; |
Rhyme | 0:ce97f6d34336 | 71 | int32_t _sample_count ; |
Rhyme | 0:ce97f6d34336 | 72 | int32_t _accumulation ; |
Rhyme | 0:ce97f6d34336 | 73 | int16_t _prev_x ; |
Rhyme | 0:ce97f6d34336 | 74 | int16_t _prev_y ; |
Rhyme | 0:ce97f6d34336 | 75 | int16_t _prev_z ; |
Rhyme | 0:ce97f6d34336 | 76 | } ; |
Rhyme | 0:ce97f6d34336 | 77 | |
Rhyme | 0:ce97f6d34336 | 78 | #endif /* _EDGE_ACCEL_H_ */ |