Package edu.wpi.first.wpilibj
Interface CounterBase
- All Known Implementing Classes:
- Counter,- Encoder,- PIDEncoder
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 so it can be used 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 SummaryNested Classes Modifier and Type Interface Description static classCounterBase.EncodingTypeThe number of edges for the counterbase to increment or decrement on.
- 
Method SummaryModifier and Type Method Description intget()Get the count.booleangetDirection()Determine which direction the counter is going.doublegetPeriod()Get the time between the last two edges counted.booleangetStopped()Determine if the counter is not moving.voidreset()Reset the count to zero.voidsetMaxPeriod(double maxPeriod)Set the maximum time between edges to be considered stalled.
- 
Method Details- 
getint get()Get the count.- Returns:
- the count
 
- 
resetvoid reset()Reset the count to zero.
- 
getPerioddouble getPeriod()Get the time between the last two edges counted.- Returns:
- the time between the last two ticks in seconds
 
- 
setMaxPeriodSet the maximum time between edges to be considered stalled.- Parameters:
- maxPeriod- the maximum period in seconds
 
- 
getStoppedboolean getStopped()Determine if the counter is not moving.- Returns:
- true if the counter has not changed for the max period
 
- 
getDirectionboolean getDirection()Determine which direction the counter is going.- Returns:
- true for one direction, false for the other
 
 
-