pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

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)
  • Initializes the I2C address of the Unit Scales
print(scales_0.read_button_status(0x20))
  • Get button status
print(scales_0.read_rgb_led(False))
  • Obtain LED status
print(scales_0.read_weight(0x10))
  • Get the ADC original value status
print(scales_0.read_status(0xFE))
  • Obtain the version number
scales_0.write_offset(5000)
  • Set the offset ADC value
scales_0.write_soft_offset()
  • Set the offset current ADC value
scales_0.write_button_offset(1)
  • Set button deviation
scales_0.write_calibration_load(200)
  • Set the load calibration
scales_0.write_i2c_address(0x26)
  • Resets the I2C address
scales_0.write_rgb_led(0, 0, 0)
  • Set RGB color
scales_0.write_rgb_sync(0)
  • Set the RGB LED synchronization status
    • ENABLE
    • DISABLE
scales_0.write_calibration_zero()
  • Set the calibrator to zero grams
On This Page