diff --git a/examples/uasyncio_example1.py b/examples/uasyncio_example1.py index dde582d30..9055320d6 100644 --- a/examples/uasyncio_example1.py +++ b/examples/uasyncio_example1.py @@ -15,17 +15,22 @@ # Workaround for including frozen modules when running micropython with a script argument # https://github.com/micropython/micropython/issues/6419 -import usys as sys +import sys sys.path.append('') # Imports -from urandom import getrandbits, seed -from utime import ticks_us -from uasyncio import sleep, create_task, Loop, CancelledError +from random import getrandbits, seed +from time import ticks_us +from asyncio import sleep, create_task, Loop, CancelledError import lv_utils import lvgl as lv +try: + import aiorepl +except ImportError: + aiorepl = None + seed(ticks_us()) lv.init() @@ -66,22 +71,26 @@ # Stylized Message Box class ################################################################################################## +popup_msg = "Pop" + class MsgBox(lv.win): def drag_event_handler(self, e): self.move_foreground() - indev = lv.indev_get_act() + # obj = lv.event_get_target(e) + indev = lv.indev_active() indev.get_vect(self.vect) - x = self.get_x() + self.vect.x - y = self.get_y() + self.vect.y + x = self.get_x_aligned() + self.vect.x + y = self.get_y_aligned() + self.vect.y self.set_pos(x, y) def __init__(self, parent): + global popup_msg super().__init__(parent) self.vect = lv.point_t() self.set_size(100,80) - self.add_title("Pop") + self.add_title(popup_msg) msg_box_close_btn = self.add_button(lv.SYMBOL.CLOSE, 20) msg_box_close_btn.add_event_cb(lambda e: self.close_msg_box(), lv.EVENT.RELEASED, None) @@ -169,5 +178,8 @@ async def btn_event_task(obj=None, event=-1): # Start event loop ################################################################################################## +if aiorepl: + create_task(aiorepl.task()) + Loop.run_forever()