Metin Azmaz
/
MPU9250AHRS3
Fixed some compile errors on original code
Diff: main.cpp
- Revision:
- 3:e1d130f34972
- Parent:
- 1:71c319f03fda
--- a/main.cpp Tue Aug 05 01:37:23 2014 +0000 +++ b/main.cpp Fri May 28 17:42:45 2021 +0000 @@ -30,7 +30,7 @@ //F401_init84 myinit(0); #include "mbed.h" #include "MPU9250.h" -#include "N5110.h" + // Using NOKIA 5110 monochrome 84 x 48 pixel display // pin 9 - Serial clock out (SCLK) @@ -43,7 +43,7 @@ float sum = 0; uint32_t sumCount = 0; char buffer[14]; - +float counttime=0; MPU9250 mpu9250; Timer t; @@ -51,7 +51,7 @@ Serial pc(USBTX, USBRX); // tx, rx // VCC, SCE, RST, D/C, MOSI,S CLK, LED - N5110 lcd(PA_8, PB_10, PA_9, PA_6, PA_7, PA_5, PC_7); + //N5110 lcd(PA_8, PB_10, PA_9, PA_6, PA_7, PA_5, PC_7); @@ -66,7 +66,7 @@ t.start(); - lcd.init(); + //lcd.init(); // lcd.setBrightness(0.05); @@ -78,11 +78,11 @@ { pc.printf("MPU9250 WHO_AM_I is 0x%x\n\r", whoami); pc.printf("MPU9250 is online...\n\r"); - lcd.clear(); - lcd.printString("MPU9250 is", 0, 0); + //lcd.clear(); + //lcd.printString("MPU9250 is", 0, 0); sprintf(buffer, "0x%x", whoami); - lcd.printString(buffer, 0, 1); - lcd.printString("shoud be 0x71", 0, 2); + //lcd.printString(buffer, 0, 1); + //lcd.printString("shoud be 0x71", 0, 2); wait(1); mpu9250.resetMPU9250(); // Reset registers to default in preparation for device calibration @@ -118,11 +118,11 @@ pc.printf("Could not connect to MPU9250: \n\r"); pc.printf("%#x \n", whoami); - lcd.clear(); - lcd.printString("MPU9250", 0, 0); - lcd.printString("no connection", 0, 1); + //lcd.clear(); + //lcd.printString("MPU9250", 0, 0); + //lcd.printString("no connection", 0, 1); sprintf(buffer, "WHO_AM_I 0x%x", whoami); - lcd.printString(buffer, 0, 2); + //lcd.printString(buffer, 0, 2); while(1) ; // Loop forever if communication doesn't happen } @@ -179,7 +179,7 @@ mpu9250.MahonyQuaternionUpdate(ax, ay, az, gx*PI/180.0f, gy*PI/180.0f, gz*PI/180.0f, my, mx, mz); // Serial print and/or display at 0.5 s rate independent of data rates - delt_t = t.read_ms() - count; + delt_t = t.read_ms() - counttime; if (delt_t > 500) { // update LCD once per half-second independent of read rate pc.printf("ax = %f", 1000*ax); @@ -238,11 +238,11 @@ // lcd.printString(buffer, 0, 5); myled= !myled; - count = t.read_ms(); + counttime = t.read_ms(); - if(count > 1<<21) { + if(counttime > 1<<21) { t.start(); // start the timer over again if ~30 minutes has passed - count = 0; + counttime = 0; deltat= 0; lastUpdate = t.read_us(); }