Interface CounterBase

All Known Implementing Classes:
Counter, Encoder

public interface CounterBase
Interface for counting the number of ticks on a digital input channel. Encoders, Gear tooth sensors, and counters should all subclass this in order to build more advanced classes for control and driving.

All counters will immediately start counting - reset() them if you need them to be zeroed before use.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    The number of edges for the CounterBase to increment or decrement on.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    get()
    Get the count.
    boolean
    Determine which direction the counter is going.
    double
    Get the time between the last two edges counted.
    boolean
    Determine if the counter is not moving.
    void
    Reset the count to zero.
    void
    setMaxPeriod(double maxPeriod)
    Set the maximum time between edges to be considered stalled.
  • Method Details

    • get

      int get()
      Get the count.
      Returns:
      the count
    • reset

      void reset()
      Reset the count to zero.
    • getPeriod

      double getPeriod()
      Get the time between the last two edges counted.
      Returns:
      the time between the last two ticks in seconds
    • setMaxPeriod

      void setMaxPeriod(double maxPeriod)
      Set the maximum time between edges to be considered stalled.
      Parameters:
      maxPeriod - the maximum period in seconds
    • getStopped

      boolean getStopped()
      Determine if the counter is not moving.
      Returns:
      true if the counter has not changed for the max period
    • getDirection

      boolean getDirection()
      Determine which direction the counter is going.
      Returns:
      true for one direction, false for the other