Class CounterJNI

java.lang.Object
org.wpilib.hardware.hal.JNIWrapper
org.wpilib.hardware.hal.CounterJNI

public class CounterJNI extends JNIWrapper
Counter HAL JNI functions.
See Also:
  • "wpi/hal/Counter.h"
  • Method Details

    • initializeCounter

      public static int initializeCounter(int channel, boolean risingEdge)
      Initializes a counter.
      Parameters:
      channel - the DIO channel
      risingEdge - true to trigger on rising
      Returns:
      the created handle
      See Also:
      • "HAL_InitializeCounter"
    • freeCounter

      public static void freeCounter(int counterHandle)
      Frees a counter.
      Parameters:
      counterHandle - the counter handle
      See Also:
      • "HAL_FreeCounter"
    • setCounterEdgeConfiguration

      public static void setCounterEdgeConfiguration(int counterHandle, boolean risingEdge)
      Sets the counter to detect rising or falling edges.
      Parameters:
      counterHandle - the counter handle
      risingEdge - true to count rising edges, false to count falling
      See Also:
      • "HAL_SetCounterEdgeConfiguration"
    • setCounterRateWindow

      public static void setCounterRateWindow(int counterHandle, int windowMilliseconds)
      Sets the time window used to calculate the counter rate.
      Parameters:
      counterHandle - the counter handle
      windowMilliseconds - the rate calculation window in milliseconds; valid values are 5 through 255
      See Also:
      • "HAL_SetCounterRateWindow"
    • resetCounter

      public static void resetCounter(int counterHandle)
      Resets the Counter to zero.

      Sets the counter value to zero. This does not effect the running state of the counter, just sets the current value to zero.

      Parameters:
      counterHandle - the counter handle
      See Also:
      • "HAL_ResetCounter"
    • getCounter

      public static int getCounter(int counterHandle)
      Reads the current counter value.

      Reads the value at this instant. It may still be running, so it reflects the current value. Next time it is read, it might have a different value.

      Parameters:
      counterHandle - the counter handle
      Returns:
      the current counter value
      See Also:
      • "HAL_GetCounter"
    • getCounterRate

      public static double getCounterRate(int counterHandle)
      Gets the rate of the counter.
      Parameters:
      counterHandle - the counter handle
      Returns:
      the counter rate in counts per second
      See Also:
      • "HAL_GetCounterRate"
    • getCounterStopped

      public static boolean getCounterStopped(int counterHandle)
      Determines if the clock is stopped.

      Determines if the counter's current rate is zero.

      Parameters:
      counterHandle - the counter handle
      Returns:
      true if the counter's current rate is zero
      See Also:
      • "HAL_GetCounterStopped"