Last active
July 30, 2018 12:42
-
-
Save elgeish/6e836ee0580638db5d59d8d1b9b1b68f to your computer and use it in GitHub Desktop.
Speedometer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Speedometer { | |
private StatefulOdometer statefulOdometer; | |
private Controller controller; | |
/** | |
* Gets the current speed and applies the brakes if activated by eye tracking. | |
* @return current speed. | |
*/ | |
public double getSpeed() { | |
OdometerDelta delta = this.statefulOdometer.getDeltaSinceLastReading(); | |
double speed = delta.getDisplacement() / delta.getTimeElapsed(TimeUnit.HOURS); | |
if (this.isActivatedByEyeTracking()) { | |
this.controller.applyBreaks(); | |
} | |
return speed; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment