Skip to content

Commit

Permalink
uasyncio_example1: Update function names.
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-anl committed Oct 18, 2024
1 parent a693cab commit 62d48ec
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions examples/uasyncio_example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()

0 comments on commit 62d48ec

Please sign in to comment.