For Telliskivi2 2014
Fork of HumanInterface by
HumanInterface.h@5:64a46d67cb6e, 2014-11-23 (annotated)
- Committer:
- Reiko
- Date:
- Sun Nov 23 02:28:04 2014 +0000
- Revision:
- 5:64a46d67cb6e
- Parent:
- 4:0a82202bc5df
Removed ball debounce
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Reiko | 0:ccf47494061b | 1 | #ifndef HUMANINTERFACE_H |
Reiko | 0:ccf47494061b | 2 | #define HUMANINTERFACE_H |
Reiko | 0:ccf47494061b | 3 | |
Reiko | 0:ccf47494061b | 4 | #include "mbed.h" |
Reiko | 0:ccf47494061b | 5 | #include "PCA9555.h" |
Reiko | 0:ccf47494061b | 6 | #include "externalin.h" |
Reiko | 0:ccf47494061b | 7 | #include "Serial.h" |
mlaane | 2:1ef07b660873 | 8 | #include "PinDetect.h" |
Reiko | 4:0a82202bc5df | 9 | #include "rgb-led-pca9555.h" |
Reiko | 0:ccf47494061b | 10 | |
Reiko | 0:ccf47494061b | 11 | class HumanInterface { |
Reiko | 0:ccf47494061b | 12 | public: |
Reiko | 0:ccf47494061b | 13 | HumanInterface( |
Reiko | 1:9b2455659c7d | 14 | PCA9555 *ioExt, |
Reiko | 4:0a82202bc5df | 15 | unsigned int redLed1Pin, unsigned int greenLed1Pin, unsigned int blueLed1Pin, |
Reiko | 4:0a82202bc5df | 16 | unsigned int redLed2Pin, unsigned int greenLed2Pin, unsigned int blueLed2Pin, |
Reiko | 1:9b2455659c7d | 17 | PinName goalButtonPin, PinName startButtonPin, PinName ballSensePin |
Reiko | 0:ccf47494061b | 18 | ); |
Reiko | 0:ccf47494061b | 19 | |
Reiko | 0:ccf47494061b | 20 | enum Goal {YELLOW, BLUE, UNSET}; |
Reiko | 0:ccf47494061b | 21 | void setGoal(Goal goal); |
Reiko | 0:ccf47494061b | 22 | void setError(bool state); |
Reiko | 1:9b2455659c7d | 23 | void setGo(bool state); |
Reiko | 0:ccf47494061b | 24 | |
mlaane | 2:1ef07b660873 | 25 | bool isGoalChange(); |
mlaane | 2:1ef07b660873 | 26 | bool isStart(); |
mlaane | 2:1ef07b660873 | 27 | int getBallState(); |
Reiko | 0:ccf47494061b | 28 | |
Reiko | 0:ccf47494061b | 29 | private: |
Reiko | 0:ccf47494061b | 30 | Serial *pc; |
Reiko | 0:ccf47494061b | 31 | |
Reiko | 0:ccf47494061b | 32 | PCA9555 *extIO; |
Reiko | 1:9b2455659c7d | 33 | |
Reiko | 4:0a82202bc5df | 34 | RgbLed rgbLed1; |
Reiko | 4:0a82202bc5df | 35 | RgbLed rgbLed2; |
mlaane | 2:1ef07b660873 | 36 | |
mlaane | 2:1ef07b660873 | 37 | PinDetect buttonGoal; |
mlaane | 2:1ef07b660873 | 38 | PinDetect buttonStart; |
Reiko | 5:64a46d67cb6e | 39 | //PinDetect inputBall; |
Reiko | 5:64a46d67cb6e | 40 | |
Reiko | 5:64a46d67cb6e | 41 | InterruptIn inputBall; |
mlaane | 2:1ef07b660873 | 42 | |
mlaane | 2:1ef07b660873 | 43 | //Functions that PinDetect will call |
mlaane | 2:1ef07b660873 | 44 | void goalFall(); |
mlaane | 2:1ef07b660873 | 45 | void startRise(); |
mlaane | 2:1ef07b660873 | 46 | void ballFall(); |
mlaane | 2:1ef07b660873 | 47 | void ballRise(); |
mlaane | 2:1ef07b660873 | 48 | |
mlaane | 2:1ef07b660873 | 49 | bool goalButtonPressed; |
mlaane | 2:1ef07b660873 | 50 | bool startButtonReleased; |
mlaane | 2:1ef07b660873 | 51 | int ballState; |
mlaane | 2:1ef07b660873 | 52 | |
Reiko | 0:ccf47494061b | 53 | bool redBlinking; |
Reiko | 4:0a82202bc5df | 54 | bool goalBlinking; |
Reiko | 4:0a82202bc5df | 55 | |
Reiko | 4:0a82202bc5df | 56 | bool redState(); |
Reiko | 0:ccf47494061b | 57 | |
Reiko | 0:ccf47494061b | 58 | Ticker ledTicker; |
Reiko | 0:ccf47494061b | 59 | |
Reiko | 0:ccf47494061b | 60 | void blinkLeds(void); |
Reiko | 0:ccf47494061b | 61 | }; |
Reiko | 0:ccf47494061b | 62 | |
Reiko | 0:ccf47494061b | 63 | #endif |