Skip to content

Commit 09caa4c

Browse files
notification bar: disable free memory display, workaround not opening after camera
1 parent b70202e commit 09caa4c

3 files changed

Lines changed: 49 additions & 15 deletions

File tree

internal_filesystem/apps/com.example.camtest/assets/camtest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,10 @@ def init_cam():
260260

261261
# Task handler needs to be updated from this app's thread, otherwise it causes concurrency issues
262262
th.disable()
263+
#time.sleep_ms(500)
263264

264265
while appscreen == lv.screen_active() and keepgoing is True:
266+
#print("cam keeps going...")
265267
if status_label.get_text() != status_label_text:
266268
status_label.set_text(status_label_text)
267269
if status_label_text:
@@ -285,3 +287,4 @@ def init_cam():
285287
print("camtest.py: showing launcher...")
286288
show_launcher()
287289
th.enable()
290+

internal_filesystem/lib/mpos/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def start_app_by_name(app_name, is_launcher=False):
8787
start_app(builtin_app_dir, is_launcher)
8888

8989
def start_app(app_dir, is_launcher=False):
90-
print(f"main.py start_app({app_dir},{is_launcher}")
90+
print(f"main.py start_app({app_dir},{is_launcher})")
9191
mpos.ui.set_foreground_app(app_dir) # would be better to store only the app name...
9292
manifest_path = f"{app_dir}/META-INF/MANIFEST.JSON"
9393
app = parse_manifest(manifest_path)

internal_filesystem/lib/mpos/ui.py

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
CLOCK_UPDATE_INTERVAL = 1000 # 10 or even 1 ms doesn't seem to change the framerate but 100ms is enough
99
WIFI_ICON_UPDATE_INTERVAL = 1500
1010
TEMPERATURE_UPDATE_INTERVAL = 2000
11-
MEMFREE_UPDATE_INTERVAL = 5000 # not too frequent because there's a forced gc.collect() to give it a reliable value
11+
#MEMFREE_UPDATE_INTERVAL = 5000 # not too frequent because there's a forced gc.collect() to give it a reliable value
1212

1313
DRAWER_ANIM_DURATION=300
1414

@@ -20,13 +20,19 @@
2020

2121
hide_bar_animation = None
2222
show_bar_animation = None
23+
show_bar_animation_start_value = -NOTIFICATION_BAR_HEIGHT
24+
show_bar_animation_end_value = 0
25+
hide_bar_animation_start_value = show_bar_animation_end_value
26+
hide_bar_animation_end_value = show_bar_animation_start_value
27+
28+
notification_bar = None
2329

2430
foreground_app_name=None
2531

2632
def set_foreground_app(appname):
2733
global foreground_app_name
28-
print(f"foreground app is: {foreground_app_name}")
2934
foreground_app_name = appname
35+
print(f"foreground app is: {foreground_app_name}")
3036

3137
def open_drawer():
3238
global drawer_open, drawer
@@ -41,18 +47,28 @@ def close_drawer(to_launcher=False):
4147
drawer_open=False
4248
drawer.add_flag(lv.obj.FLAG.HIDDEN)
4349
if not to_launcher and not mpos.apps.is_launcher(foreground_app_name):
50+
print("close_drawer: also closing bar")
4451
close_bar()
4552

4653
def open_bar():
47-
global bar_open, show_bar_animation
54+
print("opening bar...")
55+
global bar_open, show_bar_animation, hide_bar_animation, notification_bar
4856
if not bar_open:
57+
print("not open so opening...")
4958
bar_open=True
50-
show_bar_animation.start()
59+
hide_bar_animation.current_value = hide_bar_animation_end_value # stop the hide animation
60+
show_bar_animation.current_value = hide_bar_animation_start_value
61+
#show_bar_animation.start() # coming from the camera, this doesn't work?!
62+
notification_bar.set_y(show_bar_animation_end_value) # workaround is fine
63+
else:
64+
print("bar already open")
5165

5266
def close_bar():
53-
global bar_open, hide_bar_animation
67+
global bar_open, show_bar_animation, hide_bar_animation
5468
if bar_open:
5569
bar_open=False
70+
show_bar_animation.current_value = show_bar_animation_end_value # stop the show animation
71+
hide_bar_animation.current_value = hide_bar_animation_start_value
5672
hide_bar_animation.start()
5773

