/ examples / st7735r_minitft_featherwing_simpletest.py
st7735r_minitft_featherwing_simpletest.py
 1  """
 2  This test will initialize the display using displayio and draw a solid green
 3  background, a smaller purple rectangle, and some yellow text.
 4  """
 5  
 6  import board
 7  import terminalio
 8  import displayio
 9  from adafruit_display_text import label
10  from adafruit_seesaw.seesaw import Seesaw
11  from adafruit_st7735r import ST7735R
12  
13  # Release any resources currently in use for the displays
14  displayio.release_displays()
15  
16  reset_pin = 8
17  i2c = board.I2C()
18  ss = Seesaw(i2c, 0x5E)
19  ss.pin_mode(reset_pin, ss.OUTPUT)
20  
21  spi = board.SPI()
22  tft_cs = board.D5
23  tft_dc = board.D6
24  
25  display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
26  
27  ss.digital_write(reset_pin, True)
28  display = ST7735R(
29      display_bus, width=160, height=80, colstart=24, rotation=270, bgr=True
30  )
31  
32  # Make the display context
33  splash = displayio.Group(max_size=10)
34  display.show(splash)
35  
36  color_bitmap = displayio.Bitmap(160, 80, 1)
37  color_palette = displayio.Palette(1)
38  color_palette[0] = 0x00FF00  # Bright Green
39  
40  bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
41  splash.append(bg_sprite)
42  
43  # Draw a smaller inner rectangle
44  inner_bitmap = displayio.Bitmap(150, 70, 1)
45  inner_palette = displayio.Palette(1)
46  inner_palette[0] = 0xAA0088  # Purple
47  inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=5, y=5)
48  splash.append(inner_sprite)
49  
50  # Draw a label
51  text_group = displayio.Group(max_size=10, scale=2, x=11, y=40)
52  text = "Hello World!"
53  text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
54  text_group.append(text_area)  # Subgroup for text scaling
55  splash.append(text_group)
56  
57  while True:
58      pass