Exemplo n.º 1
0
def test_display(GPIO, spidev, numpy):
    force_reimport('ST7735')
    import ST7735
    display = ST7735.ST7735(port=0, cs=0, dc=24)
    numpy.dstack().flatten().tolist.return_value = [0xff, 0x00, 0xff, 0x00]
    display.display(mock.MagicMock())

    spidev.SpiDev().xfer3.assert_called_with([0xff, 0x00, 0xff, 0x00])
Exemplo n.º 2
0
def test_setup(GPIO, spidev, numpy):
    force_reimport('ST7735')
    import ST7735
    display = ST7735.ST7735(port=0, cs=0, dc=24)
    del display

    GPIO.output.assert_has_calls(
        [mock.call(24, True), mock.call(24, False)], any_order=True)
Exemplo n.º 3
0
def test_128_64_0(GPIO, spidev, numpy):
    force_reimport('ST7735')
    import ST7735
    display = ST7735.ST7735(port=0,
                            cs=0,
                            dc=24,
                            width=128,
                            height=64,
                            rotation=0)
    assert display.width == 128
    assert display.height == 64
Exemplo n.º 4
0
def test_setup_with_backlight(GPIO, spidev, numpy):
    force_reimport('ST7735')
    import ST7735
    display = ST7735.ST7735(port=0, cs=0, dc=24, backlight=4)
    GPIO.setup.assert_called_with(4, GPIO.OUT)

    display.set_backlight(GPIO.HIGH)

    GPIO.output.assert_has_calls(
        [
            mock.call(4, GPIO.LOW),
            mock.call(4, GPIO.HIGH),
            # Dozens of falls with True/False here
            # due to _init() being called and the display
            # setup setting the command/data pin
            mock.call(4, GPIO.HIGH)
        ],
        any_order=True)
Exemplo n.º 5
0
def test_image_to_data(GPIO, spidev, numpy):
    force_reimport('ST7735')
    numpy.dstack().flatten().tolist.return_value = []
    import ST7735
    assert ST7735.image_to_data(mock.MagicMock()) == []
Exemplo n.º 6
0
def test_color565(GPIO, spidev, numpy):
    force_reimport('ST7735')
    import ST7735
    assert ST7735.color565(255, 255, 255) == 0xFFFF
Exemplo n.º 7
0
def test_setup_with_reset(GPIO, spidev, numpy):
    force_reimport('ST7735')
    import ST7735
    display = ST7735.ST7735(port=0, cs=0, dc=24, rst=4)
    GPIO.setup.assert_called_with(4, GPIO.OUT)
    del display
Exemplo n.º 8
0
def test_setup_no_invert(GPIO, spidev, numpy):
    force_reimport('ST7735')
    import ST7735
    display = ST7735.ST7735(port=0, cs=0, dc=24, invert=False)
    del display