pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Scales

Example

from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
scales_0 = unit.get(unit.SCALES, unit.PORTA)

scales_0.write_rgb_led(25, 72, 26)
scales_0.write_button_offset(1)
while True:
  print((str('weight:') + str(((scales_0.read_weight(0x14)/100) - -58344))))
  print((str('button:') + str((scales_0.read_button_status(0x20)))))
  wait(1)
  wait_ms(2)

API

scales_0.init_i2c_address(0x26)
  • 初始化 Unit Scales I2C地址
print(scales_0.read_button_status(0x20))
  • 获取按钮状态
print(scales_0.read_rgb_led(False))
  • 获取LED状态
print(scales_0.read_weight(0x10))
  • 获取ADC原始值状态
print(scales_0.read_status(0xFE))
  • 获取版本号
scales_0.write_offset(5000)
  • 设定偏移ADC值
scales_0.write_soft_offset()
  • 设置偏移电流ADC值
scales_0.write_button_offset(1)
  • 设置按钮偏离
scales_0.write_calibration_load(200)
  • 设置负载校准
scales_0.write_i2c_address(0x26)
  • 重置I2C地址
scales_0.write_rgb_led(0, 0, 0)
  • 设置RGB颜色
scales_0.write_rgb_sync(0)
  • 设置RGB LED 同步状态
    • ENABLE
    • DISABLE
scales_0.write_calibration_zero()
  • 设置校准器为零克
On This Page