MMA8451Q8g
Fork of MMA8451Q8b by
Diff: MMA8451Q8g.cpp
- Revision:
- 13:b58b302c53f6
- Parent:
- 12:12b18fdb72f7
--- a/MMA8451Q8g.cpp Mon Feb 22 16:54:40 2016 +0000 +++ b/MMA8451Q8g.cpp Wed Mar 15 16:48:06 2017 +0000 @@ -17,7 +17,7 @@ */ // Modify to change full scale gravity range 141207 sc - +#include "mbed.h" #include "MMA8451Q8g.h" #define REG_WHO_AM_I 0x0D @@ -41,6 +41,9 @@ #define ADDRESS_INDEX 0 #define DATA_INDEX 1 +Serial coolt(USBTX, USBRX); + + float gScaling[3] = {4095.0,2048.0,1024.0}; //scaling for acceleration of gravity values MMA8451Q::MMA8451Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) { @@ -56,6 +59,7 @@ readRegs(REG_WHO_AM_I, &who_am_i, 1); return who_am_i; } + void MMA8451Q::setStandbyMode(){ #define ACTIVEMASK 0x01 uint8_t registerData[1]; @@ -71,12 +75,16 @@ uint8_t data[NUM_DATA] = {REG_CTRL_REG_1, 0x00}; readRegs(REG_CTRL_REG_1, registerData, 1); + //coolt.printf("REG_CTRL_1: 0x%2x\r\n", REG_CTRL_REG_1); data[1] = registerData[0] | ACTIVEMASK; writeRegs(data, NUM_DATA); // put in standby } + + void MMA8451Q::setGLimit(int gSelect) { uint8_t data[NUM_DATA] = {REG_CTRL_REG_1, 0x00}; + coolt.printf("REG_CTRL_1: 0x%2x\r\n", REG_CTRL_REG_1); gChosen = gSelect; setStandbyMode(); data[ADDRESS_INDEX ] = XYZ_DATA_CFG; @@ -97,6 +105,15 @@ setActiveMode(); // make active } +/*void MMA8451Q::setPulseThreshold ( int axisSelect, int threshold);{ +} + +void MMA8451Q::setPulseTimeLimit (int timeLimit);{ +} + +void MMA8451Q:: setPulseLatency(int latencyTime); { +}*/ + // Make a genric register updater for those commands that need to put the // accelerometer in standby mode void MMA8451Q::setRegisterInStandby(uint8_t regAddress,uint8_t regData) {