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: MAG3110 MMA8451Q TSI SLCD mbed-src
Revision 3:6b371e451f9e, committed 2014-02-11
- Comitter:
- jppang
- Date:
- Tue Feb 11 09:08:57 2014 +0000
- Parent:
- 2:e3770fac7512
- Commit message:
- add SLCD lib
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Feb 09 12:29:43 2014 +0000
+++ b/main.cpp Tue Feb 11 09:08:57 2014 +0000
@@ -2,14 +2,17 @@
#include "TSISensor.h"
#include "MMA8451Q.h"
#include "MAG3110.h"
+#include "SLCD.h"
#include <cstdlib>
#include <iostream>
+#include <cstring>
Serial pc(USBTX, USBRX);
TSISensor tsi;
MMA8451Q acc(PTE25, PTE24, 0x1D<<1);
MAG3110 mag(PTE25, PTE24, 0x0E<<1);
+SLCD lcd;
PwmOut rled(PTE29);
PwmOut gled(PTD5);
@@ -25,7 +28,8 @@
float onTime = 1.0;
// float offTime = 0.0;
float holdTime = 1.0;
- int magX = 0, magY = 0, magZ = 0;
+ int magX = 0, magY = 0, magZ = 0;
+ char lcdMessage[40];
while(1) {
@@ -36,6 +40,9 @@
cout << "MMA8451: " << acc.getAccX() << "\t" << acc.getAccY() << "\t" << acc.getAccZ() << "\n\r" << endl;
cout << "MAG3110: " << magX << "\t" << magY << "\t" << magZ << "\n\r" << endl;
cout << "MAG3110: " << mag.getHeading() << "\n\r" << endl;
+ //lcd.All_Segments(1);
+ sprintf(lcdMessage, "%4.0f", mag.getHeading());
+ lcd.printf(lcdMessage);
wait(holdTime);
rled = tsi.readPercentage();
@@ -45,6 +52,8 @@
cout << "SW1: " << s1 << "\n\r" << endl;
cout << "SW3: " << s3 << "\n\r" << endl;
cout << "Light Sensor: " << lightSensor << "\n\r" << endl;
+ //lcd.All_Segments(0);
+ lcd.printf(lcdMessage);
wait(holdTime);
}
}