UIFlow 上手教程
Unit Weight-I2C 重量测量
from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
weight_i2c_0 = unit.get(unit.WEIGHT_I2C, unit.PORTA)
weight_i2c_0.init_i2c_address(0x26)
while True:
print(weight_i2c_0.get_weight_int)
wait_ms(2)
weight_i2c_0.init_i2c_address(0x26)
print((str('value:') + str((weight_i2c_0.get_adc_raw))))
print((str('filter:') + str((weight_i2c_0.get_average_filter_level))))
print((str('detail:') + str((weight_i2c_0.get_device_spec(0xFE)))))
print((str('filter:') + str((weight_i2c_0.get_ema_filter_alpha))))
print((str('filter:') + str((weight_i2c_0.get_lowpass_filter))))
print((str('weight:') + str((weight_i2c_0.get_weight_float))))
print((str('weight:') + str((weight_i2c_0.get_weight_int))))
print((str('weight:') + str((weight_i2c_0.get_weight_str))))
weight_i2c_0.set_reset_offset()
weight_i2c_0.set_average_filter_level(0)
weight_i2c_0.set_calibration(0, 0, 100, 100)
weight_i2c_0.set_ema_filter_alpha(0)
weight_i2c_0.set_i2c_address(0x26)
weight_i2c_0.set_lowpass_filter(True)