|
| 1 | +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +""" |
| 5 | +This test will initialize the display using displayio and draw 8 colored |
| 6 | +labels. Useful for testing the color settings on an unknown display. |
| 7 | +""" |
| 8 | + |
| 9 | +import board |
| 10 | +import terminalio |
| 11 | +import displayio |
| 12 | +from adafruit_display_text import label |
| 13 | +from adafruit_st7735r import ST7735R |
| 14 | + |
| 15 | +# Release any resources currently in use for the displays |
| 16 | +displayio.release_displays() |
| 17 | + |
| 18 | +spi = board.SPI() |
| 19 | +tft_cs = board.D5 |
| 20 | +tft_dc = board.D6 |
| 21 | + |
| 22 | +display_bus = displayio.FourWire( |
| 23 | + spi, command=tft_dc, chip_select=tft_cs, reset=board.D9 |
| 24 | +) |
| 25 | + |
| 26 | +display = ST7735R( |
| 27 | + display_bus, width=160, height=80, colstart=24, rotation=270, bgr=False |
| 28 | +) |
| 29 | + |
| 30 | +# Make the display context |
| 31 | +splash = displayio.Group(max_size=10) |
| 32 | +display.show(splash) |
| 33 | + |
| 34 | +color_bitmap = displayio.Bitmap(160, 80, 1) |
| 35 | +color_palette = displayio.Palette(1) |
| 36 | +# write some text in each font color, rgb, cmyk |
| 37 | +color_palette[0] = 0x111111 # light grey |
| 38 | + |
| 39 | +text_group_left = displayio.Group(max_size=10, scale=1, x=0, y=6) |
| 40 | +text_area_red = label.Label(terminalio.FONT, text="RED", color=0xFF0000) |
| 41 | +text_area_green = label.Label(terminalio.FONT, text="\nGREEN", color=0x00FF00) |
| 42 | +text_area_blue = label.Label(terminalio.FONT, text="\n\nBLUE", color=0x0000FF) |
| 43 | +text_area_white = label.Label(terminalio.FONT, text="\n\n\nWHITE", color=0xFFFFFF) |
| 44 | +text_group_left.append(text_area_red) |
| 45 | +text_group_left.append(text_area_green) |
| 46 | +text_group_left.append(text_area_blue) |
| 47 | +text_group_left.append(text_area_white) |
| 48 | +splash.append(text_group_left) |
| 49 | + |
| 50 | +text_group_right = displayio.Group(max_size=10, scale=1, x=80, y=6) |
| 51 | +text_area_cyan = label.Label(terminalio.FONT, text="CYAN", color=0x00FFFF) |
| 52 | +text_group_right.append(text_area_cyan) |
| 53 | +text_area_magenta = label.Label(terminalio.FONT, text="\nMAGENTA", color=0xFF00FF) |
| 54 | +text_group_right.append(text_area_magenta) |
| 55 | +text_area_yellow = label.Label(terminalio.FONT, text="\n\nYELLOW", color=0xFFFF00) |
| 56 | +text_group_right.append(text_area_yellow) |
| 57 | +text_area_black = label.Label(terminalio.FONT, text="\n\n\nBLACK", color=0x000000) |
| 58 | +text_group_right.append(text_area_black) |
| 59 | +splash.append(text_group_right) |
| 60 | + |
| 61 | +while True: |
| 62 | + pass |
0 commit comments