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 10:3de03f06624e, committed 2016-11-28
- Comitter:
- dorian505
- Date:
- Mon Nov 28 05:01:24 2016 +0000
- Parent:
- 9:b2768bb45a68
- Child:
- 11:40fda348bb5e
- Commit message:
- final version
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 28 02:35:44 2016 +0000
+++ b/acc_341.cpp Mon Nov 28 05:01:24 2016 +0000
@@ -2,9 +2,10 @@
#include <math.h>
#include "MMA8451Q.h"
#include "SLCD.h"
-
+#define NUMBUTS 2
+#define RBUT PTC3
#define LBUT PTC12 // port addresses for left button
-
+#define BUTTONTIME 0.1
/*
Test of the accelerometer, digital I/O, on-board LCD screen.
Looing at vector product of the x-y components of the accelerometer.
@@ -39,7 +40,11 @@
MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
Serial pc(USBTX, USBRX);
Timer dataTimer;
-DigitalIn button(LBUT)
+Timer ButtonTimer;
+
+int displayState;
+DigitalIn buttons[NUMBUTS] = {RBUT, LBUT};
+DigitalIn button(LBUT);
void LCDMess(char *lMess){
@@ -73,7 +78,8 @@
//Get accelerometer data - tilt angles minus offset for zero mark.
while (true) {
if (ButtonTimer > BUTTONTIME){
- buttonValue = !buttons[1].read();
+ //buttonValue = !buttons[1].read();
+// pc.printf("%d \r\n",buttonValue);
for (int i=0; i < NUMBUTS; i++){ // index will be 0 or 1
if(!buttons[i]) {
displayState = i;
@@ -88,17 +94,17 @@
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);
+ 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
// Wait then do the whole thing again.
- }
\ No newline at end of file
+ }
+ }}
\ No newline at end of file
