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: 4DGL-uLCD-SE mbed
Revision 2:84b9865dad96, committed 2018-02-12
- Comitter:
- bjs9
- Date:
- Mon Feb 12 19:58:56 2018 +0000
- Parent:
- 1:9f093ed9a93b
- Commit message:
- Lab2_Part3;
Changed in this revision
| LSM9DS1_Library.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9f093ed9a93b -r 84b9865dad96 LSM9DS1_Library.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LSM9DS1_Library.lib Mon Feb 12 19:58:56 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ECE-4180-Spring-18/code/LSM9DS1_Library1/#f2e34787966e
diff -r 9f093ed9a93b -r 84b9865dad96 main.cpp
--- a/main.cpp Thu Feb 08 03:47:59 2018 +0000
+++ b/main.cpp Mon Feb 12 19:58:56 2018 +0000
@@ -2,20 +2,40 @@
//
#include "mbed.h"
#include "uLCD_4DGL.h"
-
+#include "LSM9DS1.h"
+
+
uLCD_4DGL uLCD(p28,p27,p29); // serial tx, serial rx, reset pin;
-
-int main()
-{
- // basic printf demo = 16 by 18 characters on screen
- uLCD.printf("\nHello uLCD World\n"); //Default Green on black text
- uLCD.printf("\n Starting Demo...");
- uLCD.text_width(4); //4X size text
- uLCD.text_height(4);
- uLCD.color(RED);
- for (int i=10; i>=0; --i) {
- uLCD.locate(1,2);
- uLCD.printf("%2D",i);
- wait(.5);
+Serial pc(USBTX, USBRX);
+int previousX = 64;
+int previousY = 64;
+int main(){
+ LSM9DS1 lol(p9, p10, 0xD6, 0x3C);
+ lol.begin();
+ if (!lol.begin()) {
+ pc.printf("Failed to communicate with LSM9DS1.\n");
+ }
+ lol.calibrate();
+ uLCD.circle(64,64,5,RED);
+ uLCD.filled_circle(64,64,2,GREEN);
+ while(1) {
+ uLCD.circle(64,64,5,RED);
+ lol.readTemp();
+ lol.readMag();
+ lol.readGyro();
+ lol.readAccel();
+ float accel_x = lol.calcAccel(lol.ax);
+ float accel_y = lol.calcAccel(lol.ay);
+ float accel_z = lol.calcAccel(lol.az);
+ float x = 64 + 64 * accel_x;
+ float y = 64 + 64 * accel_y;
+ uLCD.filled_circle(previousX,previousY,2,BLACK);
+ uLCD.filled_circle(x,y,2,GREEN);
+ previousX = x;
+ previousY = y;
+ //pc.printf("gyro: %d %d %d\n\r", lol.gx, lol.gy, lol.gz);
+ pc.printf("accel: %d %d %d\n\r", lol.ax, lol.ay, lol.az);
+ //pc.printf("mag: %d %d %d\n\n\r", lol.mx, lol.my, lol.mz);
+ wait(.005);
}
}
\ No newline at end of file