CIS441 Proj MS 2b

Dependencies:   TextLCD MQTT

Revision:
11:2ab3397b6e30
Parent:
10:8df624795295
Child:
12:ade22f4681af
--- a/main.cpp	Thu Dec 12 23:14:19 2019 +0000
+++ b/main.cpp	Fri Dec 13 03:23:31 2019 +0000
@@ -13,7 +13,7 @@
 // main() runs in its own thread in the OS
 int main() {
     Communication::init();
-    wait(5);
+    wait(2);
     printf("starting simulation/r/n");
     // ------------------------------------------------------------------------------
     // The following three variables are used for timing statistics, do not modify them
@@ -44,22 +44,22 @@
         printf("\r\nRoad 1 Update %d\r\n", time);
         road1.print_status();
         
-    if(new_cars == -1 && road1.intersection_car == -1){
-            lcd.printf("x, x");
-    }
-    else if(new_cars != -1 && road1.intersection_car == -1){
-        lcd.printf("%d, x", new_cars);
-    }
-    else if(new_cars == -1 && road1.intersection_car != -1){
-        lcd.printf("x, %d", road1.intersection_car);
-    }
-    else{
-        lcd.printf("%d, %d", new_cars, road1.intersection_car);
-    }
+        if(new_cars == -1 && road1.intersection_car == -1){
+                lcd.printf("x, x");
+        }
+        else if(new_cars != -1 && road1.intersection_car == -1){
+            lcd.printf("%d, x", new_cars);
+        }
+        else if(new_cars == -1 && road1.intersection_car != -1){
+            lcd.printf("x, %d", road1.intersection_car);
+        }
+        else{
+            lcd.printf("%d, %d", new_cars, road1.intersection_car);
+        }
 
 
         printf("\r\n");
-    road1.check_exit_cars(return_cars);
+        road1.check_exit_cars(return_cars);
 
         time++;
         
@@ -75,9 +75,9 @@
         road1.publish_car_info();
         Communication::publish_road_ready();
         printf("published car info\r\n");
-        int do_nothing = 1;
+        Communication::yield(); 
         while(Road::ready(-1) == 0) {
-            do_nothing++;
+            Communication::yield(); 
         }
     } while( road1.active_cars > 0x00);