DLight Hat

以下产品受支持:

DLightHAT

MicroPython 应用示例:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from hardware import *
 9from hat import DLightHat
10
11
12label0 = None
13i2c0 = None
14hat_dlight_0 = None
15
16
17def setup():
18    global label0, i2c0, hat_dlight_0
19
20    M5.begin()
21    label0 = Widgets.Label("label0", 39, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
22
23    i2c0 = I2C(0, scl=Pin(26), sda=Pin(0), freq=100000)
24    hat_dlight_0 = DLightHat(i2c0)
25    hat_dlight_0.configure(hat_dlight_0.CONTINUOUSLY, hat_dlight_0.H_RESOLUTION_MODE)
26
27
28def loop():
29    global label0, i2c0, hat_dlight_0
30    M5.update()
31    label0.setText(str(hat_dlight_0.get_lux()))
32
33
34if __name__ == "__main__":
35    try:
36        setup()
37        while True:
38            loop()
39    except (Exception, KeyboardInterrupt) as e:
40        try:
41            from utility import print_error_msg
42
43            print_error_msg(e)
44        except ImportError:
45            print("please update to latest firmware")

UiFlow2 应用示例:

example.png

stickc_plus2_dlight_example.m5f2

class DLightHat

Constructors

class DLightHat(i2c, address: int = 0x23)

创建一个 DLightHat 对象。

参数:
  • i2c – I2C 对象

  • address – 设备的 I2C 地址。默认值为 0x23。

UiFlow2

init.png

DLightHat 类继承自 DLightUnit 类,更多详情请参阅 unit.DLightUnit.Methods