Class CounterJNI
java.lang.Object
org.wpilib.hardware.hal.JNIWrapper
org.wpilib.hardware.hal.CounterJNI
-
Nested Class Summary
Nested classes/interfaces inherited from class JNIWrapper
JNIWrapper.Helper -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfreeCounter(int counterHandle) Frees a counter.static intgetCounter(int counterHandle) Reads the current counter value.static doublegetCounterRate(int counterHandle) Gets the rate of the counter.static booleangetCounterStopped(int counterHandle) Determines if the clock is stopped.static intinitializeCounter(int channel, boolean risingEdge) Initializes a counter.static voidresetCounter(int counterHandle) Resets the Counter to zero.static voidsetCounterEdgeConfiguration(int counterHandle, boolean risingEdge) Sets the counter to detect rising or falling edges.static voidsetCounterRateWindow(int counterHandle, int windowMilliseconds) Sets the time window used to calculate the counter rate.Methods inherited from class JNIWrapper
forceLoad, suppressUnused
-
Method Details
-
initializeCounter
public static int initializeCounter(int channel, boolean risingEdge) Initializes a counter.- Parameters:
channel- the DIO channelrisingEdge- true to trigger on rising- Returns:
- the created handle
- See Also:
-
freeCounter
public static void freeCounter(int counterHandle) Frees a counter.- Parameters:
counterHandle- the counter handle- See Also:
-
setCounterEdgeConfiguration
public static void setCounterEdgeConfiguration(int counterHandle, boolean risingEdge) Sets the counter to detect rising or falling edges.- Parameters:
counterHandle- the counter handlerisingEdge- true to count rising edges, false to count falling- See Also:
-
setCounterRateWindow
public static void setCounterRateWindow(int counterHandle, int windowMilliseconds) Sets the time window used to calculate the counter rate.- Parameters:
counterHandle- the counter handlewindowMilliseconds- the rate calculation window in milliseconds; valid values are 5 through 255- See Also:
-
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:
-
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:
-
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:
-
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:
-