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
All Methods Instance Methods Concrete Methods 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 Detail
-
ExternalDirectionCounter
public ExternalDirectionCounter(DigitalSource countSource, DigitalSource directionSource)
Constructs a new ExternalDirectionCounter.- Parameters:
countSource
- The source for counting.directionSource
- The source for selecting count direction.
-
-
Method Detail
-
getCount
public int getCount()
Gets the current count.- Returns:
- The current count.
-
setReverseDirection
public void setReverseDirection(boolean reverseDirection)
Sets to revese the counter direction.- Parameters:
reverseDirection
- True to reverse counting direction.
-
reset
public void reset()
Resets the current count.
-
setEdgeConfiguration
public void setEdgeConfiguration(EdgeConfiguration configuration)
Sets the edge configuration for counting.- Parameters:
configuration
- The counting edge configuration.
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
initSendable
public void initSendable(SendableBuilder builder)
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-
-