You've already forked uiflow-micropython
mirror of
https://github.com/m5stack/uiflow-micropython.git
synced 2026-05-20 10:39:27 -07:00
b3e4371492
Signed-off-by: Tinyu <tinyu@Tinyus-Mac-mini.local>
53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import os, sys, io
|
|
import M5
|
|
from M5 import *
|
|
from unit import ButtonUnit
|
|
|
|
|
|
title0 = None
|
|
label1 = None
|
|
label0 = None
|
|
button_0 = None
|
|
|
|
|
|
def setup():
|
|
global title0, label1, label0, button_0
|
|
|
|
M5.begin()
|
|
Widgets.fillScreen(0x222222)
|
|
title0 = Widgets.Title(
|
|
"ButtonUnit Core2 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18
|
|
)
|
|
label1 = Widgets.Label(
|
|
"Button State:", 395, 150, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
|
|
)
|
|
label0 = Widgets.Label(
|
|
"Button Counter Value:", 1, 102, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
|
|
)
|
|
|
|
button_0 = ButtonUnit((33, 32), True, type=2)
|
|
|
|
|
|
def loop():
|
|
global title0, label1, label0, button_0
|
|
M5.update()
|
|
label0.setText(str((str("Button Counter Value:") + str((button_0.count_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")
|