Merge pull request #333 from lurch/add_ledborg

Add LedBorg as a subclass of RGBLED
This commit is contained in:
Ben Nuttall
2016-05-26 23:08:39 +01:00
8 changed files with 75 additions and 14 deletions

View File

@@ -106,6 +106,7 @@ from .boards import (
LEDCollection,
LEDBoard,
LEDBarGraph,
LedBorg,
PiLiter,
PiLiterBarGraph,
TrafficLights,

View File

@@ -21,7 +21,14 @@ from .exc import (
OutputDeviceBadValue,
)
from .input_devices import Button
from .output_devices import OutputDevice, LED, PWMLED, Buzzer, Motor
from .output_devices import (
OutputDevice,
LED,
PWMLED,
RGBLED,
Buzzer,
Motor,
)
from .threads import GPIOThread
from .devices import Device, CompositeDevice
from .mixins import SharedMixin, SourceMixin
@@ -431,6 +438,36 @@ class LEDBarGraph(LEDCollection):
led.value = calc_value(index)
class LedBorg(RGBLED):
"""
Extends :class:`RGBLED` for the `PiBorg LedBorg`_: an add-on board
containing a very bright RGB LED.
The LedBorg pins are fixed and therefore there's no need to specify them
when constructing this class. The following example turns the LedBorg
purple::
from gpiozero import LedBorg
led = LedBorg()
led.color = (1, 0, 1)
:param tuple initial_value:
The initial color for the LedBorg. Defaults to black ``(0, 0, 0)``.
:param bool pwm:
If ``True`` (the default), construct :class:`PWMLED` instances for
each component of the LedBorg. If ``False``, construct regular
:class:`LED` instances, which prevents smooth color graduations.
.. _PiBorg LedBorg: https://www.piborg.org/ledborg
"""
def __init__(self, initial_value=(0, 0, 0), pwm=True):
super(LedBorg, self).__init__(red=17, green=27, blue=22,
initial_value=initial_value, pwm=pwm)
class PiLiter(LEDBoard):
"""
Extends :class:`LEDBoard` for the `Ciseco Pi-LITEr`_: a strip of 8 very bright