Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
41:dee3fd34e37a
Parent:
39:b1f864b71318
Child:
42:ed38b8671e43
--- a/proto_code.cpp	Sat Jan 09 01:32:54 2016 +0000
+++ b/proto_code.cpp	Sat Jan 09 12:04:00 2016 +0000
@@ -682,11 +682,13 @@
     {
       if(i > 1)
       {
-        buffer[i-1] = 0;
-        value = atoi(buffer);
-        
+        buffer[i-1] = 0;        
         if(parameter == 'l')
             value = strtoul(buffer, &endp, 2);
+        else if(parameter == 'B')
+            value = strtoul(buffer, &endp, 16);
+        else
+            value = atoi(buffer);
       }
 
       interpret(parameter, value);
@@ -768,13 +770,37 @@
       }
       else
       {
-        writeToPhone("This pattern is not available.  Please select a value between 1 and %d", SEQUENCES);
+        writeToPhone("This pattern is not available.  Please select a value between 1 and %d\r\n", SEQUENCES);
       }
     }
     break;
+  case 'P':
+    if(value != 0)
+    {
+      if(value <= SEQUENCES && value > 0)
+      {
+        active_sequence = value - 1;
+        cones = (uint8_t*)cone_table + (value-1)*STATIONS;
+        times = (uint16_t*)time_table + (value-1)*STATIONS;
+        masks = (uint8_t*)mask_table + (value-1)*STATIONS;
+
+        // Side effect:  Also sets current station to 1:
+        station = 1;
+      }
+      else
+      {
+        writeToPhone("Only from 1 to %d\r\n", SEQUENCES);
+      }
+    }
+    else  // P; or P0;
+    {
+      writeToPhone("Nothing done\r\n");
+    }
+    break;
   case 's':
+    writeToPhone("Selected station %d\r\n", value);
+  case 'S':
     station = value;
-    writeToPhone("Selected station %d\r\n", value);
     break;
   case 'd':
     if(value == 0){
@@ -793,27 +819,38 @@
     //Serial.println(value);
     break;
   case 'c':
+    writeToPhone("Station %d will be cone %d\r\n", station, value);
+  case 'C':
     c = value;
-    writeToPhone("Station %d will be cone %d\r\n", station, value);
     if(station <= STATIONS && station > 0)cones[station-1] = c;
     break;
   case 't':
     t = (uint16_t)value;
     remainder = t%1000;
     writeToPhone("Station %d split time is: %d.%03d seconds.\r\n", station, t/1000, remainder);
+  case 'T':
+    t = (uint16_t)value;
+//  remainder = t%1000;
 ///    if(remainder < 100)writeToPhone("0");
 ///    if(remainder < 10)writeToPhone("0");
 ///    writeToPhone("%d seconds.\r\n",remainder);
     if(station <= STATIONS && station > 0)times[station-1] = t;
     break;
   case 'l':
-    l = 0;
+//  l = 0;
     l = (uint8_t)value;
     masks[station-1] = l;
     writeToPhone( "Station %d config bits: ", station );
     writeBitsToPhone( l );
     writeToPhone( "\r\n" );
     break;
+  case 'B':  // After setting bits, echo back station data.
+    l = (uint8_t)value;
+    masks[station-1] = l;
+    writeToPhone( "%c%02d;C%02d;T&05d;B%02x\r\n", (1==station) ? 'P'                 : 'S',
+                                                  (1==station) ?  active_sequence +1 : station,
+                                                  cones[station-1], times[station-1], l );
+    break;
   case 'q':
     state_p = IDLE_P;
     new_state = true; // force state reporting, even if we're already in IDLE