Hi all, I am trying to implement interrupts on the A and B pins of a rotary encoder. I can't find any documentation on this, help please.
OPMacca
Hi all, I am trying to implement interrupts on the A and B pins of a rotary encoder. I can't find any documentation on this, help please.
floitsch04/18/2023 07:44 AM
Toit doesn't give direct access to interrupts. If you just want to wait for a pin to change you would generally use pin.wait_for. However, for a rotary encoder that would probably be too slow. I think the pulse_counter library is what you are looking for: https://libs.toit.io/pulse_counter/library-summary
floitsch04/18/2023 07:47 AM
That peripheral automatically counts pulses for you. I'm not too familiar with rotary encoders, though. So maybe that doesn't work.
Macca04/18/2023 07:50 AM
Mmm, rotary encoders rely on the relationship of Pin A and Pin B. There are usually four possible stable states. which indicate the direction of rotation.
Macca04/18/2023 07:50 AM
I will try the pulse counter as I have an upcoming project anyway.
floitsch04/18/2023 07:50 AM
The pulse counter has one pin to count and another as control pin for the direction.