UIFlow Guide
Initialize the joystick module's I2C address and LED brightness, then continuously fetch the joystick's current position, ADC values, button status, and firmware version in a loop and print them.
from m5stack import *
from m5ui import *
from uiflow import *
import unit
joystick2_0 = unit.get(unit.JOYSTICKV2, unit.PORTA)
joystick2_0.init_i2c_address(0x63)
joystick2_0.set_led_brightness(50)
while True:
print(joystick2_0.get_axis_position())
print(joystick2_0.get_x_position())
print(joystick2_0.get_y_position())
print(joystick2_0.get_adc_value())
print(joystick2_0.get_x_raw())
print(joystick2_0.get_y_raw())
print(joystick2_0.get_button_status())
print(joystick2_0.get_firmware_version())
wait_ms(2)
joystick2_0.init_i2c_address(0x63)
joystick2_0.get_axis_position()
joystick2_0.get_x_position()
joystick2_0.get_y_position()
joystick2_0.get_adc_value()
joystick2_0.get_x_raw()
joystick2_0.get_y_raw()
joystick2_0.get_button_status()
True
if pressed; otherwise False
.joystick2_0.get_firmware_version()
joystick2_0.set_axis_x_invert(True)
True
, the X-axis output value will be reversed.joystick2_0.set_axis_y_invert(True)
True
, the Y-axis output value will be reversed.joystick2_0.set_axis_swap(True)
True
, the X and Y axis data will be exchanged.joystick2_0.set_deadzone_position(0, 0)
joystick2_0.set_deadzone_adc(0, 0)
joystick2_0.fill_color(0xff0000)
joystick2_0.set_led_brightness(50)
joystick2_0.set_i2c_address(0x63)
joystick2_0.set_axis_x_mapping(0, 0, 0, 0)
joystick2_0.set_axis_y_mapping(0, 0, 0, 0)