Works
Dependencies: BMP180 BNO055_fusion Fonts GPSISR HTU21D SDFileSystem UniGraphic mbed uGUI
Fork of Bicycl_Computer_NUCLEO-F411RE by
Diff: main.cpp
- Revision:
- 12:49600de70963
- Parent:
- 11:869a102dd31c
- Child:
- 13:1a9c0f9d7128
--- a/main.cpp Mon Feb 27 22:37:44 2017 +0000 +++ b/main.cpp Tue Feb 28 01:32:00 2017 +0000 @@ -112,6 +112,8 @@ const int centreX = 120; const int centreY = 150; const int radius = 40; +float last_dx; +float last_dy; int main() { @@ -134,8 +136,8 @@ while (1) { - TFT.set_font((unsigned char*) ArialR20x20); - //check if we recieved a new message from GPS, if so, attempt to parse it, + TFT.set_font((unsigned char*) ArialR20x20); + //check if we recieved a new message from GPS, if so, attempt to parse it, if (refresh_Timer.read_ms() >= refresh_Time) { refresh_Timer.reset(); @@ -159,8 +161,7 @@ TFT.printf("%d%%RH",humidity); //pc.printf("HTU21D Temp: %d",ftemp); //pc.printf("HTU21D Humidity: %d",humidity); - - + if (imu.chip_ready() == 0){ pc.printf("Bosch BNO055 is NOT avirable!!\r\n"); } else { @@ -183,10 +184,8 @@ TFT.printf("No Data"); } } - - float last_dx; - float last_dy; - float angle = int(euler_angles.h * 180/PI); // Convert radians to degrees for more a more usual result + + float angle = int(euler_angles.h); // * 180/PI); // Convert radians to degrees for more a more usual result // For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions float dx = (0.7*radius * cos((angle-90)*PI/180)) + centreX; // calculate X position for the screen coordinates - can be confusing! float dy = (0.7*radius * sin((angle-90)*PI/180)) + centreY; // calculate Y position for the screen coordinates - can be confusing! @@ -195,7 +194,6 @@ last_dx = dx; last_dy = dy; - if (MyGPS.dataready()) { MyGPS.read(); //pc.printf("NMEA has valid data"); @@ -258,6 +256,18 @@ TFT.line(x3, y3, x4, y4, colour); TFT.line(x3, y3, x2, y2, colour); TFT.line(x2, y2, x4, y4, colour); + TFT.set_font((unsigned char*) Arial12x12); + TFT.foreground(Blue); + TFT.background(White); + TFT.locate((centreX-2),(centreY-24)); + TFT.printf("N"); + TFT.locate((centreX-2),(centreY+17)); + TFT.printf("S"); + TFT.locate((centreX+19),(centreY-3)); + TFT.printf("E"); + TFT.locate((centreX-23),(centreY-3)); + TFT.printf("W"); + TFT.set_font((unsigned char*) ArialR20x20); } void Draw_Compass_Rose(void) {