Guides the user to their classes

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

Revision:
17:1de531cd3d4a
Parent:
16:4b4e6cf66e7c
diff -r 4b4e6cf66e7c -r 1de531cd3d4a main.cpp
--- a/main.cpp	Fri Dec 09 00:24:58 2016 +0000
+++ b/main.cpp	Fri Dec 09 00:39:19 2016 +0000
@@ -39,9 +39,14 @@
 float displacement(float diffLat,float diffLong);
 float calc_eta(float displacement, float speed);
 bool late(float eta);
-timer t2;
+Timer t2;
+
+bool volatile snooze = 0;
 
-bool snooze = 0;
+void center_callback(void)
+{
+    snooze=1;
+}
 
 void left_callback(void)
 {
@@ -83,11 +88,13 @@
 
     left.mode(PullUp);
     right.mode(PullUp);
+    center.mode(PullUp);
     left.attach_deasserted(&left_callback);
     right.attach_deasserted(&right_callback);
+    center.attach_deasserted(&center_callback);
     left.setSampleFrequency();
     right.setSampleFrequency();
-
+    center.setSampleFrequency();
     readClassFile(courseVec);
 
     gps_Serial = new Serial(p28,p27); //serial object for use w/ GPS
@@ -156,16 +163,16 @@
             if((late(eta)==1)&&(snooze==0)) {
                 uLCD.background_color(RED);
                 uLCD.textbackground_color(RED);
-            } elseif((late(eta)==1)&&(snooze==1)){
+            } else if((late(eta)==1)&&(snooze==1)) {
                 t2.start();
-                if(t2.read>120)//2 minute snooze
-                {
+                if(t2.read()<120) { //2 minute snooze
                     uLCD.background_color(BLACK);
                     uLCD.textbackground_color(BLACK);
+                } else {
+                    t2.stop();
+                    snooze = 0;
                 }
-                t2.stop();
-            }
-            else {
+            } else {
                 uLCD.background_color(BLACK);
                 uLCD.textbackground_color(BLACK);
             }
@@ -461,12 +468,10 @@
 bool late(float eta)
 {
     float totalMinutes = hoursToNextClass*60+ minutesToNextClass+ secondsToNextClass/60;
-    if(totalMinutes>eta) {
+    if(eta>totalMinutes) {
         return 1;
     } else {
         return 0;
     }
 }
-bool snooze()
-{
-}
+