Skip to content
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

Listeners lost when instantiating multiple RotaryIRQs #13

Open
jphalip opened this issue Apr 29, 2021 · 0 comments
Open

Listeners lost when instantiating multiple RotaryIRQs #13

jphalip opened this issue Apr 29, 2021 · 0 comments

Comments

@jphalip
Copy link

jphalip commented Apr 29, 2021

Hi,

I'm having issues with the following sample code:

aaa = RotaryIRQ(
    pin_num_clk=26,
    pin_num_dt=27,
    min_val=0,
    max_val=10,
    reverse=True,
    range_mode=RotaryIRQ.RANGE_WRAP)

aaa.add_listener(lambda: print('aaa'))

bbb = RotaryIRQ(
    pin_num_clk=26,
    pin_num_dt=27,
    min_val=0,
    reverse=True,
    range_mode=RotaryIRQ.RANGE_UNBOUNDED)

bbb.add_listener(lambda: print('bbb'))

(Note: I'm using the same physical encoder with the same pins, but with otherwise different parameters. Also, I'm using a Raspberry Pi Pico with the latest version of Micropython.)

I would expect to see both aaa and bbb printed every time I move the rotary encoder. However, only bbb gets printed.

In other terms, it looks like instantiating a second RotaryIRQ causes the first one to lose its listeners.

Is that a bug or am I missing something?

Thanks,

Julien

miketeachman added a commit that referenced this issue Oct 8, 2022
listener fix:  Issue #13

also minor changes to Licence commenting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant