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

Make custom EventfulDigitialOutputDevice class with callback functions so leds can turn on/off automatically #40

Open
fergusL opened this issue Oct 3, 2019 · 1 comment

Comments

@fergusL
Copy link
Contributor

fergusL commented Oct 3, 2019

Ideally all these LED operations should be done automatically by when_activated & when_deactivated callback functions associated with the relays. Unfortunately the gpiozero DigitalOutputDevice class doesn't have those attributes like DigitalInput does. But! We could fairly easily fix that oversight by making out own DigitalOutputDevice subclass that includes the EventsMixin though... I think it would be a simple as:

from gpiozero import DigitalInputDevice, DigitalOutputDevice
from gpiozero.mixins import EventsMixin

class EventfulDigitalOutputDevice(EventsMixin, DigitalOutputDevice):
    pass

Multiple inheritance is powerful magic...

Originally posted by @AnthonyHorton in https://github.com/_render_node/MDE3OlB1bGxSZXF1ZXN0UmV2aWV3Mjk1OTgyODEx/pull_request_reviews/more_threads

@fergusL
Copy link
Contributor Author

fergusL commented Oct 3, 2019

Have tried the above but the callback functions do not seem to get activated by the DigitalOutputDevice.on() calls used to switch the relay positions. Probably need to do a little bit more poking around to figure out what's going on

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