Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
30:c60b0d52b067
Parent:
26:40a0c775ff27
Child:
31:a6110950f385
diff -r 8e74ddc4f70f -r c60b0d52b067 TA.cpp
--- a/TA.cpp	Sun Jan 03 20:05:15 2016 +0000
+++ b/TA.cpp	Mon Jan 04 16:33:39 2016 +0000
@@ -121,24 +121,28 @@
 DigitalOut TA::enable_3(p8);
 #endif
 
-DigitalOut TA::cap_enable(p2);
-DigitalIn  touch_top(p1);
-DigitalIn  touch(p12);
+DigitalOut TA::cap_enable( p1, 0 );
+/// DigitalIn  touch_top(p1);
+/// DigitalIn  touch(p12);
 
-DigitalOut TA::buzzPin(p20);
+#define BUZZ_ON   0
+#define BUZZ_OFF  1
 
-#if 0
+DigitalOut TA::buzzPin( p20, BUZZ_OFF );
+
+#if 1
 // inputs
-DigitalIn TA::touch_1(A0);
-DigitalIn TA::touch_2(A1);
-DigitalIn TA::touch_3(A2);
+DigitalIn TA::touch_1( p0, PullNone );  //  Top touch sensor.
+DigitalIn TA::touch_2( p12,PullDown );  //  Test  button (p6 [was] RSVD for lower button--p6 is last analog-in though.)
+DigitalIn TA::touch_3( p3, PullNone );  // /Power button (even though not a touch button.)
 #endif
 
 //NeoStrip *neo;
 
 TA::TA()
 {
-    buzzPin = 0;
+    setMask( DEFTOUCHMASK );
+    buzzPin = BUZZ_OFF;
     neopixel_init(&m_strip, dig_pin_num, leds_per_strip);
     neopixel_clear(&m_strip); 
 }
@@ -281,13 +285,13 @@
   static unsigned long mem_monitor_start = 0;
 
   static unsigned long last_touch = 0;
-  
+/***
   if (last_touch == 0 || millis()-last_touch > 3000)
   {
-        writeToPhone("Touch value: %d\r\n", touch_top);
+        writeToPhone("Touch value: %d\r\n", touch_1);  ///
         last_touch = millis();  
-    }
-
+  }
+***/
   if(tripped())
   {
     cap_enable = 1;
@@ -302,12 +306,12 @@
     unsigned long t = millis() - powerup_start;
     if(t > powerup_toggle)
     {
-      //buzzPin = !buzzPin;
+      buzzPin = !buzzPin;
       powerup_toggle *= 1.2;
     }
     if(t > 1250)
     {
-      //buzzPin = 0;
+      buzzPin = BUZZ_OFF;
       powering_up2 = false;
     }
   }
@@ -316,13 +320,13 @@
     unsigned long t = millis() - powerup_start;
     if(t > powerup_toggle)
     {
-      //buzzPin = !buzzPin;
+      buzzPin = !buzzPin;
       powerup_toggle *= 0.95;
       powerup_start = millis();
     }
     if(powerup_toggle < 10)
     {
-      //buzzPin = 0;
+      buzzPin = BUZZ_OFF;
       powering_up1 = false;
     }
   }
@@ -332,18 +336,18 @@
         beeping = false;
     if(pulsing && (millis()-pulse_start > pulse_duration)) 
         pulsing = false;
-    //if(beeping)
-        //buzzPin = 1;
+    if(beeping)
+        buzzPin = BUZZ_ON;
     else if( pulsing && (((millis()-pulse_start) % pulse_period) < pulse_on))
     {
-      //if(!(mask & SILENT))
-        //buzzPin = 1;
+      if(!(mask & SILENT))
+        buzzPin = BUZZ_ON;
       mask_color(0);
     }
     else
     {
-      //if(pulsing)mask_color(current_color);
-      //buzzPin = 0;
+      if(pulsing)mask_color(current_color);
+      buzzPin = BUZZ_OFF;
     }
   }
 
@@ -416,7 +420,7 @@
   else if(message_in_queue && micros() - random_wait > random_wait_start){// && index%64 == 0){
     requestACK = true;
     //Serial.println(F("sending"));
-    writeToPhone("Sending message to: %d\r\n", dest_cone);
+///    writeToPhone("Sending message to: %d\r\n", dest_cone);
     radio.send(dest_cone, payload, 6, requestACK);
     //Serial.println(F("sent"));
     //Serial.print(F("Trying to send: "));
@@ -493,10 +497,10 @@
 {
   uint8_t buttons = 0;
 
-  //buttons |= touch_1?1:0;
-  //buttons |= touch_2?2:0;
-  //buttons |= touch_3?4:0;
-  return touch;
+  buttons |= touch_1?1:0;
+  buttons |= touch_2?2:0;
+  buttons |= touch_3?0:4;
+  return buttons; /// touch;
 
 }