English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Hat Joyc

Example

Sets the LED color to red and continuously prints the joystick’s X and Y potentiometer values, rotation angle, and button press state in the serial output.

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)

API

hat_joyc_0.GetAngle(0)
  • Retrieves the angle of the joystick.
hat_joyc_0.GetDistance(0)
  • Gets the distance value of the joystick.
hat_joyc_0.GetPress(0)
  • Retrieves the press state of the joystick button.
hat_joyc_0.GetX(0)
  • Gets the joystick value on the X-axis.
hat_joyc_0.GetY(0)
  • Gets the joystick value on the Y-axis.
hat_joyc_0.SetLedColor(0x0)
  • Sets the LED color (combination of red, green, and blue).
Page Tools
PDF
On This Page