Zack Braun / Mbed 2 deprecated GPS_20u7

Dependencies:   TinyGPS mbed

Files at this revision

API Documentation at this revision

Comitter:
zbraun6
Date:
Sun Oct 30 05:15:44 2016 +0000
Commit message:
push;

Changed in this revision

TinyGPS.lib Show annotated file Show diff for this revision Revisions of this file
gps.cpp Show annotated file Show diff for this revision Revisions of this file
gps.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 8a73b09fcbe6 TinyGPS.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TinyGPS.lib	Sun Oct 30 05:15:44 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/shimniok/code/TinyGPS/#f522b8bdf987
diff -r 000000000000 -r 8a73b09fcbe6 gps.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gps.cpp	Sun Oct 30 05:15:44 2016 +0000
@@ -0,0 +1,41 @@
+#include "gps.h"
+
+
+GPS::GPS(PinName tx, PinName rx) : _gps(tx, rx) {
+    _gps.baud(9600);
+            
+}
+
+bool GPS::isConnected() {
+     
+     return _gps.readable();
+     
+    }
+    
+bool GPS::isLocked(){
+        
+        return(gpsr.encode(_gps.getc()));
+        
+        }
+        
+void GPS::parseNMEA(){
+    (void)gpsr.crack_datetime(&year, &month, &day, &hour, &minute, &second);
+     sat_count = gpsr.sat_count(); 
+     
+     
+     (void)gpsr.f_get_position(&f_lat, &f_lon, &age); //fix age in milliseoconds
+     f_altitude = gpsr.f_altitude(); 
+     f_course = gpsr.f_course(); //course over ground Magnetic Variation in degrees 
+     f_hdop = gpsr.f_hdop(); //horizontal dilution of precision
+     kmph = gpsr.f_speed_kmph();
+     knots = gpsr.f_speed_knots();
+     mph = gpsr.f_speed_mph();
+     mps = gpsr.f_speed_mps();
+     
+     
+     (void)gpsr.get_position(&lat, &lon, &age); //fix age in milliseoconds
+     altitude = gpsr.altitude(); 
+     course = gpsr.course(); //course over ground Magnetic Variation in degrees 
+     hdop = gpsr.hdop(); //horizontal dilution of precision
+     speed = gpsr.speed(); //speed in 100ths of a knot   
+}    
\ No newline at end of file
diff -r 000000000000 -r 8a73b09fcbe6 gps.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gps.h	Sun Oct 30 05:15:44 2016 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "TinyGPS.h"
+
+#ifndef MBED_GPS_H
+#define MBED_GPS_H
+
+ 
+/**  A GPS interface for reading from a Globalsat EM-406 GPS Module */
+class GPS {
+public:
+ 
+    /** Create the GPS interface, connected to the specified serial port
+     */    
+    GPS(PinName tx, PinName rx);
+    
+    //Checks if GPS (Serial Object) is connected
+    bool isConnected();
+    
+    //Does GPS Module have lock on satellite
+    bool isLocked();
+    
+    //parses incoming NMEA standard strings from GPS Module 
+    void parseNMEA(); 
+    
+    double f_lat, f_lon, f_altitude, f_course, knots,mph, mps,kmph, f_hdop;
+    
+    long lat, lon, altitude, hdop; 
+    
+    unsigned long course, age; //how long a fix has lasted to satellite in ms
+    
+    int year;
+    byte month, day, hour, minute, second;
+    
+    unsigned long sat_count,speed;
+    
+     
+private:
+
+Serial _gps; 
+
+TinyGPS gpsr;
+  
+ 
+};
+ 
+#endif
\ No newline at end of file
diff -r 000000000000 -r 8a73b09fcbe6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 30 05:15:44 2016 +0000
@@ -0,0 +1,33 @@
+#include "gps.h"
+
+// serial
+GPS gps(p13, p14);
+Serial serial_pc(USBTX, USBRX);    // tx, rx
+
+
+
+
+int main() {
+   
+   serial_pc.printf("Hello World\n");
+
+
+ while(1) {
+           if(gps.isConnected()){
+               //serial_pc.printf("Serial device is here \n"); 
+               if(gps.isLocked()){
+                   gps.parseNMEA();
+                    
+            serial_pc.printf("UTC: %d-%02d-%02d %02d:%02d:%02d, \n\r", gps.year, gps.month, gps.day, gps.hour, gps.minute, gps.second);
+            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);
+            serial_pc.printf("Speed: %f mph, %f mps, %f kmph \n\r", gps.mph, gps.mps, gps.kmph);
+            serial_pc.printf("Horizontal Dilution as double: %f \n\r", gps.f_hdop);  
+            serial_pc.printf("Less Precise- Latitude: %l, Longitude: %l Altitude: %l Course: %ul \n\r", gps.lat, gps.lon, gps.altitude, gps.course);
+            serial_pc.printf("Horizontal Dilution as long: %f \n\r", gps.hdop); 
+            serial_pc.printf("Age of fix: %lu ms \n\r", gps.age); 
+            serial_pc.printf("Number of Satelites: %lu Speed: %lu 1/100ths of a knot \n\r", gps.sat_count, gps.speed);  
+            wait(5);  
+        }
+    }
+}
+}
diff -r 000000000000 -r 8a73b09fcbe6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 30 05:15:44 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0
\ No newline at end of file