KBrat-SSD645-HW-7_1

Fork of MMA8451Q8 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
tisbrat
Date:
Mon Mar 06 17:39:43 2017 +0000
Parent:
7:7812354ef684
Commit message:
Revised

Changed in this revision

MMA8451Q8.cpp Show annotated file Show diff for this revision Revisions of this file
MMA8451Q8.h Show annotated file Show diff for this revision Revisions of this file
diff -r 7812354ef684 -r 65da360cf088 MMA8451Q8.cpp
--- 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);
diff -r 7812354ef684 -r 65da360cf088 MMA8451Q8.h
--- a/MMA8451Q8.h	Wed Feb 22 15:35:47 2017 +0000
+++ b/MMA8451Q8.h	Mon Mar 06 17:39:43 2017 +0000
@@ -104,6 +104,8 @@
   void readRegs(int addr, uint8_t * data, int len);
   void writeRegs(uint8_t * data, int len);
   void setGLimit(); 
+  void standbyMode();
+  void activeMode();
   
 private: 
   int16_t getAccAxis(uint8_t addr);