pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Joystick

Example

Continuously prints the joystick's X and Y axis values and button press state in the serial output.

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)

API

hat_Joystick_0.Press
  • Checks if the joystick button is pressed.
hat_Joystick_0.InvertX
  • Gets the inverted value of the joystick on the X-axis.
hat_Joystick_0.InvertY
  • Gets the inverted value of the joystick on the Y-axis.
hat_Joystick_0.X
  • Gets the position value of the joystick on the X-axis.
hat_Joystick_0.Y
  • Gets the position value of the joystick on the Y-axis.
On This Page