OpenRoadCode
Public API reference for OpenRoadCode
Loading...
Searching...
No Matches
hardware_io.rotary_encoder.seesaw_rotary_encoder.SeesawRotaryEncoder Class Reference

Reads rotary encoder events from an Adafruit Seesaw I2C device. More...

Inheritance diagram for hardware_io.rotary_encoder.seesaw_rotary_encoder.SeesawRotaryEncoder:
hardware_io.rotary_encoder.rotary_encoder_if.RotaryEncoderIf

Public Member Functions

None __init__ (self, int address=DEFAULT_ADDRESS, *, Any|None i2c=None, int button_pin=DEFAULT_BUTTON_PIN, float poll_interval=DEFAULT_POLL_INTERVAL, bool reverse_direction=False, float debounce_seconds=0.03)
 Args: address: I2C address of the Seesaw device.
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.
Public Member Functions inherited from hardware_io.rotary_encoder.rotary_encoder_if.RotaryEncoderIf
None poll (self)
 Perform implementation-specific polling work.

Detailed Description

Reads rotary encoder events from an Adafruit Seesaw I2C device.

Rotation and button events are monitored in a background thread.

Constructor & Destructor Documentation

◆ __init__()

None hardware_io.rotary_encoder.seesaw_rotary_encoder.SeesawRotaryEncoder.__init__ ( self,
int address = DEFAULT_ADDRESS,
* ,
Any | None i2c = None,
int button_pin = DEFAULT_BUTTON_PIN,
float poll_interval = DEFAULT_POLL_INTERVAL,
bool reverse_direction = False,
float debounce_seconds = 0.03 )

Args: address: I2C address of the Seesaw device.

i2c: Optional initialized I2C bus. When omitted, board.I2C() is used.

button_pin: Seesaw GPIO pin connected to the encoder button.

poll_interval: Delay between hardware reads, in seconds.

reverse_direction: Reverse the reported rotation direction.

debounce_seconds: Time that the button state must remain stable before a button event is emitted.

Member Function Documentation

◆ is_running()

bool hardware_io.rotary_encoder.seesaw_rotary_encoder.SeesawRotaryEncoder.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.

◆ start()

None hardware_io.rotary_encoder.seesaw_rotary_encoder.SeesawRotaryEncoder.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/seesaw_rotary_encoder.py