The whole program
Dependencies: MMA8451Q8 SLCD mbed
Fork of KL46z_single_tap_empty by
Diff: main.cpp
- Revision:
- 4:d75c7e69796b
- Parent:
- 3:53d47a5dbb2c
--- a/main.cpp Tue Feb 03 18:05:52 2015 +0000 +++ b/main.cpp Mon Feb 09 18:19:28 2015 +0000 @@ -18,6 +18,14 @@ #define REG_PULSE_SRC 0x22 #define REG_PULSE_CFG 0x21 +#define REG_PULSE_THSX 0x23 +#define REG_PULSE_THSY 0x24 +#define REG_PULSE_THSZ 0x25 +#define REG_PULSE_TMLT 0x26 +#define REG_PULSE_LTCY 0x27 +#define REG_PULSE_WIND 0x28 + + #define MAX_2G 0x00 #define MAX_4G 0x01 #define MAX_8G 0x02 @@ -41,13 +49,15 @@ DigitalOut myled(LED_RED); // red led DigitalOut relay(LED_GREEN); // green led - MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); +MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); float delay = WAITDELAY; int relayState = RELAYOFF; int outState = false; SLCD slcd; //define LCD display char LCDMessages[2][LCDLEN] = {"TRUE", "FALS"}; +uint8_t registerArray[8] = {REG_PULSE_CFG, REG_PULSE_SRC, REG_PULSE_THSX, REG_PULSE_THSY, REG_PULSE_THSZ, REG_PULSE_TMLT, REG_PULSE_LTCY, REG_PULSE_WIND}; +uint8_t regAddress; void LCDMess(char *lMess, float dWait){ @@ -111,6 +121,10 @@ sprintf (lcdData,"%x",regData); LCDMess(lcdData,BLINKTIME); + //send address + regData = latchData | axisData; + regAddress = 0; + acc.setRegisterInStandby(registerArray[regAddress], regData); acc.readRegs(REG_PULSE_SRC, ®Data, 1); sprintf (lcdData,"%x",regData); LCDMess(lcdData,BLINKTIME);