juechafun/模板文件/模板-原子化笔记-代码.md

57 lines
1021 B
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
#领域/<% "未知" %>
#复盘/<% "0" %> #临时/备忘 #状态/<% "待处理" %>
<% tp.file.creation_date("YYYYMMDD") %>-备忘-主题名-文件内容
## 一句话描述
[____<% tp.file.cursor() %>____]
---
## 个人理解
[________]
## 实践计划
1. [________]
2. [________]
3. [________]
## 核心定义
[________]
## 最小实现代码
```python
from maix import touchscreen
ts = touchscreen.TouchScreen()
x, y, pressed = ts.read()
```
## 样例程序
```python
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) # 屏幕显示
```