Skip to content

Commit 9ec7507

Browse files
authored
Merge pull request #3 from makermelissa/master
Updated Simpletest, changed pins on Gamma Example for Feather
2 parents 3953dfd + 0382d0d commit 9ec7507

File tree

2 files changed

+62
-18
lines changed

2 files changed

+62
-18
lines changed

examples/ssd1325_gamma.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import time
22
import board
3-
import busio
43
import displayio
54
import adafruit_ssd1325
65

76
displayio.release_displays()
87

9-
# This pinout works on a Metro and may need to be altered for other boards.
10-
spi = busio.SPI(board.SCL, board.SDA)
11-
tft_cs = board.D9
12-
tft_dc = board.D8
13-
tft_reset = board.D7
8+
spi = board.SPI()
9+
oled_cs = board.D5
10+
oled_dc = board.D6
11+
oled_reset = board.D9
1412

15-
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset,
13+
display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs, reset=oled_reset,
1614
baudrate=1000000)
1715
time.sleep(1)
1816
display = adafruit_ssd1325.SSD1325(display_bus, width=128, height=64)

examples/ssd1325_simpletest.py

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,64 @@
1-
import time
1+
"""
2+
This test will initialize the display using displayio and draw a solid white
3+
background, a smaller black rectangle, and some white text.
4+
"""
5+
26
import board
3-
import busio
47
import displayio
8+
import terminalio
9+
from adafruit_display_text import label
510
import adafruit_ssd1325
611

712
displayio.release_displays()
813

9-
# This pinout works on a Metro and may need to be altered for other boards.
10-
spi = busio.SPI(board.SCL, board.SDA)
11-
tft_cs = board.D9
12-
tft_dc = board.D8
13-
tft_reset = board.D7
14+
# Use for SPI
15+
spi = board.SPI()
16+
oled_cs = board.D5
17+
oled_dc = board.D6
18+
display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
19+
baudrate=1000000, reset=board.D9)
20+
21+
# Use for I2C
22+
# i2c = board.I2C()
23+
# display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
24+
25+
WIDTH = 128
26+
HEIGHT = 64
27+
BORDER = 8
28+
FONTSCALE = 1
29+
30+
display = adafruit_ssd1325.SSD1325(display_bus, width=WIDTH, height=HEIGHT)
31+
32+
# Make the display context
33+
splash = displayio.Group(max_size=10)
34+
display.show(splash)
35+
36+
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
37+
color_palette = displayio.Palette(1)
38+
color_palette[0] = 0x888888 # White
39+
40+
bg_sprite = displayio.TileGrid(color_bitmap,
41+
pixel_shader=color_palette,
42+
x=0, y=0)
43+
splash.append(bg_sprite)
44+
45+
# Draw a smaller inner rectangle
46+
inner_bitmap = displayio.Bitmap(display.width - BORDER * 2, display.height - BORDER * 2, 1)
47+
inner_palette = displayio.Palette(1)
48+
inner_palette[0] = 0x000000 # Black
49+
inner_sprite = displayio.TileGrid(inner_bitmap,
50+
pixel_shader=inner_palette,
51+
x=BORDER, y=BORDER)
52+
splash.append(inner_sprite)
53+
54+
# Draw a label
55+
text = "Hello World!"
56+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF)
57+
text_width = text_area.bounding_box[2] * FONTSCALE
58+
text_group = displayio.Group(max_size=10, scale=FONTSCALE, x=display.width // 2 - text_width // 2,
59+
y=display.height // 2)
60+
text_group.append(text_area) # Subgroup for text scaling
61+
splash.append(text_group)
1462

15-
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset,
16-
baudrate=1000000)
17-
time.sleep(1)
18-
display = adafruit_ssd1325.SSD1325(display_bus, width=128, height=64)
63+
while True:
64+
pass

0 commit comments

Comments
 (0)