Ejemplo n.º 1
0
def test_unsupported_platform():
    e = RuntimeError('Module not imported correctly!')
    errorgpio = Mock(unsafe=True)
    errorgpio.setmode.side_effect = e

    try:
        backlight(gpio_LIGHT=19, gpio=errorgpio)
    except luma.core.error.UnsupportedPlatform as ex:
        assert str(ex) == 'GPIO access not available'
Ejemplo n.º 2
0
#! /usr/bin/python

from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import pcd8544, st7735, uc1701x
from RPi import GPIO
from luma.lcd.aux import backlight

serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24)
channel = 18
light = backlight(gpio_LIGHT=channel, active_low=False)
light.enable(True)

device = pcd8544(serial, rotate=2)
with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((10, 10), "阿湘!", fill="red")
raw_input("Here")
Ejemplo n.º 3
0
def test_active_high_enable_off():
    gpio_LIGHT = 19
    light = backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT, active_low=False)
    gpio.reset_mock()
    light.enable(False)
    gpio.output.assert_called_once_with(gpio_LIGHT, gpio.LOW)
Ejemplo n.º 4
0
def test_active_low_enable_on():
    gpio_LIGHT = 14
    light = backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT)
    gpio.reset_mock()
    light.enable(True)
    gpio.output.assert_called_once_with(gpio_LIGHT, gpio.LOW)
Ejemplo n.º 5
0
def test_init():
    gpio_LIGHT = 11
    backlight(gpio=gpio, gpio_LIGHT=gpio_LIGHT)
    gpio.setmode.assert_called_once_with(gpio.BCM)
    gpio.setup.assert_called_once_with(gpio_LIGHT, gpio.OUT)
    gpio.output.assert_called_once_with(gpio_LIGHT, gpio.LOW)
Ejemplo n.º 6
0
 def init_st7735(self):
     light = backlight(gpio=GPIO, gpio_LIGHT=18, active_low=False)
     light.enable(True)
     serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24)
     device = st7735(serial)
     return device