![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Guides the user to their classes
Dependencies: 4DGL-uLCD-SE Course SDFileSystem mbed PinDetect LSM9DS1_Library_cal MBed_Adafruit-GPS-Library
Diff: main.cpp
- Revision:
- 14:d8a6134cafa3
- Parent:
- 13:0eb9fbd63fb2
- Child:
- 15:75a121b14e5d
--- a/main.cpp Thu Dec 08 23:07:36 2016 +0000 +++ b/main.cpp Thu Dec 08 23:10:41 2016 +0000 @@ -149,15 +149,12 @@ float dis = displacement(diffLat,diffLong); float speed = 3.1; //mph. Source:https://lmgtfy.com/?q=average+human+walking+speed float eta = calc_eta(dis,speed)*60;//(miles, mph)*60 - if(late(eta)==1) - { - uLCD.background_color(RED); - uLCD.text_mode(TRANSPARENT); - } - else - { - uLCD.background_color(BLACK); - uLCD.text_mode(TRANSPARENT); + if(late(eta)==1) { + uLCD.background_color(RED); + uLCD.text_mode(TRANSPARENT); + } else { + uLCD.background_color(BLACK); + uLCD.text_mode(TRANSPARENT); } switch(current_screen) { @@ -415,14 +412,15 @@ float displacement(float diffLat,float diffLong) { - d = sqrt(diffLat*diffLat+diffLong*diffLong); - return d; + float d = sqrt(diffLat*diffLat+diffLong*diffLong); + return d; } float calc_eta(float displacement, float speed) { float eta = displacement/speed; // for displacement. take average speed // convert to minutes later eta = eta+ 0.25*eta; //adding delay for distance vs displacement and traffic lights return eta; +} float longToDecimal(float longitudeInDDMM, char eastOrWest) { @@ -440,12 +438,9 @@ bool late(float eta) { float totalMinutes = hoursToNextClass*60+ minutesToNextClass+ secondsToNextClass/60; - if(totalMinutes>eta) - { + if(totalMinutes>eta) { return 1; - } - else - { + } else { return 0; } -} \ No newline at end of file +}