bug

Dependencies:   GroveGPS_bug

Fork of GroveGPS-Example by Michael Ray

Revision:
1:7239f4aa1605
Parent:
0:39b09b3d8731
--- a/main.cpp	Tue Jan 30 13:47:17 2018 -0600
+++ b/main.cpp	Thu May 31 16:29:40 2018 +0000
@@ -20,34 +20,52 @@
 
 #include "GroveGPS.h"
 
-Serial gps_serial(D1, D0, 9600);
+extern int GPS_init();
+extern GroveGPS gps;
+Thread gpsThread(osPriorityNormal);
 
-Thread gpsThread;
-GroveGPS gps;
 
 // Runs at 1Hz and updates the GPS location every second
 void gps_updater_thread() {
+    int tt, hours, minutes, seconds, tday;
+    int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+    printf("Thread Initialized\r\n");
     while(true) {
         char latBuffer[16], lonBuffer[16];
         gps.getLatitude(latBuffer);
         gps.getLongitude(lonBuffer);
 
         // Utilize latitude and longitude values here
-        printf("Latitude: %f\n, Longitude: %f\n", latBuffer, lonBuffer);
+        printf("\r\nLa=%s Lo=%s\r\n", latBuffer, lonBuffer);
+        tt = gps.gps_zda.utc_time;
+        hours = tt / 10000;
+        tt = tt - (hours*10000);
+        minutes = tt / 100;
+        seconds = tt - (minutes*100);
+        // Correct UTC to PAcific time
+        hours -= 7;
+        tday = gps.gps_zda.day;
+            if(hours < 0) { // UTC Correct
+                hours += 24;
+             tday -= 1;
+             if(!tday) {
+                 tday = months[gps.gps_zda.month];
+                 }
+            }
+        printf("\r\n%02d", seconds);
         wait(1);
     }
 }
 
 int main() {
-
+    GPS_init();
+    printf("GPS Initialized\r\n");
     // Start a thread to get updated GPS values
-    gpsThread.start(gps_updater_thread);
+    gpsThread.start(callback(gps_updater_thread));
 
-    // Read the serial bus to get NMEA GPS details
+    // do nothing while the library does all the work
     while (true) {
-        if (gps_serial.readable()) {
-            gps.readCharacter(gps_serial.getc());
-        }
+
     }
 
     return 0;