Files
lbuque d8c257de8e docs: Add some examples.
Signed-off-by: lbuque <1102390310@qq.com>
2024-06-20 11:33:39 +08:00

43 lines
843 B
Python

# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
#
# SPDX-License-Identifier: MIT
import os, sys, io
import M5
from M5 import *
from unit import LightUnit
label0 = None
light_0 = None
def setup():
global label0, light_0
M5.begin()
Widgets.fillScreen(0x222222)
label0 = Widgets.Label("label0", 132, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
light_0 = LightUnit((36, 26))
def loop():
global label0, light_0
M5.update()
label0.setText(str(light_0.get_digital_value()))
if __name__ == "__main__":
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")