Changed to access xAxis counts.

Dependencies:   MMA8451Q8a SLCD mbed

Fork of LCD_punch_mtr_8_v5 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
scohennm
Date:
Fri Jan 30 22:26:06 2015 +0000
Parent:
6:c2f31918cf77
Commit message:
Added correct storage classes and other details

Changed in this revision

LCD_punch_mtr8_v5.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c2f31918cf77 -r 6aa16a6fde70 LCD_punch_mtr8_v5.cpp
--- a/LCD_punch_mtr8_v5.cpp	Wed Jan 28 21:42:15 2015 +0000
+++ b/LCD_punch_mtr8_v5.cpp	Fri Jan 30 22:26:06 2015 +0000
@@ -30,8 +30,8 @@
 #define YCOMPD 1
 #define ZCOMPD 2
 #define VMAXD 3
-#define MAXGS 8.0
-
+#define MAXGS 8
+#define COUNTSCALE 1
 #define REG_WHO_AM_I      0x0D
 #define XYZ_DATA_CFG      0x0E
 
@@ -124,7 +124,7 @@
     int outState = false;
     char lcdData[LCDLEN]; //buffer needs places dor decimal pt and colon
     uint8_t regData = MAX_4G; // test value must change after G setting
-    uint16_t xCounts;
+    int16_t xCounts;
     
 #ifdef PRINTDBUG
         pc.printf(PROGNAME);
@@ -142,8 +142,8 @@
 // Go into registers ofn Accelerometer, change sensitivity then test.
 // http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8451Q.pdf
 // See page 26
-// Set 8 g max limit
-    acc.setGLimit(MAX_2G); // For now set to 8g
+// Set 2 g max limit ****************** Note limits
+    acc.setGLimit(MAX_2G); // For now set to 2g
     acc.readRegs(XYZ_DATA_CFG, &regData, 1);
     sprintf (lcdData,"%d",regData);
     LCDMess(lcdData,BLINKTIME);
@@ -168,7 +168,7 @@
         
 // --------------------------------------------
         while (dataTimer.read() > DATATIME){
-//Get accelerometer data - tilt angles minus offset for zero mark.
+
 // No offset
             xAcc = abs(acc.getAccX());
             xCounts = acc.getAccAxis(REG_OUT_X_MSB);
@@ -180,18 +180,15 @@
             if (vector > vMax) {
                 vMax = vector;
             }
-            accaxisdata[XCOMPD] = (float)xCounts;
+//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[VMAXD] = vMax;
             dataTimer.reset();
             LEDDwell = 1.1 - vMax/MAXGS;
         }
-#ifdef PRINTDBUG
-        pc.printf("vector = %f\r\n",  xAcc);
-        pc.printf("scaling = %f\r\n", scaleExpansion);
-        pc.printf("RawTemp = %f\r\n", FDeg);
-#endif
+
 // Display the appropriate data on the LCD based upon what mode was chosen
         while (displayTimer.read() > DisplayTime){
             sprintf (lcdData,displayformats[displayState],accaxisdata[displayState]);