Guides the user to their classes

Dependencies:   4DGL-uLCD-SE Course SDFileSystem mbed PinDetect LSM9DS1_Library_cal MBed_Adafruit-GPS-Library

Revision:
6:ceb6a5426add
Parent:
5:430f44669f94
Child:
7:e4d667beaf33
diff -r 430f44669f94 -r ceb6a5426add main.cpp
--- a/main.cpp	Thu Dec 08 19:34:36 2016 +0000
+++ b/main.cpp	Thu Dec 08 20:20:00 2016 +0000
@@ -24,6 +24,7 @@
 int getNextClass(vector<Course>& cVec);
 void displayCourseVec();
 float calculateHeading(float mx, float my), computeAngleToDestination(float diffLat, float diffLong);
+float longToDecimal(float longitudeInDDMM), latToDecimal(float latitudeInDDMM);
 int xEnd, yEnd = 0.0;
 int currHour, currMinute, currSecond = 0;
 int hoursToNextClass, minutesToNextClass, secondsToNextClass = 0;
@@ -82,7 +83,7 @@
 
     readClassFile(courseVec);
 
-    Course tempCourse("COC", 2, 35, "PM");
+    Course tempCourse("COC", 4, 00, "PM");
     courseVec.push_back(tempCourse);
 
     gps_Serial = new Serial(p28,p27); //serial object for use w/ GPS
@@ -129,6 +130,11 @@
 
         if (refresh_Timer.read_ms() >= refresh_Time) {
             refresh_Timer.reset();
+            if (myGPS.fix) {
+                myLat = latToDecimal(myGPS.latitude);
+                myLong = longToDecimal(myGPS.longitude);
+            }
+ 
             currHour = myGPS.hour - 5; //for eastern time zone
             if (currHour < 0)
                 currHour += 24;
@@ -204,18 +210,18 @@
                     break;
                 case 2:
                     //uLCD.cls();
-                    uLCD.locate(0,0);
+                    uLCD.locate(0,3);
                     uLCD.printf("Time to next class");
-                    uLCD.locate(0, 1);
+                    uLCD.locate(0, 4);
                     uLCD.printf("%02dhrs %02dminutes", hoursToNextClass, minutesToNextClass);
-                    uLCD.locate(0, 2);
+                    uLCD.locate(0, 5);
                     uLCD.printf("%02dseconds", secondsToNextClass);
-                    uLCD.locate(0, 4);
+                    uLCD.locate(0, 0);
                     uLCD.printf("Next class");
                     if (nextClass != currClass) {
-                        uLCD.locate(0, 5);
+                        uLCD.locate(0, 1);
                         uLCD.printf("                     ");
-                        uLCD.locate(0, 5);
+                        uLCD.locate(0, 1);
                         uLCD.printf("%s", courseVec[nextClass].getDisplayString());
                     }
                     currClass = nextClass;
@@ -362,7 +368,7 @@
 }
 
 void timeToNextClass()
-{   
+{
     hoursToNextClass = courseVec[nextClass].getHour_inMilitaryTime() - currHour;
     if (hoursToNextClass < 0)
         hoursToNextClass += 24;
@@ -372,18 +378,38 @@
         hoursToNextClass--;
         minutesToNextClass += 60;
     }
-    
+
     secondsToNextClass = 60 - currSecond;
     minutesToNextClass--;
-    
+
     if (minutesToNextClass < 0) {
         hoursToNextClass--;
         minutesToNextClass += 60;
     }
-    
+
     if (hoursToNextClass < 0)
         hoursToNextClass += 24;
-    
-    
-    
+}
+
+// convert from DDMM.mmmm to decimal
+float latToDecimal(float latitudeInDDMM)
+{
+    float latInDec = 0.0;
+    float temp = 0.0;
+    latInDec = latitudeInDDMM / 100;
+    temp = latInDec - floor(latInDec);
+    temp = temp / .6;
+    latInDec = floor(latInDec) + temp;
+    return latInDec;
+}
+
+float longToDecimal(float longitudeInDDMM)
+{
+    float longInDec = 0.0;
+    float temp = 0.0;
+    longInDec = longitudeInDDMM / 100;
+    temp = longInDec - floor(longInDec);
+    temp = temp / .6;
+    longInDec = floor(longInDec) + temp;
+    return -1 * longInDec;
 }
\ No newline at end of file