1

Revision:
20:d55e9d7eb17e
Parent:
19:4d6cd7140a71
Child:
21:a92a632a0cc7
--- a/MMA8452.h	Thu Mar 06 18:07:43 2014 +0000
+++ b/MMA8452.h	Fri Mar 07 11:55:30 2014 +0000
@@ -35,37 +35,37 @@
 #endif
 
 // Register descriptions found in section 6 of pdf
-#define MMA8452_STATUS 0x00                 // Type 'read' : Status of the data registers
-#define MMA8452_OUT_X_MSB 0x01              // Type 'read' : x axis - MSB of 2 byte sample
-#define MMA8452_OUT_X_LSB 0x02              // Type 'read' : x axis - LSB of 2 byte sample
-#define MMA8452_OUT_Y_MSB 0x03              // Type 'read' : y axis - MSB of 2 byte sample
-#define MMA8452_OUT_Y_LSB 0x04              // Type 'read' : y axis - LSB of 2 byte sample
-#define MMA8452_OUT_Z_MSB 0x05              // Type 'read' : z axis - MSB of 2 byte sample
-#define MMA8452_OUT_Z_LSB 0x06              // Type 'read' : z axis - LSB of 2 byte sample
+#define MMA8452_STATUS 0x00        // Type 'read' : Status of the data registers
+#define MMA8452_OUT_X_MSB 0x01     // Type 'read' : x axis - MSB of 2 byte sample
+#define MMA8452_OUT_X_LSB 0x02     // Type 'read' : x axis - LSB of 2 byte sample
+#define MMA8452_OUT_Y_MSB 0x03     // Type 'read' : y axis - MSB of 2 byte sample
+#define MMA8452_OUT_Y_LSB 0x04     // Type 'read' : y axis - LSB of 2 byte sample
+#define MMA8452_OUT_Z_MSB 0x05     // Type 'read' : z axis - MSB of 2 byte sample
+#define MMA8452_OUT_Z_LSB 0x06     // Type 'read' : z axis - LSB of 2 byte sample
 
 // register definitions
 #define MMA8452_XYZ_DATA_CFG 0x0E
 
-#define MMA8452_SYSMOD 0x0B                         // Type 'read' : This tells you if device is active, sleep or standy 0x00=STANDBY 0x01=WAKE 0x02=SLEEP
-#define MMA8452_WHO_AM_I 0x0D                       // Type 'read' : This should return the device id of 0x2A
+#define MMA8452_SYSMOD 0x0B        // Type 'read' : This tells you if device is active, sleep or standy 0x00=STANDBY 0x01=WAKE 0x02=SLEEP
+#define MMA8452_WHO_AM_I 0x0D      // Type 'read' : This should return the device id of 0x2A
 
-#define MMA8452_PL_STATUS 0x10                      // Type 'read' : This shows portrait landscape mode orientation
-#define MMA8452_PL_CFG 0x11                         // Type 'read/write' : This allows portrait landscape configuration
-#define MMA8452_PL_COUNT 0x12                       // Type 'read' : This is the portraint landscape debounce counter
-#define MMA8452_PL_BF_ZCOMP 0x13                    // Type 'read' :
-#define MMA8452_PL_THS_REG 0x14                     // Type 'read' :
+#define MMA8452_PL_STATUS 0x10     // Type 'read' : This shows portrait landscape mode orientation
+#define MMA8452_PL_CFG 0x11        // Type 'read/write' : This allows portrait landscape configuration
+#define MMA8452_PL_COUNT 0x12      // Type 'read' : This is the portraint landscape debounce counter
+#define MMA8452_PL_BF_ZCOMP 0x13   // Type 'read' :
+#define MMA8452_PL_THS_REG 0x14    // Type 'read' :
 
-#define MMA8452_FF_MT_CFG 0X15                      // Type 'read/write' : Freefaul motion functional block configuration
-#define MMA8452_FF_MT_SRC 0X16                      // Type 'read' : Freefaul motion event source register
-#define MMA8452_FF_MT_THS 0X17                      // Type 'read' : Freefaul motion threshold register
-#define MMA8452_FF_COUNT 0X18                       // Type 'read' : Freefaul motion debouce counter
+#define MMA8452_FF_MT_CFG 0X15     // Type 'read/write' : Freefaul motion functional block configuration
+#define MMA8452_FF_MT_SRC 0X16     // Type 'read' : Freefaul motion event source register
+#define MMA8452_FF_MT_THS 0X17     // Type 'read' : Freefaul motion threshold register
+#define MMA8452_FF_COUNT 0X18      // Type 'read' : Freefaul motion debouce counter
 
-#define MMA8452_ASLP_COUNT 0x29                     // Type 'read/write' : Counter settings for auto sleep
-#define MMA8452_CTRL_REG_1 0x2A                     // Type 'read/write' :
-#define MMA8452_CTRL_REG_2 0x2B                     // Type 'read/write' :
-#define MMA8452_CTRL_REG_3 0x2C                     // Type 'read/write' :
-#define MMA8452_CTRL_REG_4 0x2D                     // Type 'read/write' :
-#define MMA8452_CTRL_REG_5 0x2E                     // Type 'read/write' :
+#define MMA8452_ASLP_COUNT 0x29    // Type 'read/write' : Counter settings for auto sleep
+#define MMA8452_CTRL_REG_1 0x2A    // Type 'read/write' :
+#define MMA8452_CTRL_REG_2 0x2B    // Type 'read/write' :
+#define MMA8452_CTRL_REG_3 0x2C    // Type 'read/write' :
+#define MMA8452_CTRL_REG_4 0x2D    // Type 'read/write' :
+#define MMA8452_CTRL_REG_5 0x2E    // Type 'read/write' :
 
 // Defined in table 13 of the Freescale PDF
 /// xxx these all need to have better names
@@ -108,8 +108,8 @@
 #define MMA8452_STATUS_YDR_MASK 0x02
 #define MMA8452_STATUS_XDR_MASK 0x01
  
-class MMA8452         
-{        
+class MMA8452 {
+            
     public:
     
        enum DynamicRange {
@@ -209,7 +209,9 @@
       int readZCount(int *z);
       
       int readXYZGravity(double *x, double *y, double *z);
-      
+      int readXGravity(double *x);
+      int readYGravity(double *y);
+      int readZGravity(double *z);
       
       /// Returns 1 if data has been internally sampled (is available) for the x-axis since last read, 0 otherwise.
       int isXReady();
@@ -274,6 +276,7 @@
       int eightBitToSigned(char *buf);
       double convertCountToGravity(int count, int countsPerG);
       char getMaskedRegister(int reg, char mask);
+      int getCountsPerG();
     
       I2C _i2c;
       int _frequency;