KBrat-SSD645-HW-8_1_MMA8451Q8
Fork of MMA8451Q8 by
Diff: MMA8451Q8.cpp
- Revision:
- 8:65da360cf088
- Parent:
- 7:7812354ef684
- Child:
- 9:1e7f9d65ad29
--- a/MMA8451Q8.cpp Wed Feb 22 15:35:47 2017 +0000 +++ b/MMA8451Q8.cpp Mon Mar 06 17:39:43 2017 +0000 @@ -48,7 +48,29 @@ readRegs(REG_WHO_AM_I, &who_am_i, 1); return who_am_i; } + +void MMA8451Q::standbyMode(void){ + byte n; + uint8_t data[2] = {REG_CTRL_REG_1, 0x00}; + n= readRegs(data, 2); + data[0] = XYZ_DATA_CFG; + data[1] = MAX_8G; + writeRegs(data, 2 , n); + +} + +void MMA8451Q::activeMode(){ + data[0] = REG_CTRL_REG_1; + data[1] = 0x01; + writeRegs(data, 2, (readRegs(data, 2))); +} + void MMA8451Q::setGLimit() { + standbyMode(); + activeMode(); +} + +/*void MMA8451Q::setGLimit() { uint8_t data[2] = {REG_CTRL_REG_1, 0x00}; writeRegs(data, 2); // put in standby data[0] = XYZ_DATA_CFG; @@ -57,7 +79,7 @@ data[0] = REG_CTRL_REG_1; data[1] = 0x01; writeRegs(data, 2); // make active -} +}*/ float MMA8451Q::getAccX() { return (float(getAccAxis(REG_OUT_X_MSB))/GSCALING);