Intervals - addonovan/ftc-ext GitHub Wiki

Intervals

An interval is simply a class that represents a period of time, and is "active" only during that duration. This is useful for timing functions, as it's more concise and readable than doing the comparisons by hand.

Both Intervals' constructors have two parameters:

  1. time from now that this interval begins (in the correct unit)
  2. duration of the interval (in the correct unit)

Interval

Interval is a class that isn't especially high resolution nor accurate. This deals with milliseconds and uses the System.currentTimeMillis() method to tell the time, which has been criticized for not being incredibly accurate. To combat this inaccuracy, the interval remains active not only in between the start and end times, but also within 5 milliseconds before or after.

HQInterval

A High Quality Interval is a class that is especially high resolution and accurate. This deals in nanoseconds and uses the much more accurate System.nanoTime() method to tell the time. A drawback to using this class is that its constructor deals in nanoseconds, which might lead to some errors.