def test(): """Test code.""" spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23)) display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16)) display.contrast(0) display.draw_image('images/MicroPython128x128.raw', 0, 0, 128, 128) fixed_font = XglcdFont('fonts/FixedFont5x8.c', 5, 8) contrast_range = list(range(1, 16)) + list(reversed(range(15))) for c in contrast_range: display.contrast(c) display.draw_text(30, 120, 'contrast: {0:02d}'.format(c), fixed_font, color565(255, 255, 255)) sleep(1) display.cleanup()
from adafruit_bluefruit_connect.button_packet import ButtonPacket from random import randint, seed from time import monotonic, sleep # Configuration for CS, DC and Reset pins (Feather nRF52840 Express): cs_pin = DigitalInOut(board.D11) dc_pin = DigitalInOut(board.D10) rst_pin = DigitalInOut(board.D9) # Setup SPI bus using hardware SPI: spi = SPI(clock=board.SCK, MOSI=board.MOSI) # Create the SSD1351 display: display = Display(spi, dc=dc_pin, cs=cs_pin, rst=rst_pin) display.clear() display.contrast(5) NORTH = const(0) EAST = const(1) SOUTH = const(2) WEST = const(3) UP = ButtonPacket.UP DOWN = ButtonPacket.DOWN LEFT = ButtonPacket.LEFT RIGHT = ButtonPacket.RIGHT BORDER_WIDTH = const(2) WALL_HORIZ_LENGTH = const(27) WALL_VERT_LENGTH = const(44) START_ROOM_X = const(5) START_ROOM_Y = const(10)