This library provides simple interface for the table football goal counter based on a IR LED or laser diode and phototransistor.

Dependents:   goal_counter_project

Revision:
4:fc48ef79f484
Parent:
3:ce69ad70270a
--- a/GoalCounter.h	Sun Jan 13 16:43:27 2019 +0000
+++ b/GoalCounter.h	Mon Jan 14 17:48:02 2019 +0000
@@ -36,19 +36,27 @@
 class GoalCounter {
 public:
     /**
-    * Constructor
+    *   Constructor
     *
-    * @param pin Input pin where is the outpout of phototransistor connected
-    * @param timer reference to the Timer instance
+    *   @param pin Input pin where is the outpout of phototransistor connected
+    *   @param timer reference to the Timer instance
     *
     */
-    GoalCounter(PinName pin, Timer * t);  
+    GoalCounter(PinName pin, Timer * t);
     /**
-    *   Starts the timer, this function is called from the interrupt pin callback
+    *   Destructor
+    *
+    *   Destroys instance
+    */
+    ~GoalCounter();   
+    /**
+    *   Reads value of the timer, 
+    *   this function is called from the interrupt pin fall edge callback
     */
     void tstart();
     /**
-    *   Stops the timer, this function is called from the interrupt pin callback
+    *   Reads value from the timer and measures interval between end and beginning
+    *   Called from the interrupt pin rise edge callback
     */
     void tstop();
     /**
@@ -79,7 +87,7 @@
     */
     float get_ballspeed();
     /**
-    *  Variable is 1 when the goal is detected
+    *  Variable is 1 (true) when the goal is detected
     */
     volatile uint8_t is_goal;
 
@@ -87,9 +95,12 @@
     InterruptIn * _interrupt;
     volatile uint8_t _score;
     Timer * _t;
-    float _balltimes[11];
+    float _balltimes[11]; // sorry for the FP arithmetics, i was too lazy to rewrite it
     float _time;
-      
+    float _begin;
+    float _end;
+    float _last_end;
+    float _time_between;      
 };
 
 #endif 
\ No newline at end of file