mirror of
https://github.com/pimoroni/st7735-python.git
synced 2025-01-05 22:40:25 +03:00
Fix fix backlight pin state, add set_backlight
This commit is contained in:
@@ -176,8 +176,12 @@ class ST7735(object):
|
|||||||
GPIO.setup(dc, GPIO.OUT)
|
GPIO.setup(dc, GPIO.OUT)
|
||||||
|
|
||||||
# Setup backlight as output (if provided).
|
# Setup backlight as output (if provided).
|
||||||
|
self._backlight = backlight
|
||||||
if backlight is not None:
|
if backlight is not None:
|
||||||
GPIO.setup(backlight, GPIO.OUT)
|
GPIO.setup(sbacklight, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
|
||||||
|
GPIO.output(backlight, GPIO.LOW)
|
||||||
|
time.sleep(0.1)
|
||||||
|
GPIO.output(backlight, GPIO.HIGH)
|
||||||
|
|
||||||
# Setup reset as output (if provided).
|
# Setup reset as output (if provided).
|
||||||
if rst is not None:
|
if rst is not None:
|
||||||
@@ -202,6 +206,11 @@ class ST7735(object):
|
|||||||
end = min(start + chunk_size, len(data))
|
end = min(start + chunk_size, len(data))
|
||||||
self._spi.xfer(data[start:end])
|
self._spi.xfer(data[start:end])
|
||||||
|
|
||||||
|
def set_backlight(self, value):
|
||||||
|
"""Set the backlight on/off."""
|
||||||
|
if self._backlight is not None:
|
||||||
|
GPIO.output(self._backlight, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def width(self):
|
def width(self):
|
||||||
return self._width if self._rotation == 0 or self._rotation == 180 else self._height
|
return self._width if self._rotation == 0 or self._rotation == 180 else self._height
|
||||||
|
|||||||
Reference in New Issue
Block a user