def test_alpha_blending(): device = unicornhathd(serial) serial.reset_mock() with canvas(device) as draw: draw.rectangle(device.bounding_box, outline=(255, 128, 64, 32)) serial.data.assert_called_once_with( [0x72] + get_json_data('demo_unicornhathd_alphablend'))
def test_display(): """ SH1106 OLED screen can draw and display an image. """ device = sh1106(serial) 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_json_data('demo_sh1106')
def test_display(): device = unicornhathd(serial) serial.reset_mock() with canvas(device) as draw: draw.rectangle(device.bounding_box, outline="white") serial.data.assert_called_once_with([0x72] + get_json_data('demo_unicornhathd'))
def test_display(): """ SSD1351 OLED screen can draw and display a color image. """ device = ssd1351(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 == [ {'command': [21]}, {'data': [0, 127]}, {'command': [117]}, {'data': [0, 127]}, {'command': [92]}, {'data': get_json_data('demo_ssd1351')} ]
def test_greyscale_display(): """ SSD1322_NHD OLED screen can draw and display a greyscale image. """ device = ssd1322_nhd(serial, mode="RGB") 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': [21]}, {'data': [28, 91]}, {'command': [117]}, {'data': [0, 63]}, {'command': [92]}, {'data': get_json_data('demo_ssd1322_nhd_greyscale')} ]
def test_display(): """ SSD1309 OLED screen can draw and display an image. """ device = ssd1309(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(33, 0, 127, 34, 0, 7) # Next 1024 bytes are data representing the drawn image serial.data.assert_called_once_with(get_json_data('demo_ssd1309'))
def test_monochrome_display(): """ SSD1327 OLED screen can draw and display a monochrome image. """ device = ssd1327(serial, mode="1") 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, 63, 117, 0, 127) # Next 4096 bytes are data representing the drawn image serial.data.assert_called_once_with(get_json_data('demo_ssd1327_monochrome'))
def test_monochrome_display(): """ SSD1362 OLED screen can draw and display a monochrome image. """ device = ssd1362(serial, mode="1") 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, 127, 117, 0, 63) # Next 4096 bytes are data representing the drawn image serial.data.assert_called_once_with(get_json_data('demo_ssd1362_monochrome'))
def test_greyscale_display(): """ SSD1322_NHD OLED screen can draw and display a greyscale image. """ device = ssd1322_nhd(serial, mode="RGB") 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': [21] }, { 'data': [28, 91] }, { 'command': [117] }, { 'data': [0, 63] }, { 'command': [92] }, { 'data': get_json_data('demo_ssd1322_nhd_greyscale') }]
def test_alpha_blending(): device = unicornhathd(serial) serial.reset_mock() with canvas(device) as draw: draw.rectangle(device.bounding_box, outline=(255, 128, 64, 32)) serial.data.assert_called_once_with([0x72] + get_json_data('demo_unicornhathd_alphablend'))