mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Disable source when directly controlling DigitalOutputDevice, close #200
This commit is contained in:
@@ -142,14 +142,17 @@ class DigitalOutputDevice(OutputDevice):
|
|||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._stop_blink()
|
self._stop_blink()
|
||||||
|
self._stop_source()
|
||||||
super(DigitalOutputDevice, self).close()
|
super(DigitalOutputDevice, self).close()
|
||||||
|
|
||||||
def on(self):
|
def on(self):
|
||||||
self._stop_blink()
|
self._stop_blink()
|
||||||
|
self._stop_source()
|
||||||
self._write(True)
|
self._write(True)
|
||||||
|
|
||||||
def off(self):
|
def off(self):
|
||||||
self._stop_blink()
|
self._stop_blink()
|
||||||
|
self._stop_source()
|
||||||
self._write(False)
|
self._write(False)
|
||||||
|
|
||||||
def blink(self, on_time=1, off_time=1, n=None, background=True):
|
def blink(self, on_time=1, off_time=1, n=None, background=True):
|
||||||
@@ -172,6 +175,7 @@ class DigitalOutputDevice(OutputDevice):
|
|||||||
this method never returning).
|
this method never returning).
|
||||||
"""
|
"""
|
||||||
self._stop_blink()
|
self._stop_blink()
|
||||||
|
self._stop_source()
|
||||||
self._blink_thread = GPIOThread(
|
self._blink_thread = GPIOThread(
|
||||||
target=self._blink_device, args=(on_time, off_time, n)
|
target=self._blink_device, args=(on_time, off_time, n)
|
||||||
)
|
)
|
||||||
@@ -180,6 +184,10 @@ class DigitalOutputDevice(OutputDevice):
|
|||||||
self._blink_thread.join()
|
self._blink_thread.join()
|
||||||
self._blink_thread = None
|
self._blink_thread = None
|
||||||
|
|
||||||
|
def _stop_source(self):
|
||||||
|
if self.source is not None:
|
||||||
|
self.source = None
|
||||||
|
|
||||||
def _stop_blink(self):
|
def _stop_blink(self):
|
||||||
if self._controller:
|
if self._controller:
|
||||||
self._controller._stop_blink(self)
|
self._controller._stop_blink(self)
|
||||||
@@ -1207,4 +1215,3 @@ class AngularServo(Servo):
|
|||||||
self._value_range *
|
self._value_range *
|
||||||
((value - self._min_angle) / self._angular_range) +
|
((value - self._min_angle) / self._angular_range) +
|
||||||
self._min_value)
|
self._min_value)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user