v1

Dependencies:   MMA8451Q SLCD mbed

Fork of ACC_LCD_341_all_axies by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
dorian505
Date:
Thu Dec 01 03:46:15 2016 +0000
Parent:
5:9e4173e23e05
Commit message:
v1;

Changed in this revision

SLCD.lib Show annotated file Show diff for this revision Revisions of this file
acc_all_axies.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 9e4173e23e05 -r 3ec81d10d53d SLCD.lib
--- a/SLCD.lib	Mon Nov 28 15:43:04 2016 +0000
+++ b/SLCD.lib	Thu Dec 01 03:46:15 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/scohennm/code/SLCD/#73e8e2c9a5b8
+https://developer.mbed.org/users/dorian505/code/SLCD/#a0f4a3cc23dd
diff -r 9e4173e23e05 -r 3ec81d10d53d acc_all_axies.cpp
--- a/acc_all_axies.cpp	Mon Nov 28 15:43:04 2016 +0000
+++ b/acc_all_axies.cpp	Thu Dec 01 03:46:15 2016 +0000
@@ -14,6 +14,9 @@
 #define DATAINTERVAL 0.200
 #define LCDWAIT  1.5
 #define LCDDATALEN 10
+#define PI 3.1415
+#define half_circle 180
+#define flat 90 //Account for flat board accel equals 0. Make flat board equal 90
 
 #define PROGNAME "ACC_LCD_all_axes_v1\r\n"
 
@@ -49,13 +52,20 @@
         slcd.printf(lMess);
 } 
 
-void LCDsignedFloat(float theNumber){
-    sprintf (lcdData," %3.2f",theNumber); 
-    // changed SLCD.cpp to interpret < as -
-    if (theNumber < 0.0) sprintf (lcdData,"<%3.2f",fabs(theNumber));   
-    LCDMess(lcdData); 
-} 
+//void LCDsignedFloat(float theNumber){
+//    sprintf (lcdData," %3.2f",theNumber); 
+//    // changed SLCD.cpp to interpret < as -
+//    if (theNumber < 0.0) sprintf (lcdData,"<%3.2f",fabs(theNumber));   
+//    LCDMess(lcdData); 
+
 
+void LCDsignedAngle(float theAngle){
+    sprintf (lcdData, " %2.0f@",theAngle);
+    // changed SLCD.cpp to interpret @ as superscript 0 (degrees)
+    if (theAngle < 0.0) sprintf (lcdData,"<%2.0f@",fabs(theAngle));
+    LCDMess (lcdData);
+    }
+    
 void initialize_global_vars(){
     pc.printf(PROGNAME);
     // set up DAQ timers
@@ -91,15 +101,15 @@
         }
         while (dataTimer.read() > DATAINTERVAL){
             dataTimer.reset();             
-            axisValue[XAXIS]= acc.getAccX();
-            axisValue[YAXIS] = acc.getAccY(); 
-            axisValue[ZAXIS] = acc.getAccZ();     
+            axisValue[XAXIS]= ((asin (acc.getAccX()) * half_circle) / PI) + flat; 
+            axisValue[YAXIS] = ((asin (acc.getAccY()) * half_circle) / PI) + flat;
+            axisValue[ZAXIS] = ((asin (acc.getAccZ()) * half_circle) / PI) + flat;    
 #ifdef PRINTDBUG
             for (i=0; i< NUMAXES;i++){
-                pc.printf("Acc %d = %f\r\n",i, axisValue[i]);
+                pc.printf("Theta %d = %f\r\n",i, axisValue[i]);
             }
 #endif
-            LCDsignedFloat(axisValue[currentAxis]);              
+            LCDsignedAngle(axisValue[currentAxis]);              
        }
     }
 }
\ No newline at end of file