Hw

Dependencies:   MMA8451Q SLCD mbed

Fork of LCD_ACC_46_v4-2g by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
kennylujan42
Date:
Wed Feb 22 09:50:25 2017 +0000
Parent:
4:41920817d234
Commit message:
HW;

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
lcd_acc_46_v-2g.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 41920817d234 -r 98f02fe1d957 MMA8451Q.lib
--- a/MMA8451Q.lib	Fri Feb 10 19:28:50 2017 +0000
+++ b/MMA8451Q.lib	Wed Feb 22 09:50:25 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
+https://developer.mbed.org/users/kennylujan42/code/MMA8451Q/#df36b750371a
diff -r 41920817d234 -r 98f02fe1d957 lcd_acc_46_v-2g.cpp
--- a/lcd_acc_46_v-2g.cpp	Fri Feb 10 19:28:50 2017 +0000
+++ b/lcd_acc_46_v-2g.cpp	Wed Feb 22 09:50:25 2017 +0000
@@ -5,7 +5,16 @@
 Test of the accelerometer, digital I/O, on-board LCD screen, and 16-bit ADC.
  
  */
-
+ 
+ 
+ #define REG_WHO_AM_I       0x0D
+ #define REG_CTRL_REG_1     0x2A
+ #define REG_OUT_X_MSB      0x01
+ #define REG_OUT_Y_MSB      0x03
+ #define REG_OUT_Y_MSB      0x05
+ #define XYZ_DATA_CFG       0x0E
+ 
+ 
 #define BLINKTIME 0.7
 #define DATATIME 0.1
 #define DATADISPDWELL 0.2
@@ -18,14 +27,16 @@
 #define XCOMP "XCMP"
 #define YCOMP "YCMP"
 #define ZCOMP "ZCMP"
+#define XRAWP "XRAW"
 #define ANALTOVOLTS 3.3
 #define LEDDELAY 0.400
 //define states
-#define NUMSTATES 4
+#define NUMSTATES 5
 #define XCOMPD 0
 #define YCOMPD 1
 #define ZCOMPD 2
 #define VMAXD 3
+#define XRAWD 4
 
 #define PROGNAME "LCD_ACC_LCDv3 46\r/n"
 
@@ -52,6 +63,7 @@
 DigitalOut LEDs[NUMLEDS]={LED_RED, LED_GREEN}; //Indicator LEDs
 Serial pc(USBTX, USBRX);
 
+int16_t xAccBits;/// creates local warning
 
 void LCDMess(char *lMess, float dWait){
         slcd.Home();
@@ -93,6 +105,7 @@
     char lcdData[10]; //buffer needs places for decimal pt and colon
 
     
+    
 #ifdef PRINTDBUG
         pc.printf(PROGNAME);
 #endif
@@ -131,20 +144,29 @@
                 case ZCOMPD: {
                     LCDMess(ZCOMP,BLINKTIME);
                     break;
-                }
+                 }
                 case VMAXD:{
                     LCDMess(MAXVECT,BLINKTIME);
                     break;
                 }
+                case XRAWD:{
+                    LCDMes(XWRAP,BLINKTIME);
+                    break;
+                    }
+                    
             }// switch        
         }
         
 // --------------------------------------------
         while (dataTimer.read() > DATATIME){
 // No offset
+
             xAcc = abs(acc.getAccX());
             yAcc = abs(acc.getAccY());
             zAcc = abs(acc.getAccZ());
+
+            xAccBits = acc.getAccAxis(REG_OUT_X_MSB);
+ 
  // Calulate vector sum of x,y and z reading.       
 //            vector = sqrt(pow(xAcc,2) + pow(zAcc,2));
             vector = zAcc;
@@ -173,6 +195,10 @@
                     sprintf (lcdData,"%4.3f",vMax);
                     break;
                 }
+                case XRAWD:{
+                    sprintf(lcdData,"%4d",xAccBits);
+                    break;
+                }
             }
             LCDMessNoDwell(lcdData);
             displayTimer.reset();