![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Punch program for HW 3.2
Dependencies: MMA8451Q8a SLCD mbed
Fork of LCD_punch_mtr_8_v5_class by
Revision 10:66f5d56781d9, committed 2015-04-28
- Comitter:
- vbharam
- Date:
- Tue Apr 28 23:12:14 2015 +0000
- Parent:
- 9:0f3136c281d1
- Commit message:
- Added xAccDifference
Changed in this revision
LCD_punch_mtr8_v5.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0f3136c281d1 -r 66f5d56781d9 LCD_punch_mtr8_v5.cpp --- a/LCD_punch_mtr8_v5.cpp Tue Apr 28 23:01:08 2015 +0000 +++ b/LCD_punch_mtr8_v5.cpp Tue Apr 28 23:12:14 2015 +0000 @@ -116,6 +116,9 @@ float xAcc = 0.0; float yAcc = 0.0; float zAcc = 0.0; + float previous_xAcc = 0.0; + float xAccDiff = 0.0; + int counter = 0; float vector; float vMax = 0.0; float DisplayTime = DATADISPDWELL; @@ -167,26 +170,6 @@ LCDMess(displayTitles[displayState],BLINKTIME); } -///STEPS PARAMETER -//Set up a digital filter using four registers and a summing unit - - -//Set up the dynamic threshold and dynamic precision -//continuously updates the maximum and minimumvalues of the 3-axis acceleration every 50samples -//the average value, (Max+min)/2 is the dynamic threshold level - - -//set up the peak Detection - -//set up time window - - -///DISTANCE PARAMETERS -//s=number of steps*distance per step - - -///SPEED PARAMETER -//d=s/t // -------------------------------------------- while (dataTimer.read() > DATATIME){ @@ -198,14 +181,16 @@ zAcc = (acc.getAccZ()); zCounts = acc.getAccAxis(REG_OUT_Z_MSB); -// xAccDiff = - printf("%1.2f %1.2f %1.2f\n", xAcc, yAcc, zAcc); -// printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", xAcc, yAcc, zAcc); -// printf("X-counts: %1.2f, Y-counts: %1.2f, Z-counts: %1.2f\n", xCounts, yCounts, zCounts); + xAccDiff = abs(previous_xAcc - xAcc); + if (xAccDiff > 0.5){ + counter++; + }; + previous_xAcc = xAcc; + printf("%1.2f %1.2f %1.2f %1.2f %d\n", xAcc, yAcc, zAcc, xAccDiff, counter); // Calulate vector sum of x,y and z reading. vector = sqrt(pow(xAcc,2) + pow(zAcc,2)); -// vector = zAcc; + vector = zAcc; if (vector > vMax) { vMax = vector; }