pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Joyc

案例程序

设置灯的颜色为红色,串口实时打印电位器的X,Y的数值和旋转的角度和按键的状态值

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

setScreenColor(0x111111)

hat_joyc_0 = hat.get(hat.JOYC)

hat_joyc_0.SetLedColor(0xff0000)
while True:
  print(hat_joyc_0.GetX(0))
  print(hat_joyc_0.GetY(0))
  print(hat_joyc_0.GetAngle(0))
  print(hat_joyc_0.GetPress(0))
  wait_ms(2)

功能说明

hat_joyc_0.GetAngle(0)
  • 获取操纵杆的角度
hat_joyc_0.GetDistance(0)
  • 获取操纵杆的距离值
hat_joyc_0.GetPress(0)
  • 获取操纵杆的按压状态
hat_joyc_0.GetX(0)
  • 获取操纵杆在X轴上的数值
hat_joyc_0.GetY(0)
  • 获取操纵杆在Y轴上的数值
hat_joyc_0.SetLedColor(0x0)
  • 设置LED灯的颜色(红、绿、蓝三色)
On This Page