Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
46:28c29ef61276
Parent:
39:b1f864b71318
Child:
49:626e84ce5e52
--- a/TA.cpp	Sat Jan 09 21:46:34 2016 +0000
+++ b/TA.cpp	Mon Jan 11 16:34:46 2016 +0000
@@ -163,7 +163,7 @@
         //neo->setPixel(i, rgb);
     } 
     
-    buzzPin = 1;
+    /// buzzPin = 1;
 }
 
 void TA::mask_color(uint32_t rgb)
@@ -176,11 +176,14 @@
   //enable_1 = (mask & 0x01)?1:0;
   //enable_2 = (mask & 0x02)?1:0;
   //enable_3 = (mask & 0x04)?1:0;
-  
-  for (int i = 0; i <= leds_per_strip; ++i)
+
+  if( mask & TOUCHLIGHTS )  // Even though we now only use one sensor, we still have DARK ALERT.
+    for (int i = 0; i <= leds_per_strip; ++i)
     {
           neopixel_set_color_and_show(&m_strip, i, (rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF);
-    } 
+    }
+  else
+    neopixel_clear(&m_strip);
 }
 
 void TA::beep(uint16_t ms)
@@ -222,7 +225,7 @@
     pulsing = true;
     pulse_start = millis();
     pulse_period = period;
-    pulse_on = on_time;
+    pulse_on = (on_time < 126 ? 126 : on_time);
     pulse_duration = ms;   
 }
 
@@ -272,16 +275,11 @@
   return false;
 }
 
-void TA::resetTouchIfStuck()
+void TA::resetTouch()
 {
-  if(tripped())
-  {
     cap_enable = 1;
     wait_ms(100);
     cap_enable = 0;
-    writeToPhone("TCP\r\n");
-    //Serial.println(F("toggled cap sense power"));
-  }
 }
 
 void TA::spin(void)
@@ -306,7 +304,12 @@
         last_touch = millis();  
   }
 
-  resetTouchIfStuck();
+  if(tripped())
+  {
+    resetTouch();
+    writeToPhone("TCP\r\n");
+    //Serial.println(F("toggled cap sense power"));
+  }
 
   if(powering_up2)
   {
@@ -358,6 +361,7 @@
     }
   }
 
+#if 1  // Foo
 /*
   if(!waiting_for_ack && radio_receive_complete())
   {
@@ -473,11 +477,15 @@
       }
     }
   }
+#endif  // Foo
 }
 
 bool TA::activated(void)
 {
-    return (buttons() & mask)?true:false; 
+    return  ((buttons() & mask) ||
+             /* Default to enabling activation on disabled--Except if mask has DIS_ON_DARK set */
+             (!(mask & TOUCHLIGHTS) != !!(mask & DIS_ON_DARK))
+            ) ? true : false; 
 }
 
 bool TA::tripped(void)