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

NativeFactory wait_for_press and when_activated callbacks not called #1137

Open
NeonDaniel opened this issue Mar 30, 2024 · 2 comments
Open

Comments

@NeonDaniel
Copy link

Operating system: Debian Bookworm (neon-debos build)
Python version: 3.10.13
Pi model: Pi 4 Model B
GPIO Zero version: 2.0.1
Pin factory used: Native

I had a working class implemented with the default (RPi.GPIO) backend working but I am trying to move to NativeFactory to support kernel 6.6 and Pi5. The relevant code is linked to NeonGeckoCom/neon-phal-plugin-switches#16.

I tried debugging interactively and noted that a when_activated callback was never called and wait_for_press would wait infinitely when I tried pressing and holding the button multiple times. is_pressed and value appear to always report accurately though.

Python 3.10.13 (main, Mar 29 2024, 21:16:14) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpiozero
>>> from gpiozero.pins.native import NativeFactory
>>> act = gpiozero.Button(24, pull_up=None, active_state=False, pin_factory=NativeFactory())
>>> # button not pressed
>>> print(act.is_pressed)
False
>>> # button pressed
>>> print(act.is_pressed)
True
>>> act.wait_for_press()
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/neon/venv/lib/python3.10/site-packages/gpiozero/mixins.py", line 278, in wait_for_active
    return self._active_event.wait(timeout)
  File "/usr/local/lib/python3.10/threading.py", line 607, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/local/lib/python3.10/threading.py", line 320, in wait
    waiter.acquire()
KeyboardInterrupt
>>> 
@lurch
Copy link
Contributor

lurch commented Apr 3, 2024

I am trying to move to NativeFactory to support kernel 6.6 and Pi5.

You might have better luck using LGPIOFactory ? See https://gpiozero.readthedocs.io/en/latest/api_pins.html#changing-the-pin-factory

@NeonDaniel
Copy link
Author

I am trying to move to NativeFactory to support kernel 6.6 and Pi5.

You might have better luck using LGPIOFactory ? See https://gpiozero.readthedocs.io/en/latest/api_pins.html#changing-the-pin-factory

I don't think I tried that yet but if it supports kernel 6.6+ then it could be a valid workaround.

NeonDaniel pushed a commit to NeonGeckoCom/sj201-interface that referenced this issue Apr 8, 2024
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

2 participants