CounterBase

class wpilib.interfaces.CounterBase[source]

Bases: builtins.object

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.

class EncodingType[source]

Bases: builtins.object

The number of edges for the counterbase to increment or decrement on

k1X = 0

Count only the rising edge

k2X = 1

Count both the rising and falling edge

k4X = 2

Count rising and falling on both channels

CounterBase.get()[source]

Get the count

Returns:the count
CounterBase.getDirection()[source]

Determine which direction the counter is going

Returns:True for one direction, False for the other
CounterBase.getPeriod()[source]

Get the time between the last two edges counted

Returns:the time beteween the last two ticks in seconds
CounterBase.getStopped()[source]

Determine if the counter is not moving

Returns:True if the counter has not changed for the max period
CounterBase.reset()[source]

Reset the count to zero

CounterBase.setMaxPeriod(maxPeriod)[source]

Set the maximum time between edges to be considered stalled

Parameters:maxPeriod – the maximum period in seconds