FlashLight Unit

FlashLight UNIT 是一款内置闪光灯的 I/O Unit,包含 AW3641 驱动器和白色 LED,色温为 5000-5700K。板载模式选择开关,可设置闪光模式和常亮模式。通信接口为 GPIO。该 Unit 可用于闪光或照明应用。

支持以下产品:

FlashLightUnit

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 unit import FlashLightUnit
 9import time
10
11
12flashlight_0 = None
13
14
15def setup():
16    global flashlight_0
17
18    M5.begin()
19    Widgets.fillScreen(0x222222)
20
21    flashlight_0 = FlashLightUnit((8, 9))
22
23
24def loop():
25    global flashlight_0
26    M5.update()
27    flashlight_0.flash(flashlight_0.BRIGHTNESS_100, flashlight_0.TIME_220MS, True)
28    time.sleep(1)
29
30
31if __name__ == "__main__":
32    try:
33        setup()
34        while True:
35            loop()
36    except (Exception, KeyboardInterrupt) as e:
37        try:
38            from utility import print_error_msg
39
40            print_error_msg(e)
41        except ImportError:
42            print("please update to latest firmware")

UiFlow2 应用示例

example.png

cores3_flashlight_example.m5f2

class FlashLightUnit

“”

class FlashLightUnit(port)

初始化 FlashLightUnit。

参数:

port – FlashLightUnit 连接的端口。port[0]:adc 引脚,port[1]:pump 引脚。

UIFLOW2:

init.png

Methods

FlashLightUnit.flash(brightness: int, time: int, turn_off=False) None

闪烁灯光。

参数:
  • brightness – 灯光的亮度。选项: - FlashLightUnit.BRIGHTNESS_100:100% - FlashLightUnit.BRIGHTNESS_90:90% - FlashLightUnit.BRIGHTNESS_80:80% - FlashLightUnit.BRIGHTNESS_70:70% - FlashLightUnit.BRIGHTNESS_60:60% - FlashLightUnit.BRIGHTNESS_50:50% - FlashLightUnit.BRIGHTNESS_40:40% - FlashLightUnit.BRIGHTNESS_30:30%

  • time – 灯光的时间。选项: - FlashLightUnit.TIME_220MS:220 ms - FlashLightUnit.TIME_1300MS:1300 ms

  • turn_off – 闪烁后关闭灯。

UIFLOW2:

flash.png