Punch Program DE_3.2
Dependencies: MMA8451Q8a SLCD mbed
Fork of LCD_punch_mtr_8_v5_class by
Revision 8:7a3bc83ee488, committed 2015-02-02
- Comitter:
- destradafilm
- Date:
- Mon Feb 02 19:43:38 2015 +0000
- Parent:
- 7:6aa16a6fde70
- Commit message:
- David Estrada HW3_2
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 7a3bc83ee488 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 Mon Feb 02 19:43:38 2015 +0000 @@ -31,9 +31,10 @@ #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 +#define TEN 10 #define REG_OUT_X_MSB 0x01 #define REG_OUT_Y_MSB 0x03 @@ -72,7 +73,8 @@ Serial pc(USBTX, USBRX); char displayTitles[NUMSTATES][LCDLEN] = {XCOMP,YCOMP,ZCOMP,MAXVECT}; float accaxisdata[NUMSTATES]; -char displayformats[NUMSTATES][LCDLEN] = {"%4.0f","y.%3.2f","z.%3.2f","v.%3.2f"}; +char displayformats[NUMSTATES][LCDLEN] = {"%4.0f","%4.0f","%4.0f","%4.0f"}; +//char displayformats[NUMSTATES][LCDLEN] = {"%4.0f","y.%3.2f","z.%3.2f","v.%3.2f"}; //char displayformats[NUMSTATES][LCDLEN] = {"%4.3f","%4.3f","%4.3f","%4.3f"}; void LCDMess(char *lMess, float dWait){ @@ -125,6 +127,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); @@ -168,12 +172,14 @@ // -------------------------------------------- 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); 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,11 @@ } //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[YCOMPD] = yAcc; +// accaxisdata[ZCOMPD] = zAcc; accaxisdata[VMAXD] = vMax; dataTimer.reset(); LEDDwell = 1.1 - vMax/MAXGS;