Library to operate GPS 20u7 with Mbed

Dependencies:   TinyGPS mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "gps.h"
00002 
00003 // serial
00004 GPS gps(p13, p14);
00005 Serial serial_pc(USBTX, USBRX);    // tx, rx
00006 
00007 
00008 
00009 
00010 int main() {
00011    
00012    serial_pc.printf("Hello World\n");
00013 
00014 
00015  while(1) {
00016            if(gps.isConnected()){
00017                //serial_pc.printf("Serial device is here \n"); 
00018                if(gps.isLocked()){
00019                    gps.parseNMEA();
00020                     
00021             serial_pc.printf("UTC: %d-%02d-%02d %02d:%02d:%02d, \n\r", gps.year, gps.month, gps.day, gps.hour, gps.minute, gps.second);
00022             serial_pc.printf("As doubles- Latitude: %f, Longitude: %f Altitude: %f Course: %f \n\r", gps.f_lat, gps.f_lon, gps.f_altitude, gps.f_course);
00023             serial_pc.printf("Speed: %f mph, %f mps, %f kmph \n\r", gps.mph, gps.mps, gps.kmph);
00024             serial_pc.printf("Horizontal Dilution as double: %f \n\r", gps.f_hdop);  
00025             serial_pc.printf("Less Precise- Latitude: %l, Longitude: %l Altitude: %l Course: %ul \n\r", gps.lat, gps.lon, gps.altitude, gps.course);
00026             serial_pc.printf("Horizontal Dilution as long: %f \n\r", gps.hdop); 
00027             serial_pc.printf("Age of fix: %lu ms \n\r", gps.age); 
00028             serial_pc.printf("Number of Satelites: %lu Speed: %lu 1/100ths of a knot \n\r", gps.sat_count, gps.speed);  
00029             wait(5);  
00030         }
00031     }
00032 }
00033 }