You've already forked uiflow-micropython
mirror of
https://github.com/m5stack/uiflow-micropython.git
synced 2026-05-20 10:39:27 -07:00
4b8dbf65b9
Signed-off-by: lbuque <1102390310@qq.com>
51 lines
1007 B
Python
51 lines
1007 B
Python
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
import os, sys, io
|
|
import M5
|
|
from M5 import *
|
|
from bleuart import *
|
|
import time
|
|
|
|
|
|
label0 = None
|
|
ble_periph = None
|
|
|
|
|
|
data = None
|
|
|
|
|
|
def setup():
|
|
global label0, ble_periph, data
|
|
|
|
M5.begin()
|
|
Widgets.fillScreen(0x222222)
|
|
label0 = Widgets.Label("Text", 20, 31, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
|
|
|
|
ble_periph = BLEUARTServer(name="ble-uart")
|
|
|
|
|
|
def loop():
|
|
global label0, ble_periph, data
|
|
M5.update()
|
|
if (ble_periph.any()) > 0:
|
|
data = ble_periph.read()
|
|
label0.setText(str(data))
|
|
ble_periph.write(data)
|
|
else:
|
|
time.sleep_ms(100)
|
|
|
|
|
|
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")
|