Skip to content

Commit 2817abd

Browse files
Merge pull request #4 from FoamyGuy/more_examples
additional examples
2 parents dba73bf + 5fdad0c commit 2817abd

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

docs/examples.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,22 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/spd1656_simpletest.py
77
:caption: examples/spd1656_simpletest.py
88
:linenos:
9+
10+
Stripes test
11+
------------
12+
13+
Show stripes with each of the colors that can be displayed
14+
15+
.. literalinclude:: ../examples/spd1656_color_stripes.py
16+
:caption: examples/spd1656_color_stripes.py
17+
:linenos:
18+
19+
Colors and Text Example
20+
-----------------------
21+
22+
Display a filled colored rectangle with a different
23+
border color and test layered on top in the center.
24+
25+
.. literalinclude:: ../examples/spd1656_colors_and_text.py
26+
:caption: examples/spd1656_colors_and_text.py
27+
:linenos:

examples/spd1656_color_stripes.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2023 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
"""Stripes test script for 5.6" 600x448 7-color ACeP display.
6+
Fill the screen with striped rows, one for each possible color.
7+
"""
8+
# pylint: disable=no-member
9+
10+
import board
11+
import displayio
12+
import bitmaptools
13+
import adafruit_spd1656
14+
15+
displayio.release_displays()
16+
17+
# This pinout works on a Feather RP2040 and may need to be altered for other boards.
18+
spi = board.SPI() # Uses SCK and MOSI
19+
epd_cs = board.D9
20+
epd_dc = board.D10
21+
epd_reset = board.D11
22+
epd_busy = board.D12
23+
24+
display_bus = displayio.FourWire(
25+
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
26+
)
27+
28+
display = adafruit_spd1656.SPD1656(
29+
display_bus, width=600, height=448, busy_pin=epd_busy
30+
)
31+
32+
g = displayio.Group()
33+
34+
bmp = displayio.Bitmap(display.width, display.height, 7)
35+
p = displayio.Palette(7)
36+
p[0] = 0xFFFFFF
37+
p[1] = 0x000000
38+
p[2] = 0x0000FF
39+
p[3] = 0x00FF00
40+
p[4] = 0xFF0000
41+
p[5] = 0xFFFF00
42+
p[6] = 0xFFA500
43+
44+
bmp.fill(0)
45+
46+
for i in range(7):
47+
bitmaptools.fill_region(
48+
bmp,
49+
0,
50+
i * (display.height // 7),
51+
display.width,
52+
i * (display.height // 7) + (display.height // 7),
53+
i,
54+
)
55+
56+
tg = displayio.TileGrid(bitmap=bmp, pixel_shader=p)
57+
g.append(tg)
58+
59+
display.show(g)
60+
61+
display.refresh()
62+
63+
while True:
64+
pass

examples/spd1656_colors_and_text.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2023 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
"""Colors and Text script for 5.6" 600x448 7-color ACeP display.
6+
Draw a border and screen filled with color and layer text on top
7+
of it.
8+
"""
9+
# pylint: disable=no-member
10+
11+
import board
12+
import displayio
13+
import terminalio
14+
import bitmaptools
15+
from adafruit_display_text.bitmap_label import Label
16+
import adafruit_spd1656
17+
18+
displayio.release_displays()
19+
20+
# This pinout works on a Feather RP2040 and may need to be altered for other boards.
21+
spi = board.SPI() # Uses SCK and MOSI
22+
epd_cs = board.D9
23+
epd_dc = board.D10
24+
epd_reset = board.D11
25+
epd_busy = board.D12
26+
27+
display_bus = displayio.FourWire(
28+
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
29+
)
30+
31+
display = adafruit_spd1656.SPD1656(
32+
display_bus, width=600, height=448, busy_pin=epd_busy
33+
)
34+
35+
g = displayio.Group()
36+
37+
bmp = displayio.Bitmap(display.width, display.height, 7)
38+
p = displayio.Palette(7)
39+
p[0] = 0xFFFFFF
40+
p[1] = 0x000000
41+
p[2] = 0x0000FF
42+
p[3] = 0x00FF00
43+
p[4] = 0xFF0000
44+
p[5] = 0xFFFF00
45+
p[6] = 0xFFA500
46+
47+
bmp.fill(2)
48+
49+
bitmaptools.fill_region(bmp, 40, 40, display.width - 40, display.height - 40, 3)
50+
tg = displayio.TileGrid(bitmap=bmp, pixel_shader=p)
51+
g.append(tg)
52+
53+
lbl = Label(terminalio.FONT, text="Hello World", color=0xFFFFFF, scale=3)
54+
lbl.anchor_point = (0.5, 0.5)
55+
lbl.anchored_position = (display.width // 2, display.height // 2)
56+
g.append(lbl)
57+
58+
display.show(g)
59+
display.refresh()
60+
61+
while True:
62+
pass

0 commit comments

Comments
 (0)