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.
Fork of MODGPS by
example2.cpp
00001 #ifdef COMPILE_EXAMPLE2_CODE_MODGPS 00002 00003 #include "mbed.h" 00004 #include "GPS.h" 00005 00006 Serial pc(USBTX, USBRX); 00007 DigitalOut led1(LED1); 00008 DigitalOut led2(LED2); 00009 DigitalOut led3(LED3); 00010 DigitalOut led4(LED4); 00011 00012 Timeout t2, t3, t4; 00013 00014 void t2out(void) { led2 = 0; } 00015 void t3out(void) { led3 = 0; } 00016 void t4out(void) { led4 = 0; } 00017 00018 void blip2(void) { led2 = 1; t2.attach(&t2out, 0.1); } 00019 void blip3(void) { led3 = 1; t3.attach(&t3out, 0.1); } 00020 void blip4(void) { led4 = 1; t4.attach(&t4out, 0.1); } 00021 00022 int main() { 00023 GPS *gps = new GPS(NC, p25); 00024 GPS_Time q1; 00025 GPS_Geodetic *geo; 00026 00027 pc.baud(115200); 00028 00029 gps->baud(9600); 00030 gps->format(8, Serial::None, 1); 00031 00032 gps->ppsAttach(p29, GPS::ppsFall ); 00033 00034 gps->attach_pps(&blip2); 00035 gps->attach_gga(&blip3); 00036 gps->attach_rmc(&blip4); 00037 00038 while(1) { 00039 // Every 3 seconds, flip LED1 and print the basic GPS info. 00040 wait(3); 00041 flip1(); 00042 pc.printf("Method 1. Lat = %.4f ", gps->latitude()); 00043 pc.printf("Lon = %.4f ", gps->longitude()); 00044 pc.printf("Alt = %.4f ", gps->altitude()); 00045 gps->timeNow(&q1); 00046 pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n", 00047 q1.hour, q1.minute, q1.second, q1.day, q1.month, q1.year); 00048 00049 // Alternative method that does the same thing. 00050 geo = gps->geodetic(); 00051 pc.printf("Method 2. Lat = %.4f ", geo->lat); 00052 pc.printf("Lon = %.4f ", geo->lon); 00053 pc.printf("Alt = %.4f ", geo->alt); 00054 delete(geo); 00055 00056 GPS_Time *q2 = gps->timeNow(); 00057 pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n\n", 00058 q2->hour, q2->minute, q2->second, q2->day, q2->month, q2->year); 00059 delete(q2); 00060 } 00061 } 00062 00063 #endif
Generated on Thu Jul 14 2022 07:39:12 by
1.7.2
