mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Makes Java Timer timing more accurate
Java was using integer division for calulating Timer values, which was causing Timer values to be concatinated, and only accurate to the nearest millisecond. This changes it to use double division, which matches C++ and makes timing much more accurate Change-Id: I61b893f4ad5791bf4dfdd767ee4346c1ed4ea418
This commit is contained in:
committed by
Gerrit Code Review
parent
fa8b68419f
commit
e852547344
@@ -58,7 +58,7 @@ public class HardwareTimer implements Timer.StaticInterface {
|
||||
}
|
||||
|
||||
class TimerImpl implements Timer.Interface {
|
||||
private long m_startTime;
|
||||
private double m_startTime;
|
||||
private double m_accumulatedTime;
|
||||
private boolean m_running;
|
||||
|
||||
@@ -70,8 +70,8 @@ public class HardwareTimer implements Timer.StaticInterface {
|
||||
reset();
|
||||
}
|
||||
|
||||
private long getMsClock() {
|
||||
return Utility.getFPGATime() / 1000;
|
||||
private double getMsClock() {
|
||||
return Utility.getFPGATime() / 1000.0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user