pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Dlight

Example

Outputs the light intensity value via serial.

from m5stack import *
from m5ui import *
from uiflow import *
import hat

setScreenColor(0x111111)

hat_dlight_0 = hat.get(hat.DLIGHT)

hat_dlight_0.set_mode(0x10)
while True:
  print(hat_dlight_0.get_lux())
  wait_ms(2)

API

hat_dlight_0.get_lux()
  • Reads the light intensity value in lux.
hat_dlight_0.set_mode(0x10)
  • Sets continuous mode with the current selection as H-Res1, allowing continuous light intensity readings.
hat_dlight_0.set_mode(0x20)
  • Sets one-shot mode with the current selection as H-Res1, for a single light intensity reading.
hat_dlight_0.set_mode(0x00)
  • Controls module state, currently set to Power Down, used to turn off the device or enter low power mode.
On This Page