Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
54:2878d62714d6
Parent:
53:c1c3e65b4542
Child:
55:b3cb69d69ce8
--- a/proto_code.cpp	Sat Jan 16 00:36:20 2016 +0000
+++ b/proto_code.cpp	Sat Jan 16 03:16:06 2016 +0000
@@ -130,6 +130,7 @@
 static const int success_colour = 0x00FF00; /// 0xFFFF;
 static const int pen_colour     = 0xFFFF00; /// 0x10FF;
 static const int idle_colour    = 0xFF0000; /// 0x00;
+static const int batt_colour    = 0xFFFF00;
 
 char local_input[50] = {0};
 
@@ -349,7 +350,13 @@
       break;
     case IDLE:
       bool act = ta.activated();
-      ta.post_color(act?touch_colour:idle_colour);
+      if( ta.batteryLow && !ta.isPulsing() )  // Temporary feature until batt-low-to-and-in-app.
+      {                                       //  Note:  There's no in-a-run slave cone state--Can trigger during a run.
+          ta.pulse( 75, 500, 1000L, batt_colour );
+          ta.batteryLow = false;
+
+      } else if( !ta.isPulsing() )
+          ta.post_color(act?touch_colour:idle_colour);
       break;
     default:
     break;
@@ -473,7 +480,15 @@
   case IDLE_P:
     ta.setMask( DEFTOUCHMASK );
     if(!in_menu)
-        ta.post_color((ta.activated())?touch_colour:idle_colour);
+    {
+      if( ta.batteryLow && !ta.isPulsing() )  // Temporary feature until batt-low-in-app.
+      {
+          ta.pulse( 75, 500, 1000L, batt_colour );
+          ta.batteryLow = false;
+
+      } else if( !ta.isPulsing() )
+          ta.post_color((ta.activated())?touch_colour:idle_colour);
+    }
     break;
       
   case START_P:
@@ -975,11 +990,11 @@
 
   uint8_t cone;
 
-  uint8_t avail = 1;
-  for( uint8_t i=2; i<=NUM_CONES; i++ )
+  uint8_t avail = 0;
+  for( uint8_t i=1; i<=NUM_CONES; i++ )
     if( active_cones[i] && (i != last_cone) )  ac[avail++] = i;
 
-  cone = ((avail >1) ? ac[rnd() % avail] : 1);
+  cone = ((avail != 0) ? ac[rnd() % avail] : 0);
 
   writeToPhone( "Target cone is %u\r\n", cone );  // PROTOCOL