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


Get the count

Returns:the count

Determine which direction the counter is going

Returns:True for one direction, False for the other

Get the time between the last two edges counted

Returns:the time beteween the last two ticks in seconds

Determine if the counter is not moving

Returns:True if the counter has not changed for the max period

Reset the count to zero


Set the maximum time between edges to be considered stalled

Parameters:maxPeriod – the maximum period in seconds