OpenRoadCode
Public API reference for OpenRoadCode
Loading...
Searching...
No Matches
hardware_io.rotary_encoder.gpio_rotary_encoder.GpioRotaryEncoder Class Reference

Reads a directly connected rotary encoder using Raspberry Pi GPIO. More...

Inheritance diagram for hardware_io.rotary_encoder.gpio_rotary_encoder.GpioRotaryEncoder:
hardware_io.rotary_encoder.rotary_encoder_if.RotaryEncoderIf

Public Member Functions

GpioRotaryEncoderPins pins (self)
 Return the GPIO pin assignment used by the encoder.
bool is_running (self)
 Return whether the encoder is currently being monitored.
None start (self, RotationCallback rotated, ButtonCallback|None button_pressed=None, ButtonCallback|None button_released=None)
 Start monitoring the rotary encoder.
None stop (self)
 Stop monitoring the rotary encoder.
None cleanup (self)
 Stop monitoring and release only the GPIO channels used by this encoder.
None poll (self)
 Dispatch accumulated rotary movement.
None tick (self)
 Backward-compatible alias for poll().

Detailed Description

Reads a directly connected rotary encoder using Raspberry Pi GPIO.

Physical Raspberry Pi header pin numbers are used when configuring the encoder.

Member Function Documentation

◆ is_running()

bool hardware_io.rotary_encoder.gpio_rotary_encoder.GpioRotaryEncoder.is_running ( self)

Return whether the encoder is currently being monitored.

Return values
TrueEncoder monitoring is active.
FalseEncoder monitoring is stopped.

Reimplemented from hardware_io.rotary_encoder.rotary_encoder_if.RotaryEncoderIf.

◆ pins()

GpioRotaryEncoderPins hardware_io.rotary_encoder.gpio_rotary_encoder.GpioRotaryEncoder.pins ( self)

Return the GPIO pin assignment used by the encoder.

Returns
Immutable A/B/button BCM pin assignment.

◆ poll()

None hardware_io.rotary_encoder.gpio_rotary_encoder.GpioRotaryEncoder.poll ( self)

Dispatch accumulated rotary movement.

This method should be called periodically by the component using the encoder.

Reimplemented from hardware_io.rotary_encoder.rotary_encoder_if.RotaryEncoderIf.

◆ start()

None hardware_io.rotary_encoder.gpio_rotary_encoder.GpioRotaryEncoder.start ( self,
RotationCallback rotated,
ButtonCallback | None button_pressed = None,
ButtonCallback | None button_released = None )

Start monitoring the rotary encoder.

Parameters
rotatedCallback receiving signed steps since the prior event; positive values indicate clockwise rotation.
button_pressedOptional callback invoked on button press.
button_releasedOptional callback invoked on button release.

Reimplemented from hardware_io.rotary_encoder.rotary_encoder_if.RotaryEncoderIf.


The documentation for this class was generated from the following file:
  • hardware_io/rotary_encoder/gpio_rotary_encoder.py