Package edu.wpi.first.wpilibj.counter
Class ExternalDirectionCounter
java.lang.Object
edu.wpi.first.wpilibj.counter.ExternalDirectionCounter
- All Implemented Interfaces:
Sendable
,AutoCloseable
public class ExternalDirectionCounter extends Object implements Sendable, AutoCloseable
Counter using external direction.
This counts on an edge from one digital input and the whether it counts up or down based on the state of a second digital input.
-
Constructor Summary
Constructors Constructor Description ExternalDirectionCounter(DigitalSource countSource, DigitalSource directionSource)
Constructs a new ExternalDirectionCounter. -
Method Summary
Modifier and Type Method Description void
close()
int
getCount()
Gets the current count.void
initSendable(SendableBuilder builder)
Initializes thisSendable
object.void
reset()
Resets the current count.void
setEdgeConfiguration(EdgeConfiguration configuration)
Sets the edge configuration for counting.void
setReverseDirection(boolean reverseDirection)
Sets to revese the counter direction.
-
Constructor Details
-
ExternalDirectionCounter
Constructs a new ExternalDirectionCounter.- Parameters:
countSource
- The source for counting.directionSource
- The source for selecting count direction.
-
-
Method Details
-
getCount
Gets the current count.- Returns:
- The current count.
-
setReverseDirection
Sets to revese the counter direction.- Parameters:
reverseDirection
- True to reverse counting direction.
-
reset
Resets the current count. -
setEdgeConfiguration
Sets the edge configuration for counting.- Parameters:
configuration
- The counting edge configuration.
-
close
- Specified by:
close
in interfaceAutoCloseable
-
initSendable
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-