FlashLight Unit
FlashLight UNIT is an I/O Unit with built-in flash, including AW3641 driver and a white LED, with a color temperature of 5000-5700K. There is a mode selection switch on the board, which can set the flash mode and the constant lighting mode. The communication interface is GPIO. This Unit can be used as a flash or lighting applications.
Support the following products:
Micropython Example:
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:
cores3_flashlight_example.m5f2
class FlashLightUnit
Constructors
- class FlashLightUnit(port)
Initialize the FlashLightUnit.
- 参数:
port – The port to which the FlashLightUnit is connected. port[0]: adc pin, port[1]: pump pin.
UIFLOW2:
Methods
- FlashLightUnit.flash(brightness: int, time: int, turn_off=False) None
Flash the light.
- 参数:
brightness –
The brightness of the light.
Options:
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 –
The time of the light.
Options:
FlashLightUnit.TIME_220MS
: 220msFlashLightUnit.TIME_1300MS
: 1300ms
turn_off – Turn off the light after flash.
UIFLOW2: