example application with TFT display and SMS receive send
Dependencies: C027 C027_Support SeeedStudioTFTv2 TFT_fonts UbloxUSBModem mbed
Fork of C027_DisplayTest by
This is an application that combines several libraries together and demonstartes the use of cellular, GPS and a Touch enabled TFT on the u-blox C027 board.
Diff: main.cpp
- Revision:
- 4:b18b0bc4142f
- Parent:
- 3:4ec009118465
- Child:
- 5:2d2a14f0e98d
diff -r 4ec009118465 -r b18b0bc4142f main.cpp --- a/main.cpp Mon Oct 21 19:55:45 2013 +0000 +++ b/main.cpp Fri Oct 25 13:06:15 2013 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "C027.h" #include "GPS.h" +#include "SerialPipe.h" #include "SeeedStudioTFTv2.h" #include "Arial12x12.h" @@ -32,24 +33,6 @@ TFT.fillrect(0,0,320,35,White), \ TFT.printf(__VA_ARGS__) -void initC027(void) -{ - DigitalOut mdmEn(MDMEN); - DigitalOut mdmPwrOn(MDMPWRON); - DigitalOut mdmRst(MDMRST); - DigitalOut gpsEn(GPSEN); - DigitalOut gpsRst(GPSRST); - - gpsEn = 1; // LDOEN: 1=on,0=off - gpsRst = 1; // RESET: 0=reset,1=operating - mdmPwrOn = 1; // PWRON: 1=idle,0=action - mdmEn = 1; // LDOEN: 1=on,0=off - mdmRst = 0; // RESET: 0=reset,1=operating - Thread::wait(100); // power on sequence is triggered by 50ms reset low and wait for supplies ready - mdmRst = 1; // RESET: 1=operating,0=reset - Thread::wait(3000);// modem will be ready after 3 seconds -} - int main() { SeeedStudioTFTv2 TFT(A3, A1, A2, A0, @@ -67,10 +50,11 @@ TFT.locate(70,220); TFT.printf("u-blox C027-C20/U20/G35"); - initC027(); - //C027 c027; - //c027.mdmPower(true); - GPS gps; + C027 c027; + c027.mdmPower(true); + c027.gpsPower(true); + + GPSI2C gps; UbloxUSBGSMModem modem; size_t count; @@ -128,7 +112,7 @@ } } int ret; - while ((ret = gps.getGPS(msg, sizeof(msg))) > 0) + while ((ret = gps.getMessage(msg, sizeof(msg))) > 0) { int len = LENGTH(ret); if (PROTOCOL(ret) == NMEA && !strncmp("$GPGLL", msg, 6)) @@ -136,6 +120,8 @@ double la = 0, lo = 0; char cLa = 0, cLo = 0, ch = 0; TFT.fillrect(220,175,320,210,White); + TFT.locate(220,175); + TFT.printf(" GPS"); if (gps.getNmeaItem(1,msg,len,la) && gps.getNmeaItem(2,msg,len,cLa) && gps.getNmeaItem(3,msg,len,lo) && gps.getNmeaItem(4,msg,len,cLo) && gps.getNmeaItem(6,msg,len,ch) && ch == 'A') @@ -149,8 +135,6 @@ if (cLa == 'S') la = -la; if (cLo == 'N') lo = -lo; - TFT.locate(220,175); - TFT.printf(" GPS"); TFT.locate(220,187); TFT.printf("%11.6f ", la); TFT.locate(220,199);