88CLOCK_UPDATE_INTERVAL = 1000 # 10 or even 1 ms doesn't seem to change the framerate but 100ms is enough
99WIFI_ICON_UPDATE_INTERVAL = 1500
1010TEMPERATURE_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
1313DRAWER_ANIM_DURATION = 300
1414
2020
2121hide_bar_animation = None
2222show_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
2430foreground_app_name = None
2531
2632def 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
3137def 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
4653def 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
5266def 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
5874def show_launcher ():
@@ -64,12 +80,27 @@ def show_launcher():
6480def 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
72102def 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