Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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.
Revision 11:5c7f76702799, committed 2014-03-17
- Comitter:
- amwe
- Date:
- Mon Mar 17 13:15:51 2014 +0000
- Parent:
- 10:2b1e6015e413
- Commit message:
- Back to rev 9
Changed in this revision
--- a/C12832.lib Mon Mar 17 10:34:37 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/chris/code/C12832/#7de323fa46fe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SeeedStudioTFTv2.lib Mon Mar 17 13:15:51 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mazgch/code/SeeedStudioTFTv2/#f2aaffad7d38
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TFT_fonts.lib Mon Mar 17 13:15:51 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/dreschpe/code/TFT_fonts/#76774250fcec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UbloxUSBModem.lib Mon Mar 17 13:15:51 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/UbloxUSBModem/#bc1c98e552ab
--- a/main.cpp Mon Mar 17 10:34:37 2014 +0000
+++ b/main.cpp Mon Mar 17 13:15:51 2014 +0000
@@ -1,42 +1,133 @@
#include "mbed.h"
-#include "C12832.h"
#include "C027.h"
#include "GPS.h"
#include "SerialPipe.h"
-DigitalOut myled(LED);
-C12832 lcd(D11, D13, D12, D7, D10); // jumper connections
+#include "SeeedStudioTFTv2.h"
+#include "Arial12x12.h"
+#include "Arial24x23.h"
+#include "Arial28x28.h"
+#include "font_big.h"
+
+#include "UbloxModem.h"
+
+void ubxLogo(SPI_TFT_ILI9341* tft, int x0/*160*/, int y0/*160*/, int r)
+{
+ int i1=r/8, i1_5=r*3/16, i2=r*2/8, i3=r*3/8,
+ i4=r*4/8, i5=r*5/8, i6=r*6/8, i7=r*7/8;
+ // the ball
+ tft->fillcircle(x0, y0, r, Red);
+ // the dot
+ tft->fillcircle(x0-i2, y0-i3, i1_5, White);
+ // the u
+ tft->fillcircle(x0+i4, y0+i3, i3, White);
+ tft->fillcircle(x0+i4, y0+i3, i1, Red);
+ tft->fillrect( x0+i1, y0-i1, x0+i3, y0+i3, White);
+ tft->fillrect( x0+i3, y0-i1, x0+i5, y0+i3, Red);
+ tft->fillrect( x0+i5, y0-i1, x0+i7, y0+i6, White);
+}
+
+#define info(...) \
+ TFT.locate(0,5), \
+ TFT.fillrect(0,0,320,35,White), \
+ TFT.printf(__VA_ARGS__)
int main()
{
+ SeeedStudioTFTv2 TFT(A3, A1, A2, A0,
+ D11, D12, D13,
+ D5/*tft cs*/, D6/*tft dc*/, D7/*backlight*/,
+ D4/*sd cs*/);
+ TFT.setBacklight(true);
+ TFT.set_font((unsigned char*) Arial12x12); // select the font
+ TFT.set_orientation(3);
+ //TFT.calibrate(); // calibrate the touch
+ TFT.background(White); // set background to black
+ TFT.foreground(Black); // set chars to white
+ TFT.cls(); // clear the screen
+ ubxLogo(&TFT, 160, 120, 80);
+ TFT.locate(70,220);
+ TFT.printf("u-blox C027-C20/U20/G35");
+
C027 c027;
- GPSSerial gps;
+ //c027.mdmUsbEnable(true); // disable this is you plan to use the Serial port on LISA-C
+ c027.mdmPower(true);
c027.gpsPower(true);
- lcd.locate(0,0);
- lcd.printf("u-blox C027-C20/U20/G35");
- lcd.locate(0,11);
- lcd.printf("Positioning demonstrator");
- wait(2.5);
- lcd.cls();
- lcd.locate(0,0);
- lcd.printf("C027 Position:");
+ GPSSerial gps;
+ //UbloxUSBModem modem; // LISA-U or LISA-C, don't forget to call the mdmUsbEnable above
+ UbloxSerModem modem; // LISA-U, LISA-C or SARA-G
+ size_t count;
- char msg[160+1] = "";
-
+ #define MY_IMEI "+41799613242"
+ info(" Cellular Modem\n IMEI: %s", MY_IMEI);
+
+ char num[17] = "", msg[160+1] = "";
+ char link[160] = "";
+ clock_t c = clock();
while(true)
{
+ clock_t n = clock();
+ if ((n - c) > CLOCKS_PER_SEC) // every 3 seconds
+ {
+ int rssi;
+ LinkMonitor::REGISTRATION_STATE state;
+ LinkMonitor::BEARER bearer;
+ if (!modem.getLinkState(&rssi, &state, &bearer))
+ {
+ const char* sState[] =
+ { " ",
+ "REG. ",
+ "DENIED",
+ "NO NET",
+ "HOME ",
+ "ROAM " };
+ const char* sBearer[] =
+ { " ",
+ "GSM 2G ",
+ "EDGE 2.5G",
+ "UMTS 3G ",
+ "HSPA 3G+ ",
+ "LTE 4G " };
+ TFT.locate(0,175);
+ TFT.printf(" %s\n"
+ " %s\n"
+ " %idBm ", sBearer[bearer],sState[state],rssi);
+ }
+ if((state >= LinkMonitor::REGISTRATION_STATE_HOME_NETWORK) && !modem.getSMCount(&count) && (count > 0))
+ {
+ if(!modem.getSM(num, msg, sizeof(msg)))
+ {
+ info(" From: %s\n SMS:%s", num, msg);
+ if (0 == strcmp(msg, "Where are you?") && *link)
+ {
+ modem.sendSM(num, link);
+ }
+ }
+ }
+ c = n;
+ }
+ point p;
+ if (TFT.getPixel(p) && (p.y < 35) && *num)
+ {
+ const char* txt = "Hello from C027 :)";
+ if (OK == modem.sendSM(num, txt))
+ {
+ info(" To: %s\n SMS:%s", num, txt);
+ *num = 0;
+ }
+ }
int ret;
-
while ((ret = gps.getMessage(msg, sizeof(msg))) > 0)
{
-
- printf("%s\n", msg); // for debugging connect PC terminal program 9600 9,1 no flowctrl
int len = LENGTH(ret);
if (PROTOCOL(ret) == NMEA && !strncmp("$GPGLL", msg, 6))
{
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')
@@ -48,14 +139,13 @@
la = (la - iLa) / 0.6 + iLa;
lo = (lo - iLo) / 0.6 + iLo;
if (cLa == 'S') la = -la;
- if (cLo == 'W') lo = -lo;
+ if (cLo == 'N') lo = -lo;
- lcd.locate(0,11);
- lcd.printf("%c", cLa);
- lcd.printf(":%10.6f ", la);
- lcd.locate(0,22);
- lcd.printf("%c", cLo);
- lcd.printf(":%10.6f ", lo);
+ TFT.locate(220,187);
+ TFT.printf("%11.6f ", la);
+ TFT.locate(220,199);
+ TFT.printf("%11.6f ", lo);
+ sprintf(link, "https://maps.google.com/?q=%.5f,%.5f", la, lo);
}
}
}
