-
Notifications
You must be signed in to change notification settings - Fork 1.3k
RP2040 rotaryio fails with two encoders #10024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Update: It appears to get out of hanging if a change happens on |
The hang occurs when constructing the 2nd encoder instance. However, if I modify the StateMachine implementation so that "use_existing_program" always returns false, the problem stops. Or at least it successfully constructs the StateMachine object in this case. I don't have any encoders hooked up. |
I wrote some code so that I didn't need any encoder knobs for testing. # Test simulated encoder (issue #10024) for metro rp2350
# Connect jumper wires from RX/TX/D2/D3 to A0/A1/A2/A3
# Each encoder should count.
import board, rotaryio
import digitalio
d = digitalio.DigitalInOut(board.D0)
d.switch_to_output(False)
e = digitalio.DigitalInOut(board.D1)
e.switch_to_output(False)
f = digitalio.DigitalInOut(board.D2)
f.switch_to_output(False)
g = digitalio.DigitalInOut(board.D3)
g.switch_to_output(False)
r1 = rotaryio.IncrementalEncoder(board.A0, board.A1, divisor=1)
r1.position = 0
r2 = rotaryio.IncrementalEncoder(board.A2, board.A3, divisor=1)
r2.position = 0
for _ in range(8):
d.value = True
print(f"{+d.value}{+e.value} {r1.position} {r2.position}")
e.value = True
print(f"{+d.value}{+e.value} {r1.position} {r2.position}")
d.value = False
print(f"{+d.value}{+e.value} {r1.position} {r2.position |
.. for duplicate programs, like two IncrementalEncoder instances. Closes: adafruit#10024
Verified that fix #10025 does make two encoders work on RP2040 Pico and RP2350 Pico2. |
Thanks for testing, @todbot ! |
CircuitPython version and board name
Code/REPL
Behavior
Code hangs on creation of
encoder2
, which is obviously not correct.Code should repeatedly print position of both encoders.
Description
Works on 9.2.1.
Does not work on 9.2.2 and above.
Related to #9682?
Additional information
Redditor had his issue too: https://old.reddit.com/r/circuitpython/comments/1igqzyf/two_incrementalencoders_fail/
The text was updated successfully, but these errors were encountered: