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
Diff: main.cpp
- Revision:
- 6:5619aff36840
- Parent:
- 5:b30229c6f32b
- Child:
- 7:a9e98f642a89
--- 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); }