1.1 KiB
1.1 KiB
#领域/MaixCam
{{date}}-原子化笔记-主题名-文件内容
模板变更
- 20260105(
v1.0.1):增加一句话描述和分割线 - 20251230(
v1.0.0):模板创建
注释:1-3 句话的核心逻辑 + 代码片段
一句话描述
[这是一个原子化笔记文件的模板____]
核心定义
触摸屏支持分辨率为 552 x 368 分辨率,菜单控件的更新操作和屏幕显示之间不建议插入其他代码,以免菜单显示错位
最小实现代码
from maix import touchscreen
ts = touchscreen.TouchScreen()
x, y, pressed = ts.read()
样例程序
from maix import touchscreen, app, time, display, image
ts = touchscreen.TouchScreen()
disp = display.Display()
img = image.Image(disp.width(), disp.height())
def menu_update(img):
img.draw_string(8, 12, "< Exit", image.COLOR_WHITE)
img.draw_rect(0, 0, 100, 100, image.COLOR_WHITE, 2)
while not app.need_exit():
x, y, pressed = ts.read()
if x > 0 and x < 100 and y > 0 and y < 100:
app.set_exit_flag(True)
menu_update(img) # 更新菜单
disp.show(img) # 屏幕显示