Skip to content

Commit de83dc1

Browse files
committed
prefect/startup/stickcplus2: Optimize some exceptions that cannot be located
Signed-off-by: lbuque <[email protected]>
1 parent b87d7a5 commit de83dc1

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

m5stack/modules/startup/stickcplus2.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self) -> None:
6363
super().__init__()
6464

6565
async def on_ready(self):
66+
M5.Lcd.clear()
6667
execfile("main.py")
6768
sys.exit(0)
6869

@@ -212,6 +213,7 @@ async def on_exit(self):
212213

213214
async def _keycode_enter_event_handler(self, fw):
214215
print("_keycode_enter_event_handler")
216+
M5.Lcd.clear()
215217
execfile("apps/" + self._files[self._file_pos])
216218
sys.exit(0)
217219

@@ -607,7 +609,7 @@ async def run(self):
607609
M5.BtnB.setCallback(type=M5.BtnB.CB_TYPE.WAS_CLICKED, cb=self._BtnB_wasClicked_event)
608610
M5.BtnB.setCallback(type=M5.BtnB.CB_TYPE.WAS_HOLD, cb=self._BtnB_wasHold_event)
609611
asyncio.create_task(self.load(self._launcher))
610-
asyncio.create_task(self.gc_task())
612+
# asyncio.create_task(self.gc_task())
611613
while True:
612614
M5.update()
613615
await asyncio.sleep_ms(100)
@@ -620,20 +622,14 @@ async def gc_task(self):
620622
await asyncio.sleep_ms(5000)
621623

622624
def _BtnA_wasClicked_event(self, state):
623-
asyncio.create_task(self._BtnA_wasClicked_task(state))
624-
625-
async def _BtnA_wasClicked_task(self, state):
626-
print("_BtnA_wasClicked_task")
625+
print("_BtnA_wasClicked_event")
627626
app = self._apps[-1]
628-
await app._keycode_enter_event_handler(self)
627+
asyncio.create_task(app._keycode_enter_event_handler(self))
629628

630629
def _BtnB_wasClicked_event(self, state):
631-
asyncio.create_task(self._BtnB_wasClicked_task(state))
632-
633-
async def _BtnB_wasClicked_task(self, state):
634-
print("BtnB_wasClicked_task")
630+
print("_BtnB_wasClicked_event")
635631
app = self._apps[-1]
636-
await app._keycode_dpad_down_event_handler(self)
632+
asyncio.create_task(app._keycode_dpad_down_event_handler(self))
637633

638634
def _BtnB_wasHold_event(self, state):
639635
asyncio.create_task(self._BtnB_wasHold_task(state))
@@ -666,7 +662,4 @@ def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
666662

667663
fw = Framework()
668664
fw.install_launcher(launcher)
669-
670-
loop = asyncio.get_event_loop()
671-
loop.run_until_complete(fw.run())
672-
loop.close()
665+
asyncio.run(fw.run())

0 commit comments

Comments
 (0)