Skip to content

Commit 099db3b

Browse files
committed
update for feather m0/m4
1 parent 6d45d98 commit 099db3b

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

examples/esp8266_tft_featherwing.py

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1-
# Quick test of TFT FeatherWing (ILI9341) with ESP8266 Adafruit MicroPython.
1+
# Quick test of TFT FeatherWing (ILI9341) with Feather M0 or M4
22
# Will fill the TFT black and put a red pixel in the center, wait 2 seconds,
33
# then fill the screen blue (with no pixel), wait 2 seconds, and repeat.
44
import time
5-
5+
import random
66
import busio
77
import digitalio
8-
from board import SCK, MOSI, MISO, GPIO0, GPIO15
8+
import board
99

10-
from adafruit_rgb_display import color565
10+
from adafruit_rgb_display.rgb import color565
1111
import adafruit_rgb_display.ili9341 as ili9341
1212

1313

14-
# Configuratoin for CS and DC pins (these are FeatherWing defaults on ESP8266):
15-
CS_PIN = GPIO0
16-
DC_PIN = GPIO15
17-
# Config for display baudrate (default is 32mhz, about as fast as the ESP supports):
18-
BAUDRATE = 32000000
14+
# Configuratoin for CS and DC pins (these are FeatherWing defaults on M0/M4):
15+
cs_pin = digitalio.DigitalInOut(board.D9)
16+
dc_pin = digitalio.DigitalInOut(board.D10)
1917

18+
# Config for display baudrate (default max is 24mhz):
19+
BAUDRATE = 24000000
2020

2121
# Setup SPI bus using hardware SPI:
22-
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)
22+
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
2323

2424
# Create the ILI9341 display:
25-
display = ili9341.ILI9341(spi, cs=digitalio.DigitalInOut(CS_PIN),
26-
dc=digitalio.DigitalInOut(DC_PIN), baudrate=BAUDRATE)
25+
display = ili9341.ILI9341(spi, cs=cs_pin, dc=dc_pin, baudrate=BAUDRATE)
2726

2827
# Main loop:
2928
while True:
29+
# Fill the screen red, green, blue, then black:
30+
for color in ((255, 0, 0), (0, 255, 0), (0, 0, 255)):
31+
display.fill(color565(color))
3032
# Clear the display
3133
display.fill(0)
3234
# Draw a red pixel in the center.
33-
display.pixel(120, 160, color565(255, 0, 0))
35+
display.pixel(display.width//2, display.height//2, color565(255, 0, 0))
3436
# Pause 2 seconds.
3537
time.sleep(2)
36-
# Clear the screen blue.
37-
display.fill(color565(0, 0, 255))
38+
# Clear the screen a random color
39+
display.fill(color565(random.randint(0, 255),
40+
random.randint(0, 255),
41+
random.randint(0, 255)))
3842
# Pause 2 seconds.
3943
time.sleep(2)

0 commit comments

Comments
 (0)