mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Add LedBorg as a subclass of RGBLED
This commit is contained in:
committed by
Andrew Scheller
parent
9278a2f857
commit
3a7acbf89d
@@ -106,6 +106,7 @@ from .boards import (
|
||||
LEDCollection,
|
||||
LEDBoard,
|
||||
LEDBarGraph,
|
||||
LedBorg,
|
||||
PiLiter,
|
||||
PiLiterBarGraph,
|
||||
TrafficLights,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user