Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Files at this revision

API Documentation at this revision

Comitter:
AntonLS
Date:
Sat Jan 16 03:16:06 2016 +0000
Parent:
53:c1c3e65b4542
Child:
55:b3cb69d69ce8
Commit message:
Low battery pulse--temp. Freeform random bugfix.

Changed in this revision

TA.cpp Show annotated file Show diff for this revision Revisions of this file
TA.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
proto_code.cpp Show annotated file Show diff for this revision Revisions of this file
types.h Show annotated file Show diff for this revision Revisions of this file
--- a/TA.cpp	Sat Jan 16 00:36:20 2016 +0000
+++ b/TA.cpp	Sat Jan 16 03:16:06 2016 +0000
@@ -130,6 +130,7 @@
 
 DigitalOut TA::buzzPin( p20, BUZZ_OFF );
 
+bool    TA::batteryLow    = false;
 uint8_t TA::buttonsRising = 0;
 
 #if 1
--- a/TA.h	Sat Jan 16 00:36:20 2016 +0000
+++ b/TA.h	Sat Jan 16 03:16:06 2016 +0000
@@ -112,6 +112,7 @@
 char data[DATA_SIZE];
 //static uint8_t networkID;         // network group
 
+static bool    batteryLow;
 static uint8_t buttonsRising;
 
 void post_color(uint32_t rgb);
@@ -121,6 +122,7 @@
 void powerup(uint8_t);
 void pulse(uint16_t on_time, uint16_t period, uint16_t ms, uint32_t rgb);
 void pulse_off(void);
+bool isPulsing(void){  return  pulsing;  }
 int get_buffer_size(void);
 bool send(Message *m);
 void send_immediate(Message *m);
--- a/main.cpp	Sat Jan 16 00:36:20 2016 +0000
+++ b/main.cpp	Sat Jan 16 03:16:06 2016 +0000
@@ -281,6 +281,8 @@
           wasCharging = true;  // Force show when done charging.
       }
 
+    if( pct <= 10 )  ta.batteryLow = true;
+
     batt_and_id[2] = pct;
     ble.clearAdvertisingPayload();
     setAdvData();
--- 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
   
--- a/types.h	Sat Jan 16 00:36:20 2016 +0000
+++ b/types.h	Sat Jan 16 03:16:06 2016 +0000
@@ -11,8 +11,8 @@
 #define SL_DEBUG(...)  /* Nothing */
 #endif
 
-#define MASTER
-//#define SLAVE
+//#define MASTER
+#define SLAVE
 
 // these must be here because of magic in the Arduino IDE (otherwise functions cannot retun these types
 #ifdef MASTER