Example: 50-Arduino-Boards/Giga-H7/51-Display/display.py
import sensor
import time
import image
import display
from gt911 import GT911
from machine import I2C
IMG_OFFSET = 80
touch_detected = False
points_colors = ((255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 255, 0))
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
lcd = display.DSIDisplay(
framesize=display.FWVGA, portrait=True, refresh=60, controller=display.ST7701()
)
touch = GT911(
I2C(4, freq=400_000),
reset_pin="PI2",
irq_pin="PI1",
touch_points=5,
refresh_rate=240,
reverse_x=True,
touch_callback=lambda pin: globals().update(touch_detected=True),
)
clock = time.clock()
while True:
clock.tick()
img = sensor.snapshot()
if touch_detected:
n, points = touch.read_points()
for i in range(0, n):
img.draw_circle(
points[i][0] - IMG_OFFSET,
points[i][1],
points[i][2] * 3,
points_colors[points[i][3]],
thickness=2,
)
touch_detected = False
lcd.write(img, y=IMG_OFFSET, hint=image.TRANSPOSE | image.VFLIP)
print(clock.fps())