Skip to content

Commit 28bbb9b

Browse files
Fix wifi button in drawer, tweaks stuff
1 parent 385b017 commit 28bbb9b

File tree

1 file changed

+11
-10
lines changed
  • internal_filesystem/lib/mpos

1 file changed

+11
-10
lines changed

internal_filesystem/lib/mpos/ui.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ def open_drawer():
7777
drawer.remove_flag(lv.obj.FLAG.HIDDEN)
7878

7979
def close_drawer(to_launcher=False):
80-
global drawer_open, drawer
80+
global drawer_open, drawer, foreground_app_name
8181
if drawer_open:
8282
drawer_open=False
8383
drawer.add_flag(lv.obj.FLAG.HIDDEN)
8484
if not to_launcher and not mpos.apps.is_launcher(foreground_app_name):
85-
print("close_drawer: also closing bar")
85+
print(f"close_drawer: also closing bar because to_launcher is {to_launcher} and foreground_app_name is {foreground_app_name}")
8686
close_bar()
8787

8888
def open_bar():
@@ -271,7 +271,7 @@ def create_drawer(display=None):
271271
slider.set_range(1,100)
272272
slider.set_value(100,False)
273273
slider.set_width(lv.pct(80))
274-
slider.align_to(slider_label,lv.ALIGN.OUT_BOTTOM_MID,0,lv.pct(4))
274+
slider.align_to(slider_label,lv.ALIGN.OUT_BOTTOM_MID,0,lv.pct(6))
275275
def slider_event(e):
276276
value=slider.get_value()
277277
slider_label.set_text(f"{value}%")
@@ -288,7 +288,7 @@ def slider_event(e):
288288
def wifi_event(e):
289289
global drawer_open
290290
close_drawer()
291-
mpos.apps.start_app_by_name("com.micropythonos.wificonf")
291+
mpos.apps.start_app_by_name("com.micropythonos.wifi")
292292

293293
wifi_btn.add_event_cb(wifi_event,lv.EVENT.CLICKED,None)
294294
#
@@ -320,7 +320,7 @@ def launcher_event(e):
320320
#
321321
restart_btn=lv.button(drawer)
322322
restart_btn.set_size(lv.pct(40),lv.SIZE_CONTENT)
323-
restart_btn.align(lv.ALIGN.RIGHT_MID,0,0)
323+
restart_btn.align(lv.ALIGN.BOTTOM_RIGHT,0,0)
324324
restart_label=lv.label(restart_btn)
325325
restart_label.set_text(lv.SYMBOL.POWER+" Reset")
326326
restart_label.center()
@@ -338,6 +338,8 @@ def reset_cb(e):
338338
except Exception as e:
339339
print("Warning: could not import machine, not adding reset callback")
340340

341+
'''
342+
Doesn't do anything on ESP32, not much use:
341343
poweroff_btn=lv.button(drawer)
342344
poweroff_btn.set_size(lv.pct(40),lv.SIZE_CONTENT)
343345
poweroff_btn.align(lv.ALIGN.BOTTOM_RIGHT,0,0)
@@ -348,9 +350,8 @@ def poweroff_cb(e):
348350
lv.deinit() # Deinitialize LVGL (if supported)
349351
import sys
350352
sys.exit(0)
351-
352353
poweroff_btn.add_event_cb(poweroff_cb,lv.EVENT.CLICKED,None)
353-
354+
'''
354355

355356

356357

@@ -554,7 +555,7 @@ def back_swipe_cb(event):
554555

555556
def handle_back_swipe():
556557
rect = lv.obj(lv.layer_top())
557-
rect.set_size(NOTIFICATION_BAR_HEIGHT, lv.layer_top().get_height()-NOTIFICATION_BAR_HEIGHT)
558+
rect.set_size(round(NOTIFICATION_BAR_HEIGHT/2), lv.layer_top().get_height()-NOTIFICATION_BAR_HEIGHT) # narrow because it overlaps buttons
558559
rect.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
559560
rect.set_pos(0, NOTIFICATION_BAR_HEIGHT)
560561
style = lv.style_t()
@@ -596,7 +597,7 @@ def top_swipe_cb(event):
596597
y = point.y
597598
print(f"pos: {x}, {y}")
598599
#rect.set_pos(x, 0)
599-
if event_code == lv.EVENT.RELEASED and y > 60: # TODO: use display_height / 3 here
600+
if event_code == lv.EVENT.RELEASED and y > 60: # TODO: use display_height / 3 here, or better: an animation for more feedback
600601
mpos.ui.open_drawer()
601602
#rect.set_pos(0,0)
602603
#rect.set_pos(xa + point.x, ya + point.y)
@@ -605,7 +606,7 @@ def top_swipe_cb(event):
605606

606607
def handle_top_swipe():
607608
rect = lv.obj(lv.layer_top())
608-
rect.set_size(lv.pct(100), NOTIFICATION_BAR_HEIGHT)
609+
rect.set_size(lv.pct(100), round(NOTIFICATION_BAR_HEIGHT*2/3))
609610
rect.set_pos(0, 0)
610611
rect.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
611612
style = lv.style_t()

0 commit comments

Comments
 (0)