Skip to content

Instantly share code, notes, and snippets.

@elgeish
Last active July 30, 2018 12:42
Show Gist options
  • Save elgeish/6e836ee0580638db5d59d8d1b9b1b68f to your computer and use it in GitHub Desktop.
Save elgeish/6e836ee0580638db5d59d8d1b9b1b68f to your computer and use it in GitHub Desktop.
Speedometer
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