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: MMA8451Q SLCD_minus_mod mbed
Fork of ACC_LCD_341_Basic by
Revision 6:045defd0d877, committed 2016-11-20
- Comitter:
- dorian505
- Date:
- Sun Nov 20 21:15:54 2016 +0000
- Parent:
- 5:29c6ba524263
- Child:
- 7:ae5c27eb1492
- Commit message:
- Axis program v. 1
Changed in this revision
| acc_341.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/acc_341.cpp Mon Nov 14 15:50:33 2016 +0000
+++ b/acc_341.cpp Sun Nov 20 21:15:54 2016 +0000
@@ -3,6 +3,8 @@
#include "MMA8451Q.h"
#include "SLCD.h"
+#define LBUT PTC12 // port addresses for left button
+
/*
Test of the accelerometer, digital I/O, on-board LCD screen.
Looing at vector product of the x-y components of the accelerometer.
@@ -11,6 +13,9 @@
#define DATAINTERVAL 0.200
#define LCDDATALEN 10
+#define xAxis 0
+#define yAxis 1
+#define zAxis 2
#define PROGNAME "ACCLCD341-541\r\n"
@@ -58,26 +63,44 @@
int main() {
float xAcc;
float yAcc;
- float zAcc;
+ float zAcc;
+ xAcc = acc.getAccX();
+ yAcc = acc.getAccY();
+ zAcc = acc.getAccZ();
+ float DigitalIn = LBUT;
initialize_global_vars();
// main loop forever
- while(true) {
- if(dataTimer.read() > DATAINTERVAL){
- dataTimer.reset();
-//Get accelerometer data - tilt angles minus offset for zero mark.
- xAcc = acc.getAccX();
- yAcc = acc.getAccY();
- zAcc = acc.getAccZ();
+ //Get accelerometer data - tilt angles minus offset for zero mark.
+
+ for (int i=0; i < DigitalIn; i++){ // index will be 0 or 1
+ if(!DigitalIn) { // a buttton is pressed
+ //xAcc = acc.getAccX();
+ //yAcc = acc.getAccY();
+ //zAcc = acc.getAccZ();
+ int displayState = i;
+ switch (displayState){ // this keeps things generic
+ case xAxis:
+ LCDsignedFloat(xAcc);
+ break;
+ case yAxis:
+ LCDsignedFloat(yAcc);
+ break;
+ case zAxis:
+ LCDsignedFloat(zAcc);
+ i=-1;
+ break;
+
+ }
+ }}
+ // if ! buttons
#ifdef PRINTDBUG
pc.printf("xAcc = %f\r\n", xAcc);
pc.printf("yAcc = %f\r\n", yAcc);
pc.printf("zAcc = %f\r\n", zAcc);
+ pc.printf("LBUT = %f\r\n", LBUT);
#endif
- LCDsignedFloat(xAcc);
// Wait then do the whole thing again.
- }
- }
-}
\ No newline at end of file
+ }
\ No newline at end of file
