Light Unit
支持以下产品:
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 LightUnit 9 10 11label0 = None 12light_0 = None 13 14 15def setup(): 16 global label0, light_0 17 18 M5.begin() 19 Widgets.fillScreen(0x222222) 20 label0 = Widgets.Label("label0", 132, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 21 22 light_0 = LightUnit((36, 26)) 23 24 25def loop(): 26 global label0, light_0 27 M5.update() 28 label0.setText(str(light_0.get_digital_value())) 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:
class Light
Constructors
- class Light(IO1, IO2)
创建一个Light对象.
- 参数是:
IO1,IO2
定义数字和模拟输出引脚。
UIFLOW2:
Methods
- Light.get_digital_value()
获取数字量(0或者1)。
UIFLOW2:
- Light.get_analog_value()
获取模拟量(返回0-65535).
UIFLOW2:
- Light.get_ohm()
获取阻值(返回整数)。
UIFLOW2: