Esempio n. 1
0
def test_display():
    device = st7567(serial, gpio=Mock())
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command.side_effect = command
    serial.data.side_effect = data

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

    assert serial.data.called
    assert serial.command.called

    # To regenerate test data, uncomment the following (remember not to commit though)
    # ================================================================================
    # from baseline_data import save_reference_data
    # save_reference_data("demo_st7567", recordings)

    assert recordings == get_reference_data('demo_st7567')
Esempio n. 2
0
def test_display():
    device = ili9341(serial, gpio=Mock())
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command.side_effect = command
    serial.data.side_effect = data

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

    assert serial.data.called
    assert serial.command.called

    assert recordings == [{
        'command': [0x2a]
    }, {
        'data': [0x00, 0x00, 0x01, 0x3f]
    }, {
        'command': [0x2b]
    }, {
        'data': [0x00, 0x00, 0x00, 0xef]
    }, {
        'command': [0x2c]
    }, {
        'data': bytearray(get_reference_data('demo_ili9341'))
    }]
Esempio n. 3
0
def test_display():
    """
    UC1701X LCD screen can draw and display an image.
    """
    device = uc1701x(serial, gpio=Mock())
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command = Mock(side_effect=command, unsafe=True)
    serial.data = Mock(side_effect=data, unsafe=True)

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

    serial.data.assert_called()
    serial.command.assert_called()

    assert recordings == get_reference_data('demo_uc1701x')
Esempio n. 4
0
def test_display():
    device = st7735(serial, gpio=Mock())
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command.side_effect = command
    serial.data.side_effect = data

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

    assert serial.data.called
    assert serial.command.called

    assert recordings == [{
        'command': [42]
    }, {
        'data': [0, 0, 0, 159]
    }, {
        'command': [43]
    }, {
        'data': [0, 0, 0, 127]
    }, {
        'command': [44]
    }, {
        'data': get_reference_data('demo_st7735')
    }]
Esempio n. 5
0
def test_display():
    """
    UC1701X LCD screen can draw and display an image.
    """
    device = uc1701x(serial, gpio=Mock())
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command = Mock(side_effect=command, unsafe=True)
    serial.data = Mock(side_effect=data, unsafe=True)

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

    serial.data.assert_called()
    serial.command.assert_called()

    # To regenerate test data, uncomment the following (remember not to commit though)
    # ================================================================================
    # from baseline_data import save_reference_data
    # save_reference_data("demo_uc1701x", recordings)

    assert recordings == get_reference_data('demo_uc1701x')
Esempio n. 6
0
def test_monochrome_display():
    """
    SSD1322 OLED screen can draw and display a monochrome image.
    """
    device = ssd1322(serial, mode="1", framebuffer=full_frame())
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command.side_effect = command
    serial.data.side_effect = data

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

    assert serial.data.called
    assert serial.command.called

    # To regenerate test data, uncomment the following (remember not to commit though)
    # ================================================================================
    # from baseline_data import save_reference_data
    # save_reference_data("demo_ssd1322_monochrome", recordings)

    assert recordings == get_reference_data('demo_ssd1322_monochrome')
Esempio n. 7
0
def test_display():
    device = st7789(serial, gpio=Mock(), framebuffer=full_frame())
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.extend(data)

    def command(*cmd):
        recordings.extend(['command', list(cmd)[0], 'data', *list(cmd)[1:]])

    serial.command.side_effect = command
    serial.data.side_effect = data

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

    assert serial.data.called
    assert serial.command.called

    # To regenerate test data, uncomment the following (remember not to commit though)
    # ================================================================================
    # from baseline_data import save_reference_data
    # save_reference_data("demo_st7789", recordings)

    assert recordings == get_reference_data('demo_st7789')
Esempio n. 8
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'))
Esempio n. 9
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'))
Esempio n. 10
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'))
Esempio n. 11
0
def test_display():
    """
    SSD1331 OLED screen can draw and display an image.
    """
    device = ssd1331(serial, framebuffer=full_frame())
    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(21, 0, 95, 117, 0, 63)

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

    # Next 12288 bytes are data representing the drawn image
    serial.data.assert_called_once_with(get_reference_data('demo_ssd1331'))
Esempio n. 12
0
def test_display():
    device = st7567(serial)
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command.side_effect = command
    serial.data.side_effect = data

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

    assert serial.data.called
    assert serial.command.called

    assert recordings == get_reference_data('demo_st7567')
Esempio n. 13
0
def test_display():
    device = st7567(serial)
    serial.reset_mock()

    recordings = []

    def data(data):
        recordings.append({'data': data})

    def command(*cmd):
        recordings.append({'command': list(cmd)})

    serial.command.side_effect = command
    serial.data.side_effect = data

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

    assert serial.data.called
    assert serial.command.called

    assert recordings == get_reference_data('demo_st7567')