For Telliskivi2 2014

Dependents:   Telliskivi2_2014

Fork of HumanInterface by Reiko Randoja

Revision:
1:9b2455659c7d
Parent:
0:ccf47494061b
Child:
2:1ef07b660873
--- a/HumanInterface.h	Thu Sep 19 13:13:10 2013 +0000
+++ b/HumanInterface.h	Sun Nov 03 11:40:06 2013 +0000
@@ -8,29 +8,29 @@
 #include "Serial.h"
 
 class HumanInterface {
-    FunctionPointer changeCallback;
     FunctionPointer goalRiseCallback;
     FunctionPointer startRiseCallback;
-    FunctionPointer ballChangeCallback;
+    FunctionPointer ballRiseCallback;
+    FunctionPointer ballFallCallback;
 public:
     HumanInterface(
-        Serial *pc, PCA9555 *ioExt,
+        PCA9555 *ioExt,
         unsigned int yellowLedPin, unsigned int blueLedPin, unsigned int redLedPin,
-        unsigned int goalButtonPin, unsigned int startButtonPin, unsigned int ballSensePin
+        unsigned int greenLedPin, unsigned int orangeLedPin,
+        PinName goalButtonPin, PinName startButtonPin, PinName ballSensePin
     ); 
     
     enum Goal {YELLOW, BLUE, UNSET};
     void setGoal(Goal goal);
     void setError(bool state);
+    void setGo(bool state);    
     
     bool getBallState();
     
-    void change(void (*function)(void));
-    
-    template<typename T>
-    void change(T *object, void (T::*member)(void)) { 
-        changeCallback.attach(object, member); 
-    } 
+    void goalRised();
+    void startRised();
+    void ballFalled();
+    void ballRised();
     
     void goalRise(void (*function)(void));
     
@@ -46,11 +46,18 @@
         startRiseCallback.attach(object, member); 
     } 
     
-    void ballChange(void (*function)(void));
+    void ballRise(void (*function)(void));
     
     template<typename T>
-    void ballChange(T *object, void (T::*member)(void)) { 
-        ballChangeCallback.attach(object, member); 
+    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); 
     }
     
 private:
@@ -58,10 +65,13 @@
     
     PCA9555 *extIO;
 
-    ExternalIn goalButton; // 14
-    ExternalIn startButton; // 15
-    ExternalIn ballSense; // 10
-
+    InterruptIn interruptBall;
+    InterruptIn interruptGoal;
+    InterruptIn interruptStart;
+    
+    bool goalCurrentState;
+    bool startCurrentState;
+    bool ballCurrentState;
     bool goalLastState;
     bool startLastState;
     bool ballLastState;
@@ -69,15 +79,18 @@
     LedOut redLed;
     LedOut blueLed;
     LedOut yellowLed;
+    LedOut greenLed;
+    LedOut orangeLed;
 
     bool redBlinking;
     bool blueBlinking;
     bool yellowBlinking;
+    bool greenBlinking;
+    bool orangeBlinking;
 
     Ticker ledTicker;
     
     void blinkLeds(void);
-    void extChangedCallback(void);
 };
 
 #endif
\ No newline at end of file