Skip to content

Commit a3494aa

Browse files
authored
Merge pull request #907 from adafruit/TheKitty-patch-109
Add code and graphics files for the guide
2 parents d64b0fd + 846c250 commit a3494aa

File tree

6 files changed

+384
-0
lines changed

6 files changed

+384
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
"""
2+
Simple badge script for Adafruit 2.13" 212x104 tri-color display
3+
Supported products:
4+
* Adafruit 2.13" Tri-Color Display Breakout
5+
* https://www.adafruit.com/product/4086 (breakout) or
6+
* https://www.adafruit.com/product/4128 (FeatherWing)
7+
8+
This program requires the adafruit_il0373 library and the
9+
adafruit_display_text library in the CIRCUITPY /lib folder
10+
for CircuitPython 5.0 and above which has displayio support.
11+
"""
12+
13+
import time
14+
import board
15+
import displayio
16+
import adafruit_il0373
17+
import terminalio
18+
from adafruit_display_text import label
19+
20+
BLACK = 0x000000
21+
WHITE = 0xFFFFFF
22+
RED = 0xFF0000
23+
24+
# Change text colors, choose from the following values:
25+
# BLACK, RED, WHITE
26+
27+
TEXT_COLOR = BLACK
28+
BACKGROUND_COLOR = WHITE
29+
30+
# Used to ensure the display is free in CircuitPython
31+
displayio.release_displays()
32+
33+
# Define the pins needed for display use
34+
# This pinout is for a Feather M4 and may be different for other boards
35+
spi = board.SPI() # Uses SCK and MOSI
36+
epd_cs = board.D9
37+
epd_dc = board.D10
38+
epd_reset = board.D5
39+
epd_busy = board.D6
40+
41+
# Create the displayio connection to the display pins
42+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs,
43+
reset=epd_reset, baudrate=1000000)
44+
time.sleep(1) # Wait a bit
45+
46+
DISPLAY_WIDTH = 212
47+
DISPLAY_HEIGHT = 104
48+
# Create the display object - the third color is red (0xff0000)
49+
display = adafruit_il0373.IL0373(display_bus, width=DISPLAY_WIDTH,
50+
height=DISPLAY_HEIGHT,
51+
rotation=90, busy_pin=epd_busy,
52+
highlight_color=0xff0000)
53+
54+
# Create a display group for our screen objects
55+
g = displayio.Group()
56+
57+
# Set a background
58+
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
59+
# Map colors in a palette
60+
palette = displayio.Palette(1)
61+
palette[0] = BACKGROUND_COLOR
62+
63+
# Put the background into the display group
64+
bg_sprite = displayio.TileGrid(background_bitmap,
65+
pixel_shader=palette,
66+
x=0, y=0)
67+
g.append(bg_sprite)
68+
69+
# Display a picture from the root directory of the CIRCUITPY drive
70+
# Picture should be HEIGHTxHEIGHT square idealy for a portrait
71+
# But could be the entire WIDTHxHEIGHT for a non-portrait
72+
f = open("/picture.bmp", "rb")
73+
74+
pic = displayio.OnDiskBitmap(f)
75+
# Create a Tilegrid with the bitmap and put in the displayio group
76+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
77+
g.append(t)
78+
79+
# Draw simple text using the built-in font into a displayio group
80+
# For smaller text, change scale=2 to scale=1
81+
text_group = displayio.Group(max_size=10, scale=2,
82+
x=DISPLAY_HEIGHT + 10,
83+
y=int(DISPLAY_HEIGHT/2) - 13)
84+
first_name = "Limor"
85+
text_area = label.Label(terminalio.FONT, text=first_name,
86+
color=TEXT_COLOR)
87+
text_group.append(text_area) # Add this text to the text group
88+
g.append(text_group)
89+
90+
# Draw simple text using the built-in font into a displayio group
91+
text_group = displayio.Group(max_size=10, scale=2,
92+
x=DISPLAY_HEIGHT + 10,
93+
y=int(DISPLAY_HEIGHT/2) + 13)
94+
last_name = "Ladyada"
95+
text_area = label.Label(terminalio.FONT, text=last_name,
96+
color=TEXT_COLOR)
97+
text_group.append(text_area) # Add this text to the text group
98+
g.append(text_group)
99+
100+
# Place the display group on the screen
101+
display.show(g)
102+
103+
# Refresh the display to have it actually show
104+
# NOTE: Do not refresh eInk displays more often than 180 seconds!
105+
display.refresh()
106+
107+
# Wait the minimum 3 minutes between refreshes. Then loop to freeze.
108+
time.sleep(180)
109+
while True:
110+
pass
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"""
2+
Simple text script for Adafruit 2.13" 212x104 tri-color display
3+
Supported products:
4+
* Adafruit 2.13" Tri-Color Display Breakout
5+
* Adafruit 2.13" Tri-Color Display FeatherWing
6+
https://www.adafruit.com/product/4086 (breakout) or
7+
https://www.adafruit.com/product/4128 (FeatherWing)
8+
9+
This program requires the adafruit_il0373 library and the
10+
adafruit_display_text library in the CIRCUITPY /lib folder
11+
for CircuitPython 5.0 and above which has displayio support.
12+
"""
13+
14+
import time
15+
import board
16+
import displayio
17+
import adafruit_il0373
18+
import terminalio
19+
from adafruit_display_text import label
20+
21+
BLACK = 0x000000
22+
WHITE = 0xFFFFFF
23+
RED = 0xFF0000
24+
25+
# Change text colors, choose from the following values:
26+
# BLACK, RED, WHITE
27+
28+
FOREGROUND_COLOR = RED
29+
BACKGROUND_COLOR = WHITE
30+
31+
# Used to ensure the display is free in CircuitPython
32+
displayio.release_displays()
33+
34+
# Define the pins needed for display use
35+
# This pinout is for a Feather M4 and may be different for other boards
36+
spi = board.SPI() # Uses SCK and MOSI
37+
epd_cs = board.D9
38+
epd_dc = board.D10
39+
epd_reset = board.D5
40+
epd_busy = board.D6
41+
42+
# Create the displayio connection to the display pins
43+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs,
44+
reset=epd_reset, baudrate=1000000)
45+
time.sleep(1) # Wait a bit
46+
47+
# Create the display object - the third color is red (0xff0000)
48+
DISPLAY_WIDTH = 212
49+
DISPLAY_HEIGHT = 104
50+
51+
display = adafruit_il0373.IL0373(display_bus, width=DISPLAY_WIDTH,
52+
height=DISPLAY_HEIGHT,
53+
rotation=90, busy_pin=epd_busy,
54+
highlight_color=0xff0000)
55+
56+
# Create a display group for our screen objects
57+
g = displayio.Group(max_size=10)
58+
59+
# Set a background
60+
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
61+
# Map colors in a palette
62+
palette = displayio.Palette(1)
63+
palette[0] = BACKGROUND_COLOR
64+
65+
# Create a Tilegrid with the background and put in the displayio group
66+
t = displayio.TileGrid(background_bitmap, pixel_shader=palette)
67+
g.append(t)
68+
69+
# Draw simple text using the built-in font into a displayio group
70+
text_group = displayio.Group(max_size=10, scale=2, x=20, y=40)
71+
text = "Hello World!"
72+
text_area = label.Label(terminalio.FONT, text=text, color=FOREGROUND_COLOR)
73+
text_group.append(text_area) # Add this text to the text group
74+
g.append(text_group)
75+
76+
# Place the display group on the screen
77+
display.show(g)
78+
79+
# Refresh the display to have everything show on the display
80+
# NOTE: Do not refresh eInk displays more often than 180 seconds!
81+
display.refresh()
82+
83+
time.sleep(120)
84+
85+
while True:
86+
pass
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
"""
2+
Simple Badge script for a 2.7" 264x176 Tri-Color eInk display shield
3+
Supported products:
4+
* Adafruit 2.7" Tri-Color ePaper Display Shield
5+
https://www.adafruit.com/product/4229
6+
7+
This program requires the adafruit_il91874 and the
8+
adafruit_display_text library in /lib on the CIRCUITPY drive
9+
for CircuitPython 5.0 and above which has displayio support.
10+
"""
11+
12+
import time
13+
import board
14+
import displayio
15+
import adafruit_il91874
16+
import terminalio
17+
from adafruit_display_text import label
18+
19+
BLACK = 0x000000
20+
WHITE = 0xFFFFFF
21+
RED = 0xFF0000
22+
23+
# Change text colors, choose from the following values:
24+
# BLACK, RED, WHITE
25+
26+
TEXT_COLOR = BLACK
27+
BACKGROUND_COLOR = WHITE
28+
29+
# Used to ensure the display is free in CircuitPython
30+
displayio.release_displays()
31+
32+
# Define the pins needed for display use on the Metro
33+
spi = board.SPI()
34+
epd_cs = board.D10
35+
epd_dc = board.D9
36+
37+
# Create the displayio connection to the display pins
38+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs,
39+
baudrate=1000000)
40+
time.sleep(1) # Wait a bit
41+
42+
DISPLAY_WIDTH = 264
43+
DISPLAY_HEIGHT = 176
44+
# Create the display object - the third color is red (0xff0000)
45+
display = adafruit_il91874.IL91874(display_bus, width=DISPLAY_WIDTH,
46+
height=DISPLAY_HEIGHT,
47+
highlight_color=0xff0000, rotation=90)
48+
49+
# Create a display group for our screen objects
50+
g = displayio.Group(max_size=10)
51+
52+
# Set a background
53+
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
54+
# Map colors in a palette
55+
palette = displayio.Palette(1)
56+
palette[0] = BACKGROUND_COLOR
57+
58+
# Put the background into the display group
59+
bg_sprite = displayio.TileGrid(background_bitmap,
60+
pixel_shader=palette,
61+
x=0, y=0)
62+
63+
g.append(bg_sprite)
64+
65+
# Display a picture from the root directory of the CIRCUITPY drive
66+
# Picture should be HEIGHTxHEIGHT square idealy for a portrait
67+
# But could be the entire WIDTHxHEIGHT for a non-portrait
68+
f = open("/picture.bmp", "rb")
69+
70+
pic = displayio.OnDiskBitmap(f)
71+
# Create a Tilegrid with the bitmap and put in the displayio group
72+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
73+
g.append(t)
74+
75+
# Draw simple text using the built-in font into a displayio group
76+
# For smaller text, change scale=2 to scale=1 as scale 2 doesn't
77+
# allow for much text but the text is bigger.
78+
text_group = displayio.Group(max_size=10, scale=2,
79+
x=DISPLAY_HEIGHT + 5,
80+
y=int(DISPLAY_HEIGHT/2) - 13)
81+
first_name = "Limor"
82+
text_area = label.Label(terminalio.FONT, text=first_name,
83+
color=TEXT_COLOR)
84+
text_group.append(text_area) # Add this text to the text group
85+
g.append(text_group)
86+
87+
# Draw simple text using the built-in font into a displayio group
88+
# For smaller text, change scale=2 to scale=1 as scale 2 doesn't
89+
# allow for much text but the text is bigger.
90+
text_group = displayio.Group(max_size=10, scale=2,
91+
x=DISPLAY_HEIGHT + 5,
92+
y=int(DISPLAY_HEIGHT/2) + 13)
93+
last_name = "Fried"
94+
text_area = label.Label(terminalio.FONT, text=last_name,
95+
color=TEXT_COLOR)
96+
text_group.append(text_area) # Add this text to the text group
97+
g.append(text_group)
98+
99+
# Place the display group on the screen
100+
display.show(g)
101+
102+
# Refresh the display to have it actually show
103+
# NOTE: Do not refresh eInk displays more often than 180 seconds!
104+
display.refresh()
105+
106+
# Wait the minimum 3 minutes between refreshes. Then loop to freeze.
107+
time.sleep(180)
108+
while True:
109+
pass
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""
2+
Simple text script for 2.7" 264x176 Tri-Color display shield
3+
Supported products:
4+
* Adafruit 2.7" Tri-Color ePaper Display Shield
5+
https://www.adafruit.com/product/4229
6+
This program requires the adafruit_il91874 and the
7+
adafruit_display_text library in /lib on the CIRCUITPY drive
8+
for CircuitPython 5.0 and above which has displayio support.
9+
"""
10+
11+
import time
12+
import board
13+
import displayio
14+
import adafruit_il91874
15+
import terminalio
16+
from adafruit_display_text import label
17+
18+
BLACK = 0x000000
19+
WHITE = 0xFFFFFF
20+
RED = 0xFF0000
21+
22+
# Change text colors, choose from the following values:
23+
# BLACK, WHITE, RED (note red on this display is not vivid)
24+
25+
FOREGROUND_COLOR = BLACK
26+
BACKGROUND_COLOR = WHITE
27+
28+
# Used to ensure the display is free in CircuitPython
29+
displayio.release_displays()
30+
31+
# Define the pins needed for display use on the Metro
32+
spi = board.SPI()
33+
epd_cs = board.D10
34+
epd_dc = board.D9
35+
36+
# Create the displayio connection to the display pins
37+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs,
38+
baudrate=1000000)
39+
time.sleep(1) # Wait a bit
40+
41+
# Create the display object - the third color is red (0xff0000)
42+
DISPLAY_WIDTH = 264
43+
DISPLAY_HEIGHT = 176
44+
45+
# Create the display object - the third color is red (0xff0000)
46+
display = adafruit_il91874.IL91874(display_bus, width=DISPLAY_WIDTH,
47+
height=DISPLAY_HEIGHT,
48+
highlight_color=0xff0000, rotation=90)
49+
50+
# Create a display group for our screen objects
51+
g = displayio.Group(max_size=10)
52+
53+
# Set a white background
54+
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
55+
# Map colors in a palette
56+
palette = displayio.Palette(1)
57+
palette[0] = BACKGROUND_COLOR
58+
59+
# Create a Tilegrid with the background and put in the displayio group
60+
t = displayio.TileGrid(background_bitmap, pixel_shader=palette)
61+
g.append(t)
62+
63+
# Draw simple text using the built-in font into a displayio group
64+
text_group = displayio.Group(max_size=10, scale=2, x=40, y=40)
65+
text = "Hello World!"
66+
text_area = label.Label(terminalio.FONT, text=text, color=FOREGROUND_COLOR)
67+
text_group.append(text_area) # Add this text to the text group
68+
g.append(text_group)
69+
70+
# Place the display group on the screen
71+
display.show(g)
72+
73+
# Refresh the display to have everything show on the display
74+
# NOTE: Do not refresh eInk displays more often than 180 seconds!
75+
display.refresh()
76+
77+
time.sleep(180)
78+
while True:
79+
pass
31.7 KB
Binary file not shown.
90.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)