pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

Atomic Base

UIFlow 1.0 Project

Joystick

案例程序

获取操纵杆的当前状态

from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
joystick_0 = unit.get(unit.JOYSTICK, unit.PORTA)

while True:
  print(joystick_0.X)
  print(joystick_0.Y)
  print(joystick_0.Press)
  wait(0.2)
  wait_ms(2)

功能说明

print(joystick_0.Press)
  • Get is pressed 返回按键的值
print(joystick_0.InvertX)
  • Get Reverse X 返回X轴反向数据
print(joystick_0.InvertY)
  • Get Reverse Y 返回Y轴反向数据
print(joystick_0.X)
  • Get X 返回X轴的数据
print(joystick_0.Y)
  • Get Y 返回Y轴的数据
On This Page