mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Miscellaneous minor changes for 1.1
This commit is contained in:
2
Makefile
2
Makefile
@@ -159,7 +159,7 @@ release: $(PY_SOURCES) $(DOC_SOURCES) $(DEB_SOURCES)
|
|||||||
dch --newversion $(VER)$(DEB_SUFFIX) --controlmaint
|
dch --newversion $(VER)$(DEB_SUFFIX) --controlmaint
|
||||||
# commit the changes and add a new tag
|
# commit the changes and add a new tag
|
||||||
git commit debian/changelog -m "Updated changelog for release $(VER)"
|
git commit debian/changelog -m "Updated changelog for release $(VER)"
|
||||||
git tag -s release-$(VER) -m "Release $(VER)"
|
git tag -s v$(VER) -m "Release v$(VER)"
|
||||||
# update the package's registration on PyPI (in case any metadata's changed)
|
# update the package's registration on PyPI (in case any metadata's changed)
|
||||||
$(PYTHON) $(PYFLAGS) setup.py register
|
$(PYTHON) $(PYFLAGS) setup.py register
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ RGBLED
|
|||||||
======
|
======
|
||||||
|
|
||||||
.. autoclass:: RGBLED(red, green, blue, active_high=True)
|
.. autoclass:: RGBLED(red, green, blue, active_high=True)
|
||||||
:members: on, off, blink, red, green, blue, value
|
:members: on, off, toggle, blink, red, green, blue, color
|
||||||
|
|
||||||
Motor
|
Motor
|
||||||
=====
|
=====
|
||||||
|
|||||||
@@ -520,17 +520,22 @@ class RGBLED(SourceMixin, CompositeDevice):
|
|||||||
The GPIO pin that controls the blue component of the RGB LED.
|
The GPIO pin that controls the blue component of the RGB LED.
|
||||||
|
|
||||||
:param bool active_high:
|
:param bool active_high:
|
||||||
If ``True`` (the default), the :meth:`on` method will set the GPIOs to
|
Set to ``True`` (the default) for common cathode RGB LEDs. If you are
|
||||||
HIGH. If ``False``, the :meth:`on` method will set the GPIOs to LOW
|
using a common anode RGB LED, set this to ``False``.
|
||||||
(the :meth:`off` method always does the opposite).
|
|
||||||
|
:param bool initial_value:
|
||||||
|
The initial color for the LED. Defaults to black ``(0, 0, 0)``.
|
||||||
"""
|
"""
|
||||||
def __init__(self, red=None, green=None, blue=None, active_high=True):
|
def __init__(
|
||||||
|
self, red=None, green=None, blue=None, active_high=True,
|
||||||
|
initial_value=(0, 0, 0)):
|
||||||
self._leds = ()
|
self._leds = ()
|
||||||
self._blink_thread = None
|
self._blink_thread = None
|
||||||
if not all([red, green, blue]):
|
if not all([red, green, blue]):
|
||||||
raise OutputDeviceError('red, green, and blue pins must be provided')
|
raise OutputDeviceError('red, green, and blue pins must be provided')
|
||||||
super(RGBLED, self).__init__()
|
super(RGBLED, self).__init__()
|
||||||
self._leds = tuple(PWMLED(pin, active_high) for pin in (red, green, blue))
|
self._leds = tuple(PWMLED(pin, active_high) for pin in (red, green, blue))
|
||||||
|
self.value = initial_value
|
||||||
|
|
||||||
red = _led_property(0)
|
red = _led_property(0)
|
||||||
green = _led_property(1)
|
green = _led_property(1)
|
||||||
@@ -563,18 +568,28 @@ class RGBLED(SourceMixin, CompositeDevice):
|
|||||||
|
|
||||||
def on(self):
|
def on(self):
|
||||||
"""
|
"""
|
||||||
Turn the device on. This equivalent to setting the device color to
|
Turn the LED on. This equivalent to setting the LED color to white
|
||||||
white ``(1, 1, 1)``.
|
``(1, 1, 1)``.
|
||||||
"""
|
"""
|
||||||
self.value = (1, 1, 1)
|
self.value = (1, 1, 1)
|
||||||
|
|
||||||
def off(self):
|
def off(self):
|
||||||
"""
|
"""
|
||||||
Turn the device off. This is equivalent to setting the device color
|
Turn the LED off. This is equivalent to setting the LED color to black
|
||||||
to black ``(0, 0, 0)``.
|
``(0, 0, 0)``.
|
||||||
"""
|
"""
|
||||||
self.value = (0, 0, 0)
|
self.value = (0, 0, 0)
|
||||||
|
|
||||||
|
def toggle(self):
|
||||||
|
"""
|
||||||
|
Toggle the state of the device. If the device is currently off
|
||||||
|
(:attr:`value` is ``(0, 0, 0)``), this changes it to "fully" on
|
||||||
|
(:attr:`value` is ``(1, 1, 1)``). If the device has a specific color,
|
||||||
|
this method inverts the color.
|
||||||
|
"""
|
||||||
|
r, g, b = self.value
|
||||||
|
self.value = (1 - r, 1 - g, 1 - b)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._stop_blink()
|
self._stop_blink()
|
||||||
for led in self._leds:
|
for led in self._leds:
|
||||||
|
|||||||
Reference in New Issue
Block a user