-
Notifications
You must be signed in to change notification settings - Fork 315
Description
Sometimes, you want to write a script which turns on a device, and leaves it on. Let's say you have a cron job to check something periodically, and control a device accordingly. Rather than have the script continuously running, you want to run it regularly. With gpiozero, your script will turn the device on, exit and turn it back off when running implicit cleanup.
I saw on this SO question recently that someone wanted to do this, and they ended up using RPi.GPIO instead.
It should be possible in gpiozero. If we could either have it per-device:
led = LED(2, cleanup=False)or just in the Device base class:
Device.cleanup = False
led = LED(2)or provide both?
I'm not certain that's the right API, but you get the idea.
This was originally raised in #323. In fact I almost suggested this at the end (though my suggestion doesn't quite make sense...)