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
sensors/MMA8451Q.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 _MMA8451Q_H_ |
Rhyme | 0:ce97f6d34336 | 2 | #define _MMA8451Q_H_ |
Rhyme | 0:ce97f6d34336 | 3 | |
Rhyme | 0:ce97f6d34336 | 4 | #include "mbed.h" |
Rhyme | 0:ce97f6d34336 | 5 | /** |
Rhyme | 0:ce97f6d34336 | 6 | * MMA8451Q 3-Axis, 14-bit/8-bit Digital Accelerometer |
Rhyme | 0:ce97f6d34336 | 7 | */ |
Rhyme | 0:ce97f6d34336 | 8 | |
Rhyme | 0:ce97f6d34336 | 9 | class MMA8451Q { |
Rhyme | 0:ce97f6d34336 | 10 | public: |
Rhyme | 0:ce97f6d34336 | 11 | /** |
Rhyme | 0:ce97f6d34336 | 12 | * MMA8451Q constructor |
Rhyme | 0:ce97f6d34336 | 13 | * |
Rhyme | 0:ce97f6d34336 | 14 | * @param i2c pointer to the I2C object |
Rhyme | 0:ce97f6d34336 | 15 | * @param addr 7bit addr of the I2C peripheral |
Rhyme | 0:ce97f6d34336 | 16 | */ |
Rhyme | 0:ce97f6d34336 | 17 | MMA8451Q(I2C *i2c, int addr); |
Rhyme | 0:ce97f6d34336 | 18 | |
Rhyme | 0:ce97f6d34336 | 19 | /** |
Rhyme | 0:ce97f6d34336 | 20 | * MMA8451Q destructor |
Rhyme | 0:ce97f6d34336 | 21 | */ |
Rhyme | 0:ce97f6d34336 | 22 | ~MMA8451Q(); |
Rhyme | 0:ce97f6d34336 | 23 | |
Rhyme | 0:ce97f6d34336 | 24 | /** |
Rhyme | 0:ce97f6d34336 | 25 | * get all x, y, z data as int16_t |
Rhyme | 0:ce97f6d34336 | 26 | * @param data[] three int16_t data will be returned |
Rhyme | 0:ce97f6d34336 | 27 | * @returns I2C status 0: success others: I2C error |
Rhyme | 0:ce97f6d34336 | 28 | */ |
Rhyme | 0:ce97f6d34336 | 29 | int getAllRawData(int16_t data[]) ; |
Rhyme | 0:ce97f6d34336 | 30 | |
Rhyme | 0:ce97f6d34336 | 31 | /** |
Rhyme | 0:ce97f6d34336 | 32 | * get all x, y, z data as float |
Rhyme | 0:ce97f6d34336 | 33 | * @param data three float data will be returned |
Rhyme | 0:ce97f6d34336 | 34 | * @returns I2C status 0: success others: I2C error |
Rhyme | 0:ce97f6d34336 | 35 | */ |
Rhyme | 0:ce97f6d34336 | 36 | int getAllData(float value[]) ; |
Rhyme | 0:ce97f6d34336 | 37 | int16_t getRawData(uint8_t addr) ; |
Rhyme | 0:ce97f6d34336 | 38 | int16_t getRawX(void) ; |
Rhyme | 0:ce97f6d34336 | 39 | int16_t getRawY(void) ; |
Rhyme | 0:ce97f6d34336 | 40 | int16_t getRawZ(void) ; |
Rhyme | 0:ce97f6d34336 | 41 | |
Rhyme | 0:ce97f6d34336 | 42 | float getAccX(void) ; |
Rhyme | 0:ce97f6d34336 | 43 | float getAccY(void) ; |
Rhyme | 0:ce97f6d34336 | 44 | float getAccZ(void) ; |
Rhyme | 0:ce97f6d34336 | 45 | |
Rhyme | 0:ce97f6d34336 | 46 | private: |
Rhyme | 0:ce97f6d34336 | 47 | I2C *p_i2c; |
Rhyme | 0:ce97f6d34336 | 48 | int m_addr; |
Rhyme | 0:ce97f6d34336 | 49 | int readRegs(int addr, uint8_t * data, int len); |
Rhyme | 0:ce97f6d34336 | 50 | int writeRegs(uint8_t * data, int len); |
Rhyme | 0:ce97f6d34336 | 51 | } ; |
Rhyme | 0:ce97f6d34336 | 52 | |
Rhyme | 0:ce97f6d34336 | 53 | #endif /* _MMA8451Q_H_ */ |