HW 3.2 Ambient Computing Modifications

Dependencies:   MMA8451Q8a SLCD mbed

Fork of LCD_punch_mtr_8_v5_class by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
bomalley
Date:
Sat Jan 31 22:04:01 2015 +0000
Parent:
7:6aa16a6fde70
Commit message:
HW 3.2 Ambient Computing; Modifications

Changed in this revision

LCD_punch_mtr8_v5.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6aa16a6fde70 -r 71d04967282d LCD_punch_mtr8_v5.cpp
--- a/LCD_punch_mtr8_v5.cpp	Fri Jan 30 22:26:06 2015 +0000
+++ b/LCD_punch_mtr8_v5.cpp	Sat Jan 31 22:04:01 2015 +0000
@@ -31,7 +31,7 @@
 #define ZCOMPD 2
 #define VMAXD 3
 #define MAXGS 8
-#define COUNTSCALE 1
+#define COUNTSCALE 10
 #define REG_WHO_AM_I      0x0D
 #define XYZ_DATA_CFG      0x0E
 
@@ -125,6 +125,8 @@
     char lcdData[LCDLEN]; //buffer needs places dor decimal pt and colon
     uint8_t regData = MAX_4G; // test value must change after G setting
     int16_t xCounts;
+    int16_t yCounts;
+    int16_t zCounts;
     
 #ifdef PRINTDBUG
         pc.printf(PROGNAME);
@@ -172,8 +174,12 @@
 // No offset
             xAcc = abs(acc.getAccX());
             xCounts = acc.getAccAxis(REG_OUT_X_MSB);
+            
             yAcc = abs(acc.getAccY());
+            yCounts = acc.getAccAxis(REG_OUT_Y_MSB);
+            
             zAcc = abs(acc.getAccZ());
+            zCounts = acc.getAccAxis(REG_OUT_Z_MSB);
  // Calulate vector sum of x,y and z reading.       
             vector = sqrt(pow(xAcc,2) + pow(zAcc,2));
             vector = zAcc;
@@ -182,8 +188,8 @@
             }
 //Prepare data for LCD display 
             accaxisdata[XCOMPD] = abs((float)xCounts/COUNTSCALE); // scalling is set to 1 at this point
-            accaxisdata[YCOMPD] = yAcc;
-            accaxisdata[ZCOMPD] = zAcc;
+            accaxisdata[YCOMPD] = abs((float)yCounts/COUNTSCALE);;
+            accaxisdata[ZCOMPD] = abs((float)zCounts/COUNTSCALE);;
             accaxisdata[VMAXD] = vMax;
             dataTimer.reset();
             LEDDwell = 1.1 - vMax/MAXGS;