Example: 50-Arduino-Boards/Giga-H7/51-Display/display.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# LCD、触摸屏和摄像头示例。

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)  # 将像素格式设置为RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.VGA)  # 将帧大小设置为QVGA (320x240)

lcd = display.DSIDisplay(
    framesize=display.FWVGA, portrait=True, refresh=60, controller=display.ST7701()
)

# 注意使用引脚编号或名称而不是 Pin 对象,因为
# 驱动程序需要更改引脚方向以重置控制器。
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),
)

# 创建一个时钟对象来跟踪FPS。
clock = time.clock()

while True:
    clock.tick()  # 更新FPS时钟。

    # 捕获新帧
    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())

results matching ""

    No results matching ""