Skip to content

Commit 8ea81ff

Browse files
authored
Create displayio_ssd1306_64x32_simpletest.py
To simplify testing on those tiny screen.
1 parent 57d3299 commit 8ea81ff

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SPDX-FileCopyrightText: 2022 David Glaude (based on 2021 ladyada for Adafruit Industries)
2+
# SPDX-License-Identifier: MIT
3+
4+
"""
5+
This test will initialize the display using displayio and draw a solid white
6+
background, a smaller black rectangle, and some white text.
7+
Customized version of displayio_ssd1306_simpletest.py for 64x32
8+
"""
9+
10+
import board
11+
import displayio
12+
import terminalio
13+
from adafruit_display_text import label
14+
import adafruit_displayio_ssd1306
15+
16+
displayio.release_displays()
17+
18+
i2c = board.I2C() # uses board.SCL and board.SDA
19+
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
20+
21+
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
22+
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=64, height=32)
23+
24+
# Make the display context
25+
splash = displayio.Group()
26+
display.show(splash)
27+
28+
color_bitmap = displayio.Bitmap(64, 32, 1)
29+
color_palette = displayio.Palette(1)
30+
color_palette[0] = 0xFFFFFF # White
31+
32+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
33+
splash.append(bg_sprite)
34+
35+
## Draw a smaller inner rectangle
36+
inner_bitmap = displayio.Bitmap(62, 30, 1)
37+
inner_palette = displayio.Palette(1)
38+
inner_palette[0] = 0x000000 # Black
39+
40+
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=1, y=1)
41+
splash.append(inner_sprite)
42+
43+
text = "Hello"
44+
text_area = label.Label( terminalio.FONT, text=text, color=0xFFFFFF, x=2, y=6)
45+
splash.append(text_area)
46+
47+
text = "World"
48+
text_area = label.Label( terminalio.FONT, text=text, color=0xFFFFFF, x=32, y=15)
49+
splash.append(text_area)
50+
51+
text = "9876543210"
52+
text_area = label.Label( terminalio.FONT, text=text, color=0xFFFFFF, x=2, y=24)
53+
splash.append(text_area)
54+
55+
while True:
56+
pass

0 commit comments

Comments
 (0)