pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Grove2grove

案例程序

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

setScreenColor(0x252525)
grove_0 = unit.get(unit.GROVE2GROVE, unit.PORTB)

title0 = M5Title(title="UNIT GROVE2GROVE", x=84, fgcolor=0xFFFFFF, bgcolor=0x000000)

def buttonA_wasPressed():
  # global params
  grove_0.grove_Ctrl_Status(1)
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  # global params
  grove_0.grove_Ctrl_Status(0)
  pass
btnB.wasPressed(buttonB_wasPressed)

while True:
  if grove_0.grove_Ctrl_Status():
    print('is turn on')
  else:
    print('is turn off')
  print((str('Ameter') + str(((str((grove_0.grove_Ameter())) + str('mA'))))))
  wait_ms(1)
  wait_ms(2)

功能说明

print(grove_0.grove_Ameter())
  • 获取当前Unit 检测的电流(mA)
print(grove_0.grove_Ctrl_Status())
  • 获取当前Unit 状态
grove_0.grove_Ctrl_Status(1)
  • 设置Unit 状态
    • ON
    • OFF
grove_0.grove_Set_Vref()
  • 设置 0 mA 参考电流
On This Page