Skip to content

Commit 92d664e

Browse files
authored
Merge pull request #11 from makermelissa/master
Updated examples to be more comprehensive
2 parents 6a82184 + ef6e8d4 commit 92d664e

4 files changed

+87
-13
lines changed
+23-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""
2-
This test will initialize the display using displayio
3-
and draw a solid red background
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
44
"""
55

66
import board
77
import displayio
8+
import terminalio
9+
from adafruit_display_text import label
810
from adafruit_st7735r import ST7735R
911

1012
spi = board.SPI()
@@ -14,20 +16,36 @@
1416
displayio.release_displays()
1517
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
1618

17-
display = ST7735R(display_bus, width=128, height=160, bgr=True)
19+
display = ST7735R(display_bus, width=160, height=128, rotation=90, bgr=True)
1820

1921
# Make the display context
2022
splash = displayio.Group(max_size=10)
2123
display.show(splash)
2224

23-
color_bitmap = displayio.Bitmap(128, 160, 1)
25+
color_bitmap = displayio.Bitmap(160, 128, 1)
2426
color_palette = displayio.Palette(1)
25-
color_palette[0] = 0xFF0000
27+
color_palette[0] = 0x00FF00 # Bright Green
2628

2729
bg_sprite = displayio.TileGrid(color_bitmap,
2830
pixel_shader=color_palette,
2931
x=0, y=0)
3032
splash.append(bg_sprite)
3133

34+
# Draw a smaller inner rectangle
35+
inner_bitmap = displayio.Bitmap(150, 118, 1)
36+
inner_palette = displayio.Palette(1)
37+
inner_palette[0] = 0xAA0088 # Purple
38+
inner_sprite = displayio.TileGrid(inner_bitmap,
39+
pixel_shader=inner_palette,
40+
x=5, y=5)
41+
splash.append(inner_sprite)
42+
43+
# Draw a label
44+
text_group = displayio.Group(max_size=10, scale=2, x=11, y=64)
45+
text = "Hello World!"
46+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
47+
text_group.append(text_area) # Subgroup for text scaling
48+
splash.append(text_group)
49+
3250
while True:
3351
pass

examples/st7735r_minitft_featherwing_simpletest.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
"""
2-
This example will test out the display on the Mini TFT FeatherWing
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
34
"""
5+
46
import board
57
import displayio
8+
import terminalio
9+
from adafruit_display_text import label
610
from adafruit_seesaw.seesaw import Seesaw
711
from adafruit_st7735r import ST7735R
812

@@ -27,12 +31,28 @@
2731

2832
color_bitmap = displayio.Bitmap(160, 80, 1)
2933
color_palette = displayio.Palette(1)
30-
color_palette[0] = 0xFF0000
34+
color_palette[0] = 0x00FF00 # Bright Green
3135

3236
bg_sprite = displayio.TileGrid(color_bitmap,
3337
pixel_shader=color_palette,
3438
x=0, y=0)
3539
splash.append(bg_sprite)
3640

41+
# Draw a smaller inner rectangle
42+
inner_bitmap = displayio.Bitmap(150, 70, 1)
43+
inner_palette = displayio.Palette(1)
44+
inner_palette[0] = 0xAA0088 # Purple
45+
inner_sprite = displayio.TileGrid(inner_bitmap,
46+
pixel_shader=inner_palette,
47+
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+
3757
while True:
3858
pass
+23-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
"""
2-
This example will test out the display on the Mini TFT Breakout
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
34
"""
5+
46
import board
57
import displayio
8+
import terminalio
9+
from adafruit_display_text import label
610
from adafruit_st7735r import ST7735R
711

812
spi = board.SPI()
@@ -12,20 +16,36 @@
1216
displayio.release_displays()
1317
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
1418

15-
display = ST7735R(display_bus, width=160, height=80, colstart=24, rotation=90, bgr=True)
19+
display = ST7735R(display_bus, width=160, height=80, colstart=24, rotation=270, bgr=True)
1620

1721
# Make the display context
1822
splash = displayio.Group(max_size=10)
1923
display.show(splash)
2024

2125
color_bitmap = displayio.Bitmap(160, 80, 1)
2226
color_palette = displayio.Palette(1)
23-
color_palette[0] = 0xFF0000
27+
color_palette[0] = 0x00FF00 # Bright Green
2428

2529
bg_sprite = displayio.TileGrid(color_bitmap,
2630
pixel_shader=color_palette,
2731
x=0, y=0)
2832
splash.append(bg_sprite)
2933

34+
# Draw a smaller inner rectangle
35+
inner_bitmap = displayio.Bitmap(150, 70, 1)
36+
inner_palette = displayio.Palette(1)
37+
inner_palette[0] = 0xAA0088 # Purple
38+
inner_sprite = displayio.TileGrid(inner_bitmap,
39+
pixel_shader=inner_palette,
40+
x=5, y=5)
41+
splash.append(inner_sprite)
42+
43+
# Draw a label
44+
text_group = displayio.Group(max_size=10, scale=2, x=11, y=40)
45+
text = "Hello World!"
46+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
47+
text_group.append(text_area) # Subgroup for text scaling
48+
splash.append(text_group)
49+
3050
while True:
3151
pass

examples/st7735r_simpletest.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""
2-
This test will initialize the display using displayio
3-
and draw a solid red background
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
44
"""
55

66
import board
77
import displayio
8+
import terminalio
9+
from adafruit_display_text import label
810
from adafruit_st7735r import ST7735R
911

1012
spi = board.SPI()
@@ -22,12 +24,26 @@
2224

2325
color_bitmap = displayio.Bitmap(128, 128, 1)
2426
color_palette = displayio.Palette(1)
25-
color_palette[0] = 0xFF0000
27+
color_palette[0] = 0x00FF00 # Bright Green
2628

2729
bg_sprite = displayio.TileGrid(color_bitmap,
2830
pixel_shader=color_palette,
2931
x=0, y=0)
3032
splash.append(bg_sprite)
3133

34+
# Draw a smaller inner rectangle
35+
inner_bitmap = displayio.Bitmap(108, 108, 1)
36+
inner_palette = displayio.Palette(1)
37+
inner_palette[0] = 0xAA0088 # Purple
38+
inner_sprite = displayio.TileGrid(inner_bitmap,
39+
pixel_shader=inner_palette,
40+
x=10, y=10)
41+
splash.append(inner_sprite)
42+
43+
# Draw a label
44+
text = "Hello World!"
45+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=30, y=64)
46+
splash.append(text_area)
47+
3248
while True:
3349
pass

0 commit comments

Comments
 (0)