fusion_hat.modules.rotary_encoder module

class fusion_hat.modules.rotary_encoder.Rotary_Encoder(clk, dt, *, bounce_time=0.002, reverse=False)[source]

Bases: object

_a_rising()[source]

Called on rising edge of channel A. Read channel B to determine rotation direction. Typical rule:

A↑ with B=0 -> CW (+1) A↑ with B=1 -> CCW (-1)

_a_falling()[source]

Called on falling edge of channel A. Read channel B to determine rotation direction. Typical rule:

A↓ with B=1 -> CW (+1) A↓ with B=0 -> CCW (-1)

_apply(direction: int)[source]

Apply one step of rotation, considering direction and reverse flag. Then invoke the external callback if set.

steps()[source]

Return the current step count.

reset()[source]

Reset the encoder position to zero.

close()[source]

Release interrupts and clean up GPIO resources.