
UiFlow Tutorial
Control servo rotation and RGB LED illumination
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit
setScreenColor(0x222222)
ext_io2_0 = unit.get(unit.EXT_IO2, unit.PORTA)
ext_io2_0.init_i2c_address(0x45)
ext_io2_0.set_config_mode(2, 3)
ext_io2_0.set_config_mode(1, 4)
ext_io2_0.write_rgb_led(1, 78, 74, 96)
while True:
  ext_io2_0.write_servo_angle(2, 65)
  print((str('servo angle:') + str((ext_io2_0.read_servo_angle(2)))))
  wait(1)
  ext_io2_0.write_servo_angle(2, 176)
  print((str('servo angle:') + str((ext_io2_0.read_servo_angle(2)))))
  wait(1)
  wait_ms(2)ext_io2_0.init_i2c_address(0x45)print((str('config mode:') + str((ext_io2_0.get_config_mode(0)))))print((str('ADC 12bit:') + str((ext_io2_0.read_adc12_pin(0)))))print((str('ADC 8bit:') + str((ext_io2_0.read_adc8_pin(0)))))print((str('digital input:') + str((ext_io2_0.read_input_pin(0)))))print((str('RGB LED:') + str((ext_io2_0.read_rgb_led(0)))))print((str('servo angle:') + str((ext_io2_0.read_servo_angle(0)))))print((str('servo pulse:') + str((ext_io2_0.read_servo_pulse(0)))))print((str('version:') + str((ext_io2_0.read_status(0XFE)))))ext_io2_0.set_config_mode(0, 0)ext_io2_0.set_i2c_address(0x45)ext_io2_0.write_output_pin(0, 0)ext_io2_0.write_rgb_led(0, 0, 0, 0)ext_io2_0.write_servo_angle(0, 0)ext_io2_0.write_servo_pulse(0, 500)