Skip to content

Commit 3493bc3

Browse files
committed
add usage example
1 parent 3d79b5a commit 3493bc3

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.rst

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,42 @@ This is easily achieved by downloading
3434
Usage Example
3535
=============
3636

37-
TODO
37+
```
38+
import busio
39+
import digitalio
40+
from board import SCK, MOSI, MISO, GPIO0, GPIO15
41+
42+
from adafruit_rgb_display import color565
43+
import adafruit_rgb_display.ili9341 as ili9341
44+
45+
46+
# Configuratoin for CS and DC pins (these are FeatherWing defaults on ESP8266):
47+
CS_PIN = GPIO0
48+
DC_PIN = GPIO15
49+
# Config for display baudrate (default is 32mhz, about as fast as the ESP supports):
50+
BAUDRATE = 32000000
51+
52+
53+
# Setup SPI bus using hardware SPI:
54+
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)
55+
56+
# Create the ILI9341 display:
57+
display = ili9341.ILI9341(spi, cs=digitalio.DigitalInOut(CS_PIN),
58+
dc=digitalio.DigitalInOut(DC_PIN), baudrate=BAUDRATE)
59+
60+
# Main loop:
61+
while True:
62+
# Clear the display
63+
display.fill(0)
64+
# Draw a red pixel in the center.
65+
display.pixel(120, 160, color565(255, 0, 0))
66+
# Pause 2 seconds.
67+
time.sleep(2)
68+
# Clear the screen blue.
69+
display.fill(color565(0, 0, 255))
70+
# Pause 2 seconds.
71+
time.sleep(2)
72+
```
3873

3974
API Reference
4075
=============

0 commit comments

Comments
 (0)