Skip to content

Commit 404f4e3

Browse files
Melissa LeBlanc-WilliamsMelissa LeBlanc-Williams
Melissa LeBlanc-Williams
authored and
Melissa LeBlanc-Williams
committed
Added simpletest
1 parent f90bf2f commit 404f4e3

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

docs/examples.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Simple test
33

44
Ensure your device works with this simple test.
55

6+
.. literalinclude:: ../examples/rgbdisplay_simpletest.py
7+
:caption: examples/rgbdisplay_simpletest.py
8+
:linenos:
9+
610
.. literalinclude:: ../examples/rgbdisplay_ili9341test.py
711
:caption: examples/rgbdisplay_ili9341test.py
812
:linenos:

examples/rgbdisplay_simpletest.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Quick test of TFT FeatherWing (ST7789) with Feather M0 or M4
2+
# This will work even on a device running displayio
3+
# Will fill the TFT black and put a red pixel in the center, wait 2 seconds,
4+
# then fill the screen blue (with no pixel), wait 2 seconds, and repeat.
5+
import time
6+
import random
7+
import digitalio
8+
import board
9+
import displayio
10+
11+
from adafruit_rgb_display.rgb import color565
12+
import adafruit_rgb_display.st7789 as st7789
13+
14+
displayio.release_displays()
15+
16+
# Configuratoin for CS and DC pins (these are FeatherWing defaults on M0/M4):
17+
cs_pin = digitalio.DigitalInOut(board.D5)
18+
dc_pin = digitalio.DigitalInOut(board.D6)
19+
reset_pin = digitalio.DigitalInOut(board.D9)
20+
21+
# Config for display baudrate (default max is 24mhz):
22+
BAUDRATE = 24000000
23+
24+
# Setup SPI bus using hardware SPI:
25+
spi = board.SPI()
26+
27+
# Create the ST7789 display:
28+
display = st7789.ST7789(spi, cs=cs_pin, dc=dc_pin, rst=reset_pin, baudrate=BAUDRATE)
29+
30+
# Main loop:
31+
while True:
32+
# Fill the screen red, green, blue, then black:
33+
for color in ((255, 0, 0), (0, 255, 0), (0, 0, 255)):
34+
display.fill(color565(color))
35+
# Clear the display
36+
display.fill(0)
37+
# Draw a red pixel in the center.
38+
display.pixel(display.width//2, display.height//2, color565(255, 0, 0))
39+
# Pause 2 seconds.
40+
time.sleep(2)
41+
# Clear the screen a random color
42+
display.fill(color565(random.randint(0, 255),
43+
random.randint(0, 255),
44+
random.randint(0, 255)))
45+
# Pause 2 seconds.
46+
time.sleep(2)

0 commit comments

Comments
 (0)