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:
- 7:8aa9cdab4a07
- Parent:
- 6:b78ff34209e5
- Child:
- 8:855884782f67
--- a/main.cpp Fri Jan 20 20:46:41 2017 +0000 +++ b/main.cpp Fri Feb 10 17:58:22 2017 +0000 @@ -26,27 +26,38 @@ #include "BNO055.h" #include "HTU21D.h" #include "BMP180.h" +#include "SDFileSystem.h" +#include "GPSISR.h" +#include "nmea.h" #include "Arial12x12.h" #include "Arial24x23.h" #include "Arial28x28.h" #include "Arial43x48_numb.h" -#define PIN_CS_TSC PA_9 -#define PIN_TSC_INTR PA_8 +//#define PIN_CS_TSC PA_9 +//#define PIN_TSC_INTR PA_8 #define PIN_RESET_TFT PC_13 /* place holder */ - +//ILI9341 SPI PINS #define PIN_XP A3 #define PIN_XM A1 #define PIN_YP A2 #define PIN_YM A0 -#define PIN_MOSI D11 -#define PIN_MISO D12 -#define PIN_SCLK D13 -#define PIN_CS_TFT D5 +#define PIN_MOSI_SPI1 D11 //SPI 1 MOSI +#define PIN_MISO_SPI1 D12 //SPI 1 MISO +#define PIN_SCLK_SPI1 D13 //SPI 1 SLCK +#define PIN_CS_SPI1 D5 // SPI CS D10 Was D5 #define PIN_DC_TFT D6 #define PIN_CS_SD D4 #define PIN_RESET D7 +// SD Card on GPS shield PINS +#define PIN_MOSI_SPI3 PB_15 //SPI 1 MOSI +#define PIN_MISO_SPI3 PB_14 //SPI 1 MISO +#define PIN_SCLK_SPI3 PB_13 //SPI 1 SLCK +#define PIN_CS_SPI3 D2 // SPI CS +#define PIN_RX_GPS PA_12 //GPS Shield RX pin +#define PIN_TX_GPS PA_11 //GPS Shield TX pin + BNO055_ID_INF_TypeDef bno055_id_inf; BNO055_EULER_TypeDef euler_angles; @@ -66,10 +77,12 @@ // DigitalOut tsc_cs(PA_9, 1) ; // DigitalOut tft_cs(PB_6, 1) ; +Serial pc(USBTX, USBRX); + // Display ILI9341 TFT(SPI_8, 10000000, - PIN_MOSI, PIN_MISO, PIN_SCLK, - PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8"); + PIN_MOSI_SPI1, PIN_MISO_SPI1, PIN_SCLK_SPI1, + PIN_CS_SPI1, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ; // TouchScreen TouchScreen TSC(PIN_XP, PIN_XM, PIN_YP, PIN_YM); @@ -83,6 +96,13 @@ // 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 + +// Adafruit GPS Shield +GPS MyGPS(PIN_TX_GPS,PIN_RX_GPS, 9600); +NMEA nmea; + int page = 0 ; int numPage = 2 ; @@ -110,7 +130,7 @@ TFT.set_font((unsigned char*) Arial24x23); TFT.foreground(Red) ; TFT.locate(80, 40) ; - TFT.printf("MBED"); + TFT.printf("MBED") ; TFT.foreground(Blue); TFT.locate(60, 80) ; TFT.printf("2.8\"TFT") ; @@ -220,19 +240,37 @@ } } + int main() { + //MyGPS._gps.attach(&MyGPS,&GPS::Rx_interrupt, Serial::RxIrq); + //GPS myGPS(PIN_TX_GPS,PIN_RX_GPS); + Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info? + const int refresh_Time = 100; //refresh time in ms - if (bmp180.init() != 0) { - printf("Error communicating with BMP180\n"); - } else { - printf("Initialized BMP180\n"); - - } - wait(1); + refresh_Timer.start(); //starts the clock on the timer + TFT.BusEnable(true) ; + //backlight = 0 ; + TFT.background(White) ; + wait(0.1) ; + TFT.cls() ; + wait(0.1) ; + while (1) { + //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(); + //pc.printf("Time: %f\n", myGPS.time); + //MyGPS.getline(); + //pc.printf("%s", MyGPS.msg[0]); + pc.printf("rx_int: %c ", MyGPS.rx_in); + TFT.set_font((unsigned char*) Arial12x12); + TFT.foreground(Blue); + TFT.locate(2, 2); + //TFT.printf("Time: %f\n", myGPS.time); + TFT.BusEnable(false) ; + } + } - - // uint16_t x, y, z ; int prevPage = 99 ; bool waitTouch = false ; @@ -269,15 +307,6 @@ // tft_cs = 1 ; do { TSC.getTouch(p); - - bmp180.startTemperature(); - wait_ms(5); // Wait for conversion to complete - float temp; - if(bmp180.getTemperature(&temp) != 0) { - printf("Error getting temperature\n"); - } - printf("Temperature is -> %.2f\n", temp); - //printf("Touched X %d\n\r", p.x) ; //printf("Touched Y %d\n\r", p.y) ; //printf("Touched Z %d\n\r", p.z) ;