Telliskivi 2 2014

Dependencies:   DoubleCoilGun 4DGL-uLCD-SE ExternalIn HumanInterfaceT14 LedOut MCP3021 MODSERIAL Motor1Pwm1Dir PCA9555 PinDetect QED RgbLedPCA9555 WDT_K64F mbed-src

Fork of Telliskivi2plus by Reiko Randoja

Files at this revision

API Documentation at this revision

Comitter:
mlaane
Date:
Mon Nov 04 21:23:42 2013 +0000
Parent:
5:b30229c6f32b
Child:
7:a9e98f642a89
Commit message:
Debounced buttons and ball sensor

Changed in this revision

HumanInterface.lib Show annotated file Show diff for this revision Revisions of this file
PinDetect.lib 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
--- a/HumanInterface.lib	Sun Nov 03 11:46:19 2013 +0000
+++ b/HumanInterface.lib	Mon Nov 04 21:23:42 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Reiko/code/HumanInterface/#9b2455659c7d
+http://mbed.org/users/Reiko/code/HumanInterface/#1ef07b660873
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PinDetect.lib	Mon Nov 04 21:23:42 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/AjK/code/PinDetect/#cb3afc45028b
--- a/main.cpp	Sun Nov 03 11:46:19 2013 +0000
+++ b/main.cpp	Mon Nov 04 21:23:42 2013 +0000
@@ -34,10 +34,7 @@
 
 volatile int update = 0;
 volatile int extInChanged = 0;
-volatile int ballChanged = 0;
-volatile int ballState = 0;
-volatile int goalButtonReleased = 0;
-volatile int startButtonReleased = 0;
+
 volatile int stallChanged = 0;
 
 bool failSafeEnabled = true;
@@ -90,24 +87,6 @@
     extInChanged = 1;
 }
 
-void ballRiseCallback() {
-    ballChanged = 1;
-    ballState = 1;
-}
-
-void ballFallCallback() {
-    ballChanged = 1;
-    ballState = 0;
-}
-
-void goalRiseCallback() {
-    goalButtonReleased = 1;
-}
-
-void startRiseCallback() {
-    startButtonReleased = 1;
-}
-
 void stallChangedCallback() {
     stallChanged = 1;
 }
@@ -218,11 +197,6 @@
     //button1.change(&extChangedCallback);
     //button2.change(&extChangedCallback);
     
-    humanInterface.ballRise(&ballRiseCallback);
-    humanInterface.ballFall(&ballFallCallback);
-    humanInterface.goalRise(&goalRiseCallback);
-    humanInterface.startRise(&startRiseCallback);
-    
     //humanInterface.change(&extChangedCallback);
     
     motor1.stallChange(&stallChangedCallback);
@@ -306,24 +280,27 @@
         }     
         
         
-        if (ballChanged) {
-            ballChanged = 0;
-            int charCount = sprintf(sendBuffer, "<ball:%d>", ballState);
-            server.sendTo(client, sendBuffer, charCount); 
-            if (ballState) {
-                led4 = 1;
-            } else {
-                led4 = 0;
-            }
+        switch (humanInterface.getBallState()){
+            case -1:
+                //Ball lost
+                server.sendTo(client, "<ball:0>", 8);
+                break;
+            case 0:
+                //Nothing has changed..
+                break;
+            case 1:
+                //Ball found
+                server.sendTo(client, "<ball:1>", 8);
+                break;
+            default:
+                break;
         }
         
-        if (goalButtonReleased) {
-            goalButtonReleased = 0;
+        if (humanInterface.isGoalChange()) {
             server.sendTo(client, "<toggle-side>", 13);
         }
         
-        if (startButtonReleased) {
-            startButtonReleased = 0;
+        if (humanInterface.isStart()) {
             server.sendTo(client, "<toggle-go>", 11);
         }