Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: GoalCounter WS2812 PixelArray
Diff: GoalCounter.cpp
- Revision:
- 2:f04959a6fd61
- Parent:
- 0:24f846b68c77
- Child:
- 3:d74c47d2e933
--- a/GoalCounter.cpp Thu Jan 10 15:48:39 2019 +0000
+++ b/GoalCounter.cpp Fri Jan 11 18:29:58 2019 +0000
@@ -1,10 +1,11 @@
#include "GoalCounter.h"
GoalCounter::GoalCounter(PinName pin) : _interrupt(pin) {
- _interrupt.fall(this, &GoalCounter::tstart);
- _interrupt.rise(this, &GoalCounter::tstop);
+ // Set callback functions to timers
+ _interrupt.fall(callback(this, &GoalCounter::tstart));
+ _interrupt.rise(callback(this, &GoalCounter::tstop));
// _balltimes = {0};
- _score= 0;
+ _score= 0;
}
void GoalCounter::tstart() {
@@ -18,11 +19,15 @@
if ( _time > 0 && _time < 2 && _score < 10) {
_balltimes[++_score] = _time;
- goal = 1;
+ is_goal = 1;
// wait(1);
}
}
+void GoalCounter::goal() {
+ is_goal = 1;
+}
+
uint8_t GoalCounter::get_score() {
return _score;
}
@@ -53,6 +58,12 @@
return speed;
}
+//void GoalCounter:print_info() {
+// pc.printf("Score : %d \n\r", _score);
+// pc.printf("Time of ball pass : %f seconds\n\r", this.get_balltime());
+// pc.printf("Speed of ball (34 mm diameter) : %f kph\n\r", this.get_ballspeed());
+//}
+