Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
39:b1f864b71318
Parent:
38:76e49d045a3b
Child:
40:dec5270e03e9
Child:
41:dee3fd34e37a
--- a/proto_code.cpp	Fri Jan 08 19:13:02 2016 +0000
+++ b/proto_code.cpp	Sat Jan 09 01:32:54 2016 +0000
@@ -124,13 +124,13 @@
 extern "C" void writeToPhone(char *format, ...);
 
 
-static const int active_colour  = 0x00FF;
-static const int warn_colour    = 0xF050;
-static const int fail_colour    = 0x0000FF;
-static const int touch_colour   = 0x005050;
-static const int success_colour = 0xFFFF;
-static const int pen_colour     = 0x10FF;
-static const int idle_colour    = 0x00;
+static const int active_colour  = 0x00FF00; /// 0x00FF;
+static const int warn_colour    = 0xFFA500; /// 0xF050;
+static const int fail_colour    = 0x00;     /// 0x0000FF;
+static const int touch_colour   = 0x0000FF; /// 0x005050;
+static const int success_colour = 0x00FF00; /// 0xFFFF;
+static const int pen_colour     = 0xFFFF00; /// 0x10FF;
+static const int idle_colour    = 0xFF0000; /// 0x00;
 
 char local_input[50] = {0};
 
@@ -428,7 +428,7 @@
 #if 1
 static void spin()
 {
-    #ifdef MASTER
+#ifdef MASTER
     static patternState_t last_state = START_P;
     static uint8_t last_cone = 255;
     static unsigned long start;
@@ -453,17 +453,17 @@
   if(last_state != state_p || new_state)
   {
     if(state_p == START_P)
-        DEBUG("State is START\n");
+        writeToPhone("State is START\r\n");          // PROTOCOL
     if(state_p == WAITING_P)
-        DEBUG("State is WAITING\n");
+        writeToPhone("State is WAITING\r\n");        // PROTOCOL
     if(state_p == ACTIVE_TARGET_P)
-        DEBUG("State is ACTIVE_TARGET\n");
+        writeToPhone("State is ACTIVE_TARGET\r\n");  // PROTOCOL
     if(state_p == IDLE_P)
-        DEBUG("State is IDLE\n");
+        writeToPhone("State is IDLE\r\n");           // PROTOCOL
     if(state_p == FAIL_P)
-        DEBUG("State is FAIL\n");
+        writeToPhone("State is FAIL\r\n");           // PROTOCOL
     if(state_p == SUCCESS_P)
-        DEBUG("State is SUCCESS)\n");
+        writeToPhone("State is SUCCESS\r\n");        // PROTOCOL
   
     first = true;
     new_state = false;
@@ -493,7 +493,9 @@
     {  // timeout of 0 means wait indefinitely for the first cone to be activated, then start the rest of the sequence
      timeout = ~0;
      tag_start = true; 
-     
+//     DEBUG("Activate cone ");   // May use this again in future.
+//     DEBUG("%d",active_cone);
+//     DEBUG(" to start.\n");
      writeToPhone("ACS: %d\r\n", active_cone);
     }
     
@@ -820,13 +822,16 @@
     break;
   case 'r':
     //Serial.println(F(""));
-    writeToPhone("Current pattern is %d:\r\n", active_sequence+1);
+    // writeToPhone("Current pattern is %d:\r\n", active_sequence+1);
+    writeToPhone("Pattern is %d:\r\n", active_sequence+1);  // PROTOCOL optimization
     for(int i=0; i<STATIONS; i++){
-      writeToPhone("Station %d: cone %d, ", i+1, cones[i]);
+      // writeToPhone("Station %d: cone %d, ", i+1, cones[i]);
+      writeToPhone("S%02d,C%02d", i+1, cones[i]);           // PROTOCOL optimization
       split = times[i];
-      printMsAsSeconds(split);
+      // printMsAsSeconds(split);               // Removed for PROTOCOL optimization
       //Serial.print(F("s timeout, lights: "));
-      writeToPhone("s timeout, config bits: ");
+      // writeToPhone("s timeout, config bits: ");
+      writeToPhone(",T%05d", split);                        // PROTOCOL optimization
       l = masks[i];
       /*
       if(l<0b10000000)
@@ -844,7 +849,8 @@
       if(l<0b10)
         writeToPhone("0");
         */
-      writeBitsToPhone( l, 3 );
+      // writeBitsToPhone( l, 3 );              // Removed for PROTOCOL optimization
+      writeToPhone(",B%02x", l);                            // PROTOCOL optimization
       writeToPhone( "\r\n" );
       //Serial.println(l, BIN);
     }
@@ -1150,7 +1156,7 @@
   
   remainder = number%1000;
 
-  writeToPhone( "%d.%03d\r\n", number/1000, remainder );
+  writeToPhone( "%d.%03d", number/1000, remainder );  /// Needs to stay without newline.
 }
 
  static void spinButtons(void)