This is a fork of a functional ILI9341 display with a functional Seeed touch screen library.
Dependencies: BMP180 UniGraphic mbed BNO055_fusionI_fixed HTU21D GPSISR Compass Fonts uGUI
Fork of TFT_test_NUCLEO-F411RE by
Had to move sensors to a remote board because of interference. Added spi burst mode to supported displays.
To do.... ugui buttons are slow. will need to add rtos to project. Finish other way points screen. Will have to rewrite portions of the touch screen class. Sense touch, delay, read values and then average, touch released, is the sequence. Add cadence input and logic to program for computer screen.
Diff: main.cpp
- Revision:
- 18:50520438c129
- Parent:
- 15:27e0a1721d13
- Child:
- 20:3ada4387cc1b
--- a/main.cpp Fri Apr 28 01:53:32 2017 +0000 +++ b/main.cpp Fri Aug 04 19:54:48 2017 +0000 @@ -30,11 +30,9 @@ #include "BNO055.h" #include "HTU21D.h" #include "BMP180.h" -#include "SDFileSystem.h" #include "GPSISR.h" #include "nav.h" - #include "ArialR16x17.h" #include "Arial24x23i.h" #include "Arial28x28.h" @@ -42,7 +40,7 @@ #include "SCProSB31x55.h" #include "Arial12x12.h" #include "ArialR20x20.h" -#include "Compass.h" +#include "compass.h" //#define PIN_CS_TSC PA_9 //#define PIN_TSC_INTR PA_8 @@ -115,9 +113,6 @@ // Pressure BMP180 bmp180(I2C_SDA, I2C_SCL); -// SD Card Reader On Adafruit GPS Shield -SDFileSystem sd(PIN_MOSI_SPI3, PIN_MISO_SPI3, PIN_SCLK_SPI3, PIN_CS_SPI3, "sd"); // the pinout on the mbed Cool Components workshop board - // Set up serial interrupe service handler for gps characters. GPS MyGPS(PIN_TX_GPS,PIN_RX_GPS, 9600); @@ -135,8 +130,8 @@ void cb1(void); const int centreX = 120; -const int centreY = 150; -const int radius = 40; +const int centreY = 136; +const int radius = 104; float last_dx; float last_dy; @@ -146,14 +141,6 @@ #define PAGE2 2 #define PAGE3 3 -const UG_BMP compass = { - (void*) compass_bmp , - 200 , - 200 , - BMP_BPP_16 , - BMP_RGB565 -} ; - UG_GUI gui; //Ticker to1; @@ -242,14 +229,7 @@ UG_ButtonSetFont (&window_3 , BTN_ID_5 , &FONT_8X8) ; UG_ButtonSetText (&window_3 , BTN_ID_4 , "Prev" ); UG_ButtonSetText (&window_3 , BTN_ID_5 , "Next" ); - - /* Finally , show the window */ - //UG_WindowShow(&window_1) ; - //UG_WindowHide(&window_2); - //UG_WindowHide(&window_3); - - //UG_Update(); - + while (1) { cb1(); @@ -297,7 +277,7 @@ TFT.printf("%d%%",humidity); if (MyGPS.dataready()) { MyGPS.read(); - TFT.locate(10, 35) ; + TFT.locate(10, 40) ; TFT.foreground(UG_WindowGetBackColor(&window_1)); TFT.printf("No GPS Data"); TFT.foreground(White); @@ -331,8 +311,8 @@ //double waypoint = nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon)/double(1609.344); //TFT.printf("%.1fMI From Perry", waypoint); } else { - TFT.locate(10, 26) ; - TFT.printf("No GPS Data"); + TFT.locate(10, 40) ; + TFT.printf("No GPS Data "); //pc.printf("NMEA has no valid data"); } break; @@ -343,9 +323,29 @@ UG_WindowHide(&window_3); UG_WindowShow(&window_2); UG_Update(); - TFT.Bitmap(10,20,200,200,(unsigned char*)compass_bmp); + TFT.drawXBitmap(20,35,compass,compass_width,compass_height,C_WHITE); + } + pageinit = 1; + if (imu.read_calib_status() > 0x0) { + imu.get_Euler_Angles(&euler_angles); + float angle = euler_angles.h; // Convert radians to degrees for more a more usual result + + TFT.set_font((unsigned char*) ArialR20x20); + TFT.foreground(White); + TFT.background(UG_WindowGetBackColor(&window_1)); + TFT.locate(10, 224) ; + TFT.printf("%.1f*", euler_angles.h); + + // For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions + float dx = (radius * cos((angle-90)*PI/180)) + centreX; // calculate X position for the screen coordinates - can be confusing! + float dy = (radius * sin((angle-90)*PI/180)) + centreY; // calculate Y position for the screen coordinates - can be confusing! + arrow(last_dx,last_dy, centreX, centreY, 2,2,UG_WindowGetBackColor(&window_2)); // Erase last arrow + arrow(dx,dy, centreX, centreY, 2, 2,C_WHITE); // Draw arrow in new position + last_dx = dx; + last_dy = dy; } - pageinit = 1; + + break; } case PAGE3: { @@ -408,14 +408,7 @@ } } - float angle = euler_angles.h; // 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 = (radius * cos((angle-90)*PI/180)) + centreX; // calculate X position for the screen coordinates - can be confusing! - float dy = (radius * sin((angle-90)*PI/180)) + centreY; // calculate Y position for the screen coordinates - can be confusing! - arrow(last_dx,last_dy, centreX, centreY, 2,2,White); // Erase last arrow - arrow(dx,dy, centreX, centreY, 2, 2,Blue); // Draw arrow in new position - last_dx = dx; - last_dy = dy; + } @@ -437,22 +430,7 @@ y3 = x2o * k + dy; x4 = dx - y2o * k; y4 = dy - x2o * k; - TFT.line(x1, y1, x2, y2, colour); - TFT.line(x1, y1, dx, dy, colour); - 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.fillcircle(x3,y3,2,colour); TFT.set_font((unsigned char*) ArialR20x20); }