UIFlow Guide
初始化操纵杆模块的 I2C 地址和 LED 亮度,并在循环中连续获取操纵杆的当前位置、ADC 值、按键状态和固件版本,并将这些信息打印出来。
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()
joystick2_0.get_firmware_version()
joystick2_0.set_axis_x_invert(True)
joystick2_0.set_axis_y_invert(True)
joystick2_0.set_axis_swap(True)
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)