pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Kmeter

案例程序

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

setScreenColor(0x222222)
KMeter_0 = unit.get(unit.KMETER, unit.PORTA)

KMeter_0.init_i2c_address(0x66)
print((str('firmware version:') + str((KMeter_0.get_firmware_version()))))
print((str('I2C address') + str((KMeter_0.rw_i2c_address()))))
while True:
  print((str('thermocouple:') + str((KMeter_0.get_kmeter(1)))))
  print((str('Internal Temp:') + str((KMeter_0.get_kmeter(2)))))
  wait_ms(2)

功能说明

KMeter_0.init_i2c_address(0x66)
  • 初始化设备的i2c地址,默认是0x66
print(KMeter_0.get_firmware_version())
  • 获取设备的固件版本号
print(KMeter_0.rw_i2c_address())
  • 获取设备的i2c地址
print(KMeter_0.rw_sleep_time())
  • 获取设备睡眠时间
print(KMeter_0.get_kmeter(1))
  • 获取采集温度
    • Thermocouple
    • Internal Temp
KMeter_0.rw_i2c_address(0x66)
  • 设置设备的i2c地址
KMeter_0.rw_sleep_time(5)
  • 设置设备睡眠时间
KMeter_0.set_wakeup_timer(True)
  • 设置设备随眠时间
On This Page