Skip to content

Commit f8fac8a

Browse files
Explicitly use mpos. prefix + don't hide notification bar in launcher
1 parent c09e023 commit f8fac8a

4 files changed

Lines changed: 21 additions & 20 deletions

File tree

internal_filesystem/boot_unix.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import lvgl as lv
33
import sdl_display
44
import sdl_pointer
5-
from mpos import ui
5+
import mpos.ui
66

77
TFT_HOR_RES=320
88
TFT_VER_RES=240
@@ -31,23 +31,23 @@ def swipe_read_cb(indev_drv, data):
3131
if pressed and start_y is None:
3232
start_y = y
3333
# Mouse button pressed (start of potential swipe)
34-
if y <= ui.NOTIFICATION_BAR_HEIGHT:
34+
if y <= mpos.ui.NOTIFICATION_BAR_HEIGHT:
3535
# Store starting Y if press is in the notification bar area
3636
print(f"Mouse press at Y={start_y}")
3737
elif pressed and start_y is not None:
3838
# Mouse dragged while pressed (potential swipe in progress)
3939
# Check for downward swipe (y increased significantly)
4040
if y > start_y + 50: # Threshold for swipe detection (adjust as needed)
4141
print("long swipe down")
42-
if start_y <= ui.NOTIFICATION_BAR_HEIGHT:
42+
if start_y <= mpos.ui.NOTIFICATION_BAR_HEIGHT:
4343
print("Swipe Down Detected from Notification Bar")
44-
ui.open_drawer()
44+
mpos.ui.open_drawer()
4545
start_y = None # Reset after swipe
4646
else:
4747
# Mouse button released
4848
if start_y is not None and y < start_y - 50: # Threshold for swipe-up
4949
print("Swipe Up Detected")
50-
ui.close_drawer()
50+
mpos.ui.close_drawer()
5151
start_y = None # Reset on release
5252

5353
# Register the custom read callback with the input device

internal_filesystem/lib/mpos/apps.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import _thread
88
import traceback
99

10-
from mpos import ui
1110
import mpos.info
11+
import mpos.ui
1212

1313
# Run the script in the current thread:
1414
def execute_script(script_source, is_file, is_launcher, is_graphical):
@@ -26,20 +26,20 @@ def execute_script(script_source, is_file, is_launcher, is_graphical):
2626
else: # is_graphical
2727
if is_launcher:
2828
prevscreen = None
29-
newscreen = ui.rootscreen
29+
newscreen = mpos.ui.rootscreen
3030
else:
3131
prevscreen = lv.screen_active()
3232
newscreen=lv.obj()
3333
newscreen.set_size(lv.pct(100),lv.pct(100))
3434
lv.screen_load(newscreen)
3535
script_globals = {
3636
'lv': lv,
37-
'NOTIFICATION_BAR_HEIGHT': ui.NOTIFICATION_BAR_HEIGHT, # for apps that want to leave space for notification bar
37+
'NOTIFICATION_BAR_HEIGHT': mpos.ui.NOTIFICATION_BAR_HEIGHT, # for apps that want to leave space for notification bar
3838
'appscreen': newscreen,
3939
'start_app': start_app, # for launcher apps
4040
'parse_manifest': parse_manifest, # for launcher apps
4141
'restart_launcher': restart_launcher, # for appstore apps
42-
'show_launcher': ui.show_launcher, # for apps that want to show the launcher
42+
'show_launcher': mpos.ui.show_launcher, # for apps that want to show the launcher
4343
'CURRENT_OS_VERSION': mpos.info.CURRENT_OS_VERSION, # for osupdate
4444
'__name__': "__main__"
4545
}
@@ -54,7 +54,7 @@ def execute_script(script_source, is_file, is_launcher, is_graphical):
5454
tb = getattr(e, '__traceback__', None)
5555
traceback.print_exception(type(e), e, tb)
5656
print(f"Thread {thread_id}: script {compile_name} finished")
57-
# Note that newscreen isn't deleted, as it might still be foreground, or it might be ui.rootscreen
57+
# Note that newscreen isn't deleted, as it might still be foreground, or it might be mpos.ui.rootscreen
5858
except Exception as e:
5959
print(f"Thread {thread_id}: error:")
6060
tb = getattr(e, '__traceback__', None)
@@ -73,7 +73,7 @@ def execute_script_new_thread(scriptname, is_file, is_launcher, is_graphical):
7373
print("main.py: execute_script_new_thread(): error starting new thread thread: ", e)
7474

7575
def start_app_by_name(app_name, is_launcher=False):
76-
ui.set_foreground_app(app_name)
76+
mpos.ui.set_foreground_app(app_name)
7777
custom_app_dir=f"apps/{app_name}"
7878
builtin_app_dir=f"builtin/apps/{app_name}"
7979
try:
@@ -84,16 +84,16 @@ def start_app_by_name(app_name, is_launcher=False):
8484

8585
def start_app(app_dir, is_launcher=False):
8686
print(f"main.py start_app({app_dir},{is_launcher}")
87-
ui.set_foreground_app(app_dir) # would be better to store only the app name...
87+
mpos.ui.set_foreground_app(app_dir) # would be better to store only the app name...
8888
manifest_path = f"{app_dir}/META-INF/MANIFEST.JSON"
8989
app = parse_manifest(manifest_path)
9090
start_script_fullpath = f"{app_dir}/{app.entrypoint}"
9191
execute_script_new_thread(start_script_fullpath, True, is_launcher, True)
9292
# Launchers have the bar, other apps don't have it
9393
if is_launcher:
94-
ui.open_bar()
94+
mpos.ui.open_bar()
9595
else:
96-
ui.close_bar()
96+
mpos.ui.close_bar()
9797

9898

9999
def restart_launcher():

internal_filesystem/lib/mpos/ui.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import lvgl as lv
2-
from mpos import apps
2+
import mpos.apps
33

44
NOTIFICATION_BAR_HEIGHT=24
55

@@ -38,7 +38,7 @@ def close_drawer(to_launcher=False):
3838
if drawer_open:
3939
drawer_open=False
4040
drawer.add_flag(lv.obj.FLAG.HIDDEN)
41-
if not to_launcher and not apps.is_launcher(foreground_app_name):
41+
if not to_launcher and not mpos.apps.is_launcher(foreground_app_name):
4242
close_bar()
4343

4444
def open_bar():
@@ -55,6 +55,7 @@ def close_bar():
5555

5656
def show_launcher():
5757
global rootscreen
58+
set_foreground_app("com.example.launcher")
5859
open_bar()
5960
lv.screen_load(rootscreen)
6061

internal_filesystem/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import task_handler
22
th = task_handler.TaskHandler(duration=5) # 5ms is recommended for MicroPython+LVGL on desktop
33

4-
from mpos import ui
5-
ui.create_rootscreen()
6-
ui.create_notification_bar()
7-
ui.create_drawer(display)
4+
import mpos.ui
5+
mpos.ui.create_rootscreen()
6+
mpos.ui.create_notification_bar()
7+
mpos.ui.create_drawer(display)
88

99
try:
1010
import freezefs_mount_builtin

0 commit comments

Comments
 (0)