Skip to content

Commit

Permalink
Make backlight configurable active high/low
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-hull committed Apr 7, 2017
1 parent 2ffb9bc commit cacbb8e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions luma/lcd/aux.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
@lib.rpi_gpio
class backlight(object):
"""
Controls a backlight, assumed to be on GPIO 18 (PWM_CLK0) by default.
Controls a backlight (active low), assumed to be on GPIO 18 (PWM_CLK0) by default.
:param gpio: GPIO interface (must be compatible with `RPi.GPIO <https://pypi.python.org/pypi/RPi.GPIO>`_).
:param gpio_LIGHT: the GPIO pin to use for the backlight.
Expand All @@ -22,13 +23,14 @@ class backlight(object):
:type bcm_LIGHT: int
:raises luma.core.error.UnsupportedPlatform: GPIO access not available.
"""
def __init__(self, gpio=None, gpio_LIGHT=18, bcm_LIGHT=None):
def __init__(self, gpio=None, gpio_LIGHT=18, bcm_LIGHT=None, active_low=True):
if bcm_LIGHT is not None:
deprecation('bcm_LIGHT argument is deprecated in favor of gpio_LIGHT and will be removed in 1.0.0')
gpio_LIGHT = bcm_LIGHT

self._gpio_LIGHT = gpio_LIGHT
self._gpio = gpio or self.__rpi_gpio__()
self._enabled = not active_low

try:
self._gpio.setmode(self._gpio.BCM)
Expand All @@ -48,4 +50,4 @@ def enable(self, value):
"""
assert(value in [True, False])
self._gpio.output(self._gpio_LIGHT,
self._gpio.LOW if value else self._gpio.HIGH)
self._enabled if value else not self._enabled)

0 comments on commit cacbb8e

Please sign in to comment.