pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Touch

案例程序

将触摸坐标和触摸状态显示在屏幕上

from m5stack import *
from m5stack_ui import *
from uiflow import *
from m5stack import touch

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)

label0 = M5Label('label0', x=123, y=59, color=0x000, font=FONT_MONT_14, parent=None)
label1 = M5Label('label1', x=121, y=93, color=0x000, font=FONT_MONT_14, parent=None)

while True:
  label0.set_text(str(touch.read()))
  label1.set_text(str(touch.status()))
  wait_ms(2)

功能说明

str(touch.read())
  • 获取屏幕触摸点坐标x和y轴(x:0-320,y:0-240)
str(touch.read()[0])
  • 获取屏幕触摸点的x轴坐标(返回0-320)
str(touch.read()[1])
  • 获取屏幕触摸点的y轴坐标(返回0-240)
str(touch.status())
  • 返回true或者false,触摸屏幕返回ture,没有触摸屏幕返回false
On This Page