CIS441 Proj MS 2b

Dependencies:   TextLCD MQTT

Revision:
16:cb7cbf2cc23b
Parent:
14:8b65b1f342ee
--- a/main.cpp	Fri Dec 13 21:31:24 2019 +0000
+++ b/main.cpp	Fri Dec 13 22:14:27 2019 +0000
@@ -62,17 +62,23 @@
         printf("successful publish: car info\r\n");
         Communication::publish_road_ready();
         
-        Communication::yield(500); 
+        Communication::yield(50); 
         while(Road::ready(-1) == 0) {
             Communication::yield(50); 
         }
+        road1.update_wait_counter(); 
         printf("----------------------\r\n"); 
     } while( road1.active_cars > 0x00);
     
     // ----------------------------------------------------------------------
     // Timing statistics printout, do not modify
+    printf("Average Wait Time: %fs \r\n", road1.wait_counter / 5.0); 
     printf("Average update cycle took: %fms \r\n", (totalUpdateTime*1.0)/(numberCycles*1.0));
     totalUpdateTime = 0;
     numberCycles = 0;
     // ----------------------------------------------------------------------
+    while (true) {
+        Communication::publish_road_ready();
+        wait(0.1); 
+    }
 }