Ejemplo n.º 1
0
def test_init_84x48():
    pcd8544(serial, gpio=Mock())
    serial.command.assert_has_calls(
        [call(33, 20, 176, 32),
         call(32, 128, 64), call(12)])

    # Next 1024 are all data: zero's to clear the RAM
    # (1024 = 128 * 64 / 8)
    serial.data.assert_called_once_with([0] * (84 * 48 // 8))
Ejemplo n.º 2
0
def test_init_84x48():
    pcd8544(serial)
    serial.command.assert_has_calls([
        call(33, 20, 176, 32),
        call(32, 128, 64),
        call(12)
    ])

    # Next 1024 are all data: zero's to clear the RAM
    # (1024 = 128 * 64 / 8)
    serial.data.assert_called_once_with([0] * (84 * 48 // 8))
Ejemplo n.º 3
0
def test_display():
    device = pcd8544(serial, gpio=Mock())
    serial.reset_mock()

    # Use the same drawing primitives as the demo
    with canvas(device) as draw:
        primitives(device, draw)

    # Initial command to reset the display
    serial.command.assert_called_once_with(32, 128, 64)

    # Next 1024 bytes are data representing the drawn image
    serial.data.assert_called_once_with(get_reference_data('demo_pcd8544'))
Ejemplo n.º 4
0
def test_display():
    device = pcd8544(serial)
    serial.reset_mock()

    # Use the same drawing primitives as the demo
    with canvas(device) as draw:
        primitives(device, draw)

    # Initial command to reset the display
    serial.command.assert_called_once_with(32, 128, 64)

    # Next 1024 bytes are data representing the drawn image
    serial.data.assert_called_once_with(get_reference_data('demo_pcd8544'))
Ejemplo n.º 5
0
def test_display():
    device = pcd8544(serial, gpio=Mock())
    serial.reset_mock()

    # Use the same drawing primitives as the demo
    with canvas(device) as draw:
        primitives(device, draw)

    # Initial command to reset the display
    serial.command.assert_called_once_with(32, 128, 64)

    # To regenerate test data, uncomment the following (remember not to commit though)
    # ================================================================================
    # from baseline_data import save_reference_data
    # save_reference_data("demo_pcd8544", serial.data.call_args.args[0])

    # Next 1024 bytes are data representing the drawn image
    serial.data.assert_called_once_with(get_reference_data('demo_pcd8544'))
Ejemplo n.º 6
0
def test_show():
    device = pcd8544(serial, gpio=Mock())
    serial.reset_mock()
    device.show()
    serial.command.assert_called_once_with(12)
Ejemplo n.º 7
0
def test_show():
    device = pcd8544(serial)
    serial.reset_mock()
    device.show()
    serial.command.assert_called_once_with(12)
Ejemplo n.º 8
0
def test_hide():
    device = pcd8544(serial)
    serial.reset_mock()
    device.hide()
    serial.command.assert_called_once_with(8)
Ejemplo n.º 9
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.º 10
0
def test_hide():
    device = pcd8544(serial)
    serial.reset_mock()
    device.hide()
    serial.command.assert_called_once_with(8)
Ejemplo n.º 11
0
RST = 24
SPI_PORT = 0
SPI_DEVICE = 0

# Beaglebone Black hardware SPI config:
# DC = 'P9_15'
# RST = 'P9_12'
# SPI_PORT = 1
# SPI_DEVICE = 0

# Hardware SPI usage:
if configure.pc:
    device = pygame(width=84, height=48, mode="1")
else:
    serial = spi(port=SPI_PORT, device=SPI_DEVICE, gpio_DC=DC, gpio_RST=RST)
    device = pcd8544(serial)
    device.contrast(50)

fore_col = 0
back_col = 1


# Controls text objects drawn to the LCD
class LabelObj(object):
    def __init__(self, string, font, draw):
        self.font = font
        self.draw = draw
        self.string = string

    def push(self, locx, locy):
        self.draw.text((locx, locy),