pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Joystick

案例程序

串口实时打印电位器的X,Y轴和按键值

from m5stack import *
from m5ui import *
from uiflow import *
import hat

setScreenColor(0x111111)

hat_Joystick_0 = hat.get(hat.JOYSTICK)

while True:
  print(hat_Joystick_0.X)
  print(hat_Joystick_0.Y)
  print(hat_Joystick_0.Press)
  wait_ms(2)

功能说明

hat_Joystick_0.Press
  • 检查操纵杆是否被按下
hat_Joystick_0.InvertX
  • 获取操纵杆X轴的反转值
hat_Joystick_0.InvertY
  • 获取操纵杆Y轴的反转值
hat_Joystick_0.X
  • 获取操纵杆的X轴位置值
hat_Joystick_0.Y
  • 获取操纵杆的Y轴位置值
On This Page