Skip to content

Commit 4d2a1bc

Browse files
committed
lil painting demo
1 parent ceb1397 commit 4d2a1bc

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

examples/simple_paint.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Simple painting demo
2+
3+
import time
4+
import busio
5+
import board
6+
import digitalio
7+
from ft62xx import adafruit_ft62xx
8+
9+
# Create library object using our Bus I2C & SPI port
10+
i2c = busio.I2C(board.SCL, board.SDA)
11+
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
12+
13+
# Adafruit Metro M0 + 2.8" Capacitive touch shield
14+
cs_pin = digitalio.DigitalInOut(board.D10)
15+
dc_pin = digitalio.DigitalInOut(board.D9)
16+
17+
# Initialize display
18+
from adafruit_rgb_display import ili9341, color565
19+
display = ili9341.ILI9341(spi, cs=cs_pin, dc=dc_pin)
20+
# Fill with black!
21+
display.fill(color565(0, 0, 0))
22+
23+
ft = adafruit_ft62xx.Adafruit_FT6206(i2c)
24+
25+
while True:
26+
if ft.touched:
27+
ts = ft.touches
28+
point = ts[0] # the shield only supports one point!
29+
# perform transformation to get into display coordinate system!
30+
y = 320 - point['y']
31+
x = 240 - point['x']
32+
display.fill_rectangle(x-2, y-2, 4, 4, color565(255, 255, 255))

0 commit comments

Comments
 (0)