mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-12-08 20:39:01 +00:00
Fix #204 and start readying the release
Also re-numbers energenie sockets 1-4 (as noted by @bennuttall in comments to #239), and adds several "real pins" tests and board tests. The bad-PWM stuff is currently disabled as it causes segfaults when running the tests and I can't seem to trace the cause at the moment. Finally, I've tweaked the deb config to suggest gpiozero, removed spidev as a mandatory dep (which'll fix installs on wheezy for py3), and there's some more miscellaneous last-minute stuff here that I can't recall...
This commit is contained in:
@@ -41,6 +41,7 @@ class OutputDevice(SourceMixin, GPIODevice):
|
||||
"""
|
||||
def __init__(self, pin=None, active_high=True, initial_value=False):
|
||||
super(OutputDevice, self).__init__(pin)
|
||||
self._lock = Lock()
|
||||
self.active_high = active_high
|
||||
if initial_value is None:
|
||||
self.pin.function = 'output'
|
||||
@@ -70,6 +71,17 @@ class OutputDevice(SourceMixin, GPIODevice):
|
||||
"""
|
||||
self._write(False)
|
||||
|
||||
def toggle(self):
|
||||
"""
|
||||
Reverse the state of the device. If it's on, turn it off; if it's off,
|
||||
turn it on.
|
||||
"""
|
||||
with self._lock:
|
||||
if self.is_active:
|
||||
self.off()
|
||||
else:
|
||||
self.on()
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""
|
||||
@@ -121,7 +133,6 @@ class DigitalOutputDevice(OutputDevice):
|
||||
def __init__(self, pin=None, active_high=True, initial_value=False):
|
||||
self._blink_thread = None
|
||||
super(DigitalOutputDevice, self).__init__(pin, active_high, initial_value)
|
||||
self._lock = Lock()
|
||||
self._controller = None
|
||||
|
||||
@property
|
||||
@@ -145,17 +156,6 @@ class DigitalOutputDevice(OutputDevice):
|
||||
self._stop_blink()
|
||||
self._write(False)
|
||||
|
||||
def toggle(self):
|
||||
"""
|
||||
Reverse the state of the device. If it's on, turn it off; if it's off,
|
||||
turn it on.
|
||||
"""
|
||||
with self._lock:
|
||||
if self.is_active:
|
||||
self.off()
|
||||
else:
|
||||
self.on()
|
||||
|
||||
def blink(self, on_time=1, off_time=1, n=None, background=True):
|
||||
"""
|
||||
Make the device turn on and off repeatedly.
|
||||
@@ -757,7 +757,8 @@ class Motor(SourceMixin, CompositeDevice):
|
||||
)
|
||||
super(Motor, self).__init__(
|
||||
forward_device=PWMOutputDevice(forward),
|
||||
backward_device=PWMOutputDevice(backward))
|
||||
backward_device=PWMOutputDevice(backward),
|
||||
_order=('forward_device', 'backward_device'))
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
|
||||
Reference in New Issue
Block a user