-
Hi I am running Ubuntu 20.04.6 64bit on a Pi 3 for ROS. Tried using the OS packages python3-gpiozero (1.4.1-1.2) with python3-rpi.gpio (0.6.5-1ubuntu3) and rpi.gpio-common:arm64 (0.6.5-1ubuntu3) and also the pip3 packages gpiozero-1.6.2-py2.py3-none-any.whl and RPi.GPIO-0.7.1.tar.gz but with the same result. The 'Button' device works, but the DigitalInputDevice .when_activated doesn't seem to get called. Example output:
Code:
Thanks very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
def __init__(self, pin):
self._value = 0
encoder = DigitalInputDevice(pin, pull_up=True)
encoder.when_activated = self._increment
encoder.when_deactivated = self._increment
print("Init") In the function above, |
Beta Was this translation helpful? Give feedback.
In the function above,
encoder
is a local variable, and so I think it will go out of scope (and get garbage-collected) at the end of the function. Does your code work any better if you doself._encoder = ...
instead?