5874
def show_launcher():
@@ -64,12 +80,27 @@ def show_launcher():
6480
def create_rootscreen():
6581
global rootscreen
6682
rootscreen = lv.screen_active()
83+
# Create a style for the undecorated screen
84+
style = lv.style_t()
85+
style.init()
86+
# Remove background (make it transparent or set no color)
87+
style.set_bg_opa(lv.OPA.TRANSP) # Transparent background
88+
style.set_border_width(0) # No border
89+
style.set_outline_width(0) # No outline
90+
style.set_shadow_width(0) # No shadow
91+
style.set_pad_all(0) # No padding
92+
style.set_radius(0) # No corner radius (sharp edges)
93+
# Apply the style to the screen
94+
rootscreen.add_style(style, 0)
95+
rootscreen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
96+
#rootscreen.set_scroll_mode(lv.SCROLL_MODE.OFF)
6797
rootlabel = lv.label(rootscreen)
6898
rootlabel.set_text("Welcome!")
6999
rootlabel.align(lv.ALIGN.CENTER, 0, 0)
70100

71101

72102
def create_notification_bar():
103+
global notification_bar
73104
# Create notification bar
74105
notification_bar = lv.obj(lv.layer_top())
75106
notification_bar.set_size(lv.pct(100), NOTIFICATION_BAR_HEIGHT)
@@ -85,9 +116,9 @@ def create_notification_bar():
85116
temp_label = lv.label(notification_bar)
86117
temp_label.set_text("00°C")
87118
temp_label.align_to(time_label, lv.ALIGN.OUT_RIGHT_MID, NOTIFICATION_BAR_HEIGHT , 0)
88-
memfree_label = lv.label(notification_bar)
89-
memfree_label.set_text("")
90-
memfree_label.align_to(temp_label, lv.ALIGN.OUT_RIGHT_MID, NOTIFICATION_BAR_HEIGHT, 0)
119+
#memfree_label = lv.label(notification_bar)
120+
#memfree_label.set_text("")
121+
#memfree_label.align_to(temp_label, lv.ALIGN.OUT_RIGHT_MID, NOTIFICATION_BAR_HEIGHT, 0)
91122
#style = lv.style_t()
92123
#style.init()
93124
#style.set_text_font(lv.font_montserrat_8) # tiny font
@@ -146,14 +177,14 @@ def update_temperature(timer):
146177
temp_label.set_text("42°C")
147178

148179

149-
import gc
150-
def update_memfree(timer):
151-
gc.collect()
152-
memfree_label.set_text(f"{gc.mem_free()}")
180+
#import gc
181+
#def update_memfree(timer):
182+
# gc.collect()
183+
# memfree_label.set_text(f"{gc.mem_free()}")
153184

154185
timer1 = lv.timer_create(update_time, CLOCK_UPDATE_INTERVAL, None)
155186
timer2 = lv.timer_create(update_temperature, TEMPERATURE_UPDATE_INTERVAL, None)
156-
timer3 = lv.timer_create(update_memfree, MEMFREE_UPDATE_INTERVAL, None)
187+
#timer3 = lv.timer_create(update_memfree, MEMFREE_UPDATE_INTERVAL, None)
157188
timer4 = lv.timer_create(update_wifi_icon, WIFI_ICON_UPDATE_INTERVAL, None)
158189

159190
# hide bar animation
@@ -170,7 +201,7 @@ def update_memfree(timer):
170201
show_bar_animation = lv.anim_t()
171202
show_bar_animation.init()
172203
show_bar_animation.set_var(notification_bar)
173-
show_bar_animation.set_values(-NOTIFICATION_BAR_HEIGHT, 0)
204+
show_bar_animation.set_values(show_bar_animation_start_value, show_bar_animation_end_value)
174205
show_bar_animation.set_time(1000)
175206
show_bar_animation.set_custom_exec_cb(lambda not_used, value : notification_bar.set_y(value))
176207

0 commit comments

Comments
 (0)