class Encoder – quadrature decoder

class machine.Encoder(pin_a, pin_b, *, pull=None, debounce=0)

Construct a quadrature decoder object used to decode the signals of a rotary encoder.

pin_a is the A-phase pin of the encoder. pin_b is the B-phase pin of the encoder. pull is the pin pull-up/pull-down setting, which can be None, Pin.PULL_UP or Pin.PULL_DOWN. debounce is the debounce time (milliseconds), defaulting to 0.

init(pin_a, pin_b, *, pull=None, debounce=0)

Initialize the quadrature decoder.

The parameters are the same as the constructor.

deinit()

Deinitialize the quadrature decoder.

value([value])

Get or set the encoder value.

If value is provided, the encoder value is set. Otherwise, the current encoder value is returned.