Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q8 SLCD mbed
Fork of SSD_341_535_finalv3 by
Diff: lcd_acc_46_v3.cpp
- Revision:
- 1:6c2ec7b0e1c9
- Parent:
- 0:88ddbd76b455
- Child:
- 2:8cdbe8a96b59
--- a/lcd_acc_46_v3.cpp Sun Nov 30 00:08:36 2014 +0000
+++ b/lcd_acc_46_v3.cpp Sun Nov 30 01:04:47 2014 +0000
@@ -9,8 +9,9 @@
Show x and y components
*/
-#define BLINKTIME 0.5
+#define BLINKTIME 0.7
#define DATATIME 0.1
+#define DATADISPDWELL 0.2
#define NUMLEDS 2
#define LEDON 0
#define LEDOFF 1
@@ -94,12 +95,12 @@
float xOffset;
float yOffset;
int displayState = true;
- float xAcc;
- float yAcc;
- float zAcc;
+ float xAcc = 0.0;
+ float yAcc = 0.0;
+// float zAcc;
float vector;
float vMax = 0.0;
- int DisplayTime = DATATIME;
+ float DisplayTime = DATADISPDWELL;
int outState = false;
char lcdData[10]; //buffer needs places dor decimal pt and colon
@@ -113,6 +114,10 @@
// runLEDs(NUMLEDS);
blinkTimer.start();
blinkTimer.reset();
+ displayTimer.start();
+ displayTimer.reset();
+ dataTimer.start();
+ dataTimer.reset();
// main loop forever
while(true) {
@@ -143,32 +148,37 @@
LCDMess(MAXVECT,BLINKTIME);
}
}
- //while (dataTimer.read() > DATATIME){
+
+// --------------------------------------------
+ while (dataTimer.read() > DATATIME){
//Get accelerometer data - tilt angles minus offset for zero mark.
// No offset
xAcc = abs(acc.getAccX());
yAcc = abs(acc.getAccY());
- zAcc = abs(acc.getAccZ());
+// zAcc = abs(acc.getAccZ());
// Calulate vector sum of x,y and z reading.
- vector = sqrt(pow(xAcc,2) + pow(yAcc,2)+ pow(zAcc,2));
+ vector = sqrt(pow(xAcc,2) + pow(yAcc,2));
if (vector > vMax) {
vMax = vector;
}
- wait(DATATIME);
+ dataTimer.reset();
+ }
#ifdef PRINTDBUG
pc.printf("vector = %f\r\n", yAcc);
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){
if (displayState) {
sprintf (lcdData,"%4.3f",yAcc);
}else {
sprintf (lcdData,"%4.3f",vMax);
}
- DisplayTime = BLINKTIME;
- LCDMess(lcdData,DisplayTime);
+ // LCDMess(lcdData,DisplayTime);
+ LCDMessNoDwell(lcdData);
+ displayTimer.reset();
+ } // displaytimer
// Wait then do the whole thing again.
}//forever loop
}// main
\ No newline at end of file
