Telliskivi 2+ peripherals library
Diff: HumanInterface.h
- Revision:
- 2:1ef07b660873
- Parent:
- 1:9b2455659c7d
diff -r 9b2455659c7d -r 1ef07b660873 HumanInterface.h --- a/HumanInterface.h Sun Nov 03 11:40:06 2013 +0000 +++ b/HumanInterface.h Mon Nov 04 21:23:17 2013 +0000 @@ -6,12 +6,9 @@ #include "externalin.h" #include "ledout.h" #include "Serial.h" +#include "PinDetect.h" class HumanInterface { - FunctionPointer goalRiseCallback; - FunctionPointer startRiseCallback; - FunctionPointer ballRiseCallback; - FunctionPointer ballFallCallback; public: HumanInterface( PCA9555 *ioExt, @@ -25,63 +22,36 @@ void setError(bool state); void setGo(bool state); - bool getBallState(); - - void goalRised(); - void startRised(); - void ballFalled(); - void ballRised(); - - void goalRise(void (*function)(void)); - - template<typename T> - void goalRise(T *object, void (T::*member)(void)) { - goalRiseCallback.attach(object, member); - } - - void startRise(void (*function)(void)); - - template<typename T> - void startRise(T *object, void (T::*member)(void)) { - startRiseCallback.attach(object, member); - } - - void ballRise(void (*function)(void)); - - template<typename T> - void ballRise(T *object, void (T::*member)(void)) { - ballRiseCallback.attach(object, member); - } - - void ballFall(void (*function)(void)); - - template<typename T> - void ballFall(T *object, void (T::*member)(void)) { - ballFallCallback.attach(object, member); - } + bool isGoalChange(); + bool isStart(); + int getBallState(); private: Serial *pc; PCA9555 *extIO; - - InterruptIn interruptBall; - InterruptIn interruptGoal; - InterruptIn interruptStart; - bool goalCurrentState; - bool startCurrentState; - bool ballCurrentState; - bool goalLastState; - bool startLastState; - bool ballLastState; - LedOut redLed; LedOut blueLed; LedOut yellowLed; LedOut greenLed; LedOut orangeLed; - + + PinDetect buttonGoal; + PinDetect buttonStart; + PinDetect inputBall; + + + //Functions that PinDetect will call + void goalFall(); + void startRise(); + void ballFall(); + void ballRise(); + + bool goalButtonPressed; + bool startButtonReleased; + int ballState; + bool redBlinking; bool blueBlinking; bool yellowBlinking;