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.
Revision 18:50520438c129, committed 2017-08-04
- Comitter:
- trevieze
- Date:
- Fri Aug 04 19:54:48 2017 +0000
- Parent:
- 16:01d9a8509b43
- Child:
- 19:096bcabf2dab
- Commit message:
- Compass is now functioning. With the help of brilliant real software engineers I was able to rescue this program. Thanks everyone!
Changed in this revision
--- a/BNO055_fusion.lib Fri Apr 28 01:53:32 2017 +0000 +++ b/BNO055_fusion.lib Fri Aug 04 19:54:48 2017 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/kenjiArai/code/BNO055_fusion/#9e6fead1e93e +http://developer.mbed.org/users/kenjiArai/code/BNO055_fusion/#d77acb6b3980
--- a/Compass.lib Fri Apr 28 01:53:32 2017 +0000 +++ b/Compass.lib Fri Aug 04 19:54:48 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/trevieze/code/Compass/#bd19b421b4ca +https://developer.mbed.org/users/trevieze/code/Compass/#222fab8fd312
--- a/SDFileSystem.lib Fri Apr 28 01:53:32 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/trevieze/code/SDFileSystem/#11c2f296777f
--- a/SeeedStudioTFTv2.cpp Fri Apr 28 01:53:32 2017 +0000 +++ b/SeeedStudioTFTv2.cpp Fri Aug 04 19:54:48 2017 +0000 @@ -15,8 +15,11 @@ #include "mbed.h" #include "SeeedStudioTFTv2.h" +//#include "SmoothAnalogIn.h" -//Serial pc(USBTX,USBRX,19200); +extern Serial pc; +//SmoothAnalogIn analogY(PIN_YP, .1, 1, 1); +//SmoothAnalogIn analogX(PIN_XP, .1, 1, 1); TouchScreen::TouchScreen(PinName xp, PinName xm, PinName yp, PinName ym) { @@ -32,6 +35,7 @@ y_off = 22000; // 22330 105819 97167 22000 pp_tx = -291; // 378 289 -390 -291 pp_ty = 356; // 261 -355 -239 356 + } int TouchScreen::readTouch(PinName p, PinName m, PinName a, PinName i)
--- a/SeeedStudioTFTv2.h Fri Apr 28 01:53:32 2017 +0000 +++ b/SeeedStudioTFTv2.h Fri Aug 04 19:54:48 2017 +0000 @@ -30,6 +30,11 @@ #define TS_MINY 12500 //83*2 #define TS_MAXY 116044 //913*2 +#define PIN_XP A3 +#define PIN_XM A1 +#define PIN_YP A2 +#define PIN_YM A0 + struct point { int x; int y;
--- a/UniGraphic.lib Fri Apr 28 01:53:32 2017 +0000 +++ b/UniGraphic.lib Fri Aug 04 19:54:48 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/trevieze/code/UniGraphic/#7eea44b19734 +https://developer.mbed.org/users/trevieze/code/UniGraphic/#0ced7cf0ec8c
--- 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); }
--- a/mbed.bld Fri Apr 28 01:53:32 2017 +0000 +++ b/mbed.bld Fri Aug 04 19:54:48 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f \ No newline at end of file +https://mbed.org/users/mbed_official/code/mbed/builds/a97add6d7e64 \ No newline at end of file