pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Mini Scales

案例程序

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

setScreenColor(0x222222)
miniscales_0 = unit.get(unit.MINISCALE, unit.PORTA)

miniscales_0.setLed(255, 0, 0)
while True:
  print((str('weight:') + str(((str((miniscales_0.weight)) + str('g'))))))
  print((str('button status:') + str((miniscales_0.button))))
  wait(1)
  wait_ms(2)

功能说明

miniscales_0.calibration(0, adc0, 100, adc1)
  • Calibration measuring weight
print(miniscales_0.adc)
  • Get the ADC raw value
print(miniscales_0.getAverageFilterLevel())
  • Get the average filter level
print(miniscales_0.button)
  • Get the current button status
print(miniscales_0.getEMAFilterAlpha())
  • Obtain EMA filter alpha value
print(miniscales_0.getLowPassFilter())

Obtain low overrate filter status

print(miniscales_0.weight)
  • Gets the current weight (in g, returns Float)
miniscales_0.reset()
  • Reset information
miniscales_0.setAverageFilterLevel(0)
  • Set the level of the average filter
miniscales_0.setEMAFilterAlpha(0)
  • Set EMA filter alpha
miniscales_0.setLed(255, 0, 0)
  • Set the RGB light color value
miniscales_0.setLowPassFilter(True)
  • Set the status of the low pass rate filter
On This Page