For Telliskivi2 2014
Fork of HumanInterface by
Diff: HumanInterface.cpp
- Revision:
- 4:0a82202bc5df
- Parent:
- 3:92390ebe4903
- Child:
- 5:64a46d67cb6e
--- a/HumanInterface.cpp Tue Sep 02 15:31:07 2014 +0000 +++ b/HumanInterface.cpp Fri Nov 21 18:19:47 2014 +0000 @@ -2,12 +2,12 @@ HumanInterface::HumanInterface (PCA9555 *ioExt, - unsigned int yellowLedPin, unsigned int blueLedPin, unsigned int redLedPin, - unsigned int greenLedPin, unsigned int orangeLedPin, + unsigned int redLed1Pin, unsigned int greenLed1Pin, unsigned int blueLed1Pin, + unsigned int redLed2Pin, unsigned int greenLed2Pin, unsigned int blueLed2Pin, PinName goalButtonPin, PinName startButtonPin, PinName ballSensePin): - extIO(ioExt), redLed(ioExt, redLedPin), blueLed(ioExt, blueLedPin), yellowLed(ioExt, yellowLedPin), - greenLed(ioExt, greenLedPin), orangeLed(ioExt, orangeLedPin), - /*interruptGoal(goalButtonPin), interruptStart(startButtonPin), interruptBall(ballSensePin)*/ + extIO(ioExt), + rgbLed1(ioExt, redLed1Pin, greenLed1Pin, blueLed1Pin), + rgbLed2(ioExt, redLed2Pin, greenLed2Pin, blueLed2Pin), buttonGoal(goalButtonPin), buttonStart(startButtonPin), inputBall(ballSensePin) { goalButtonPressed = false; @@ -28,14 +28,10 @@ buttonGoal.setSampleFrequency(1000); buttonStart.setSampleFrequency(1000); - inputBall.setSampleFrequency(250); - + inputBall.setSampleFrequency(5000); redBlinking = false; - blueBlinking = false; - yellowBlinking = false; - greenBlinking = false; - orangeBlinking = false; + goalBlinking = false; setGoal(UNSET); @@ -46,58 +42,49 @@ void HumanInterface::setError(bool state) { if (state) { redBlinking = true; + rgbLed2.setGreen(false); + rgbLed2.setColor(RgbLed::RED); } else { redBlinking = false; - redLed.clear(); + rgbLed2.setRed(false); } } void HumanInterface::setGo(bool state) { if (state) { - greenLed.set(); + rgbLed2.setColor(RgbLed::GREEN); + redBlinking = false; } else { - greenLed.clear(); + rgbLed2.setGreen(false); } } void HumanInterface::setGoal(Goal goal) { if (goal == YELLOW) { - yellowLed.set(); - blueLed.clear(); - blueBlinking = false; - yellowBlinking = false; + rgbLed1.setColor(RgbLed::YELLOW); + goalBlinking = false; } else if (goal == BLUE) { - yellowLed.clear(); - blueLed.set(); - blueBlinking = false; - yellowBlinking = false; + rgbLed1.setColor(RgbLed::BLUE); + goalBlinking = false; } else if (goal == UNSET) { - yellowLed.clear(); - blueLed.clear(); - blueBlinking = true; - yellowBlinking = true; + rgbLed1.setColor(RgbLed::YELLOW); + goalBlinking = true; } } void HumanInterface::blinkLeds(void) { if (redBlinking) - redLed.toggle(); - if (blueBlinking) - blueLed.toggle(); - if (yellowBlinking) - yellowLed.toggle(); - if (greenBlinking) - greenLed.toggle(); - if (orangeBlinking) - orangeLed.toggle(); + rgbLed2.toggleRed(); + if (goalBlinking) + rgbLed1.toggle(); } int HumanInterface::getBallState() { - int ret = ballState; - ballState = 0; - return ret; + //int ret = ballState; + //ballState = 0; + return ballState; } bool HumanInterface::isGoalChange() { @@ -105,13 +92,13 @@ goalButtonPressed = false; return ret; } + bool HumanInterface::isStart() { bool ret = startButtonReleased; startButtonReleased = false; return ret; } - void HumanInterface::goalFall() { goalButtonPressed = true; } @@ -122,8 +109,10 @@ void HumanInterface::ballRise() { ballState = 1; + rgbLed2.setColor(RgbLed::MAGENTA); } void HumanInterface::ballFall() { - ballState = -1; + ballState = 0; + rgbLed2.setColor(RgbLed::OFF); }