pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Dlight

案例程序

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

setScreenColor(0x222222)
dlight_0 = unit.get(unit.DLIGHT, unit.PORTA)

def buttonA_wasPressed():
  # global params
  dlight_0.set_mode(0x10)
  print('Continous Mode 1')
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  # global params
  dlight_0.set_mode(0x20)
  print('One Shot Mode 1')
  pass
btnB.wasPressed(buttonB_wasPressed)

def buttonC_wasPressed():
  # global params
  dlight_0.set_mode(0x07)
  print('Reset')
  pass
btnC.wasPressed(buttonC_wasPressed)


while True:
  print((str('lux value:') + str((dlight_0.get_lux()))))
  wait_ms(250)
  wait_ms(2)

功能说明

print((str('Lux value:') + str((dlight_0.get_lux()))))
  • 获取环境光照度值
dlight_0.set_mode(0x10)
  • 连续模式
    • H-Res1
    • H-Res2
    • L-Res
dlight_0.set_mode(0x20)
  • 单镜头模式
    • H-Res1
    • H-Res2
    • L-Res
dlight_0.set_mode(0x00)
  • 设备状态控件
On This Page