rotaryio¶
Support for reading rotation sensors
The rotaryio module contains classes to read different rotation encoding schemes. See
Wikipedia’s Rotary Encoder page for more
background.
.. warning:: This module is not available in some SAMD21 (aka M0) builds. See the Support Matrix for more info.
All classes change hardware state and should be deinitialized when they
are no longer needed if the program continues after use. To do so, either
call deinit() or use a context manager. See
Lifetime and ContextManagers for more info.
-
class
rotaryio.IncrementalEncoder(pin_a: microcontroller.Pin, pin_b: microcontroller.Pin)¶ IncrementalEncoder determines the relative rotational position based on two series of pulses.
-
position:Any¶ The current position in terms of pulses. The number of pulses per rotation is defined by the specific hardware.
-
deinit(self)¶ Deinitializes the IncrementalEncoder and releases any hardware resources for reuse.
-
__enter__(self)¶ No-op used by Context Managers.
-
__exit__(self)¶ Automatically deinitializes the hardware when exiting a context. See Lifetime and ContextManagers for more info.
-