For Telliskivi2 2014

Dependents:   Telliskivi2_2014

Fork of HumanInterface by Reiko Randoja

Committer:
Reiko
Date:
Fri Nov 21 18:19:47 2014 +0000
Revision:
4:0a82202bc5df
Parent:
2:1ef07b660873
Child:
5:64a46d67cb6e
RGB leds

Who changed what in which revision?

UserRevisionLine numberNew 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 4:0a82202bc5df 39 PinDetect inputBall;
mlaane 2:1ef07b660873 40
mlaane 2:1ef07b660873 41 //Functions that PinDetect will call
mlaane 2:1ef07b660873 42 void goalFall();
mlaane 2:1ef07b660873 43 void startRise();
mlaane 2:1ef07b660873 44 void ballFall();
mlaane 2:1ef07b660873 45 void ballRise();
mlaane 2:1ef07b660873 46
mlaane 2:1ef07b660873 47 bool goalButtonPressed;
mlaane 2:1ef07b660873 48 bool startButtonReleased;
mlaane 2:1ef07b660873 49 int ballState;
mlaane 2:1ef07b660873 50
Reiko 0:ccf47494061b 51 bool redBlinking;
Reiko 4:0a82202bc5df 52 bool goalBlinking;
Reiko 4:0a82202bc5df 53
Reiko 4:0a82202bc5df 54 bool redState();
Reiko 0:ccf47494061b 55
Reiko 0:ccf47494061b 56 Ticker ledTicker;
Reiko 0:ccf47494061b 57
Reiko 0:ccf47494061b 58 void blinkLeds(void);
Reiko 0:ccf47494061b 59 };
Reiko 0:ccf47494061b 60
Reiko 0:ccf47494061b 61 #endif