Saltware / Mbed 2 deprecated Water Play

Dependencies:   mbed DRV88255 TextLCD Ping mbed-rtos

Revision:
11:1a0a8fd74bc0
Parent:
10:fd4670ec0806
Child:
12:c51f3aba84fe
--- a/main.cpp	Fri Jun 10 22:21:04 2016 +0000
+++ b/main.cpp	Fri Jun 10 22:34:57 2016 +0000
@@ -11,6 +11,7 @@
 #include "mbed.h"
 #include "rtos.h"
 
+#define MAIN_THREAD_DELAY_MS 1000
 
 int main() 
 {
@@ -48,20 +49,28 @@
     
     while(1) {
         
-        Thread::wait(1000);
+        Thread::wait(MAIN_THREAD_DELAY_MS);
         
         vector<void *>::iterator v = controllers.begin();
         while(v != controllers.end()) {
+            
+            // Get the next controller
             Controller *c = ((Controller *)*v);
+            
             if(!c->is_threaded())
                 cout << "Running " << c->get_name() << " from main loop" << "\r\n";
+            
+            // The controller only updates here if it's not threaded
             c->run();
+            
+            // Advance to the next controller
             v++;
         }
         
-        // if alarm then update lcd and exit
+        // if the alarm controller detected a dangerous situation then update lcd and exit
+        // TODO maybe signal threads to terminate
         if(alarm.is_error()) {
-            lcd.error(alarm.get_error_string());    
+            lcd.error(alarm.get_error_message());    
             break;
         }        
 
@@ -74,6 +83,7 @@
         printf("Grabbing distance value from main thread: %f\r\n", d);
         
         
+        // Show either temperature and salinity or the water level given by the proximity controller
         if(i++ % 2)
             lcd.updateScreen(t, s);
         else