Zack Braun
/
GPS_20u7
Library to operate GPS 20u7 with Mbed
Embed:
(wiki syntax)
Show/hide line numbers
gps.cpp
00001 #include "gps.h" 00002 00003 00004 GPS::GPS(PinName tx, PinName rx) : _gps(tx, rx) { 00005 _gps.baud(9600); 00006 00007 } 00008 00009 bool GPS::isConnected() { 00010 00011 return _gps.readable(); 00012 00013 } 00014 00015 bool GPS::isLocked(){ 00016 00017 return(gpsr.encode(_gps.getc())); 00018 00019 } 00020 00021 void GPS::parseNMEA(){ 00022 (void)gpsr.crack_datetime(&year, &month, &day, &hour, &minute, &second); 00023 sat_count = gpsr.sat_count(); 00024 00025 00026 (void)gpsr.f_get_position(&f_lat, &f_lon, &age); //fix age in milliseoconds 00027 f_altitude = gpsr.f_altitude(); 00028 f_course = gpsr.f_course(); //course over ground Magnetic Variation in degrees 00029 f_hdop = gpsr.f_hdop(); //horizontal dilution of precision 00030 kmph = gpsr.f_speed_kmph(); 00031 knots = gpsr.f_speed_knots(); 00032 mph = gpsr.f_speed_mph(); 00033 mps = gpsr.f_speed_mps(); 00034 00035 00036 (void)gpsr.get_position(&lat, &lon, &age); //fix age in milliseoconds 00037 altitude = gpsr.altitude(); 00038 course = gpsr.course(); //course over ground Magnetic Variation in degrees 00039 hdop = gpsr.hdop(); //horizontal dilution of precision 00040 speed = gpsr.speed(); //speed in 100ths of a knot 00041 }
Generated on Sat Jul 16 2022 01:40:30 by 1.7.2