@@ -72,94 +72,93 @@ def toggle_drawer(event):
7272 else :
7373 open_drawer ()
7474
75- def add_notification_bar (screen ):
76- # Create notification bar object
77- notification_bar = lv .obj (screen )
78- notification_bar .set_style_bg_color (COLOR_NOTIF_BAR_BG , 0 )
79- notification_bar .set_size (TFT_HOR_RES , NOTIFICATION_BAR_HEIGHT )
80- notification_bar .set_pos (0 , 0 )
81- notification_bar .set_scrollbar_mode (lv .SCROLLBAR_MODE .OFF )
82- notification_bar .set_scroll_dir (lv .DIR .VER )
83- notification_bar .set_style_border_width (0 , 0 )
84- notification_bar .set_style_radius (0 , 0 )
85- # Time label
86- time_label = lv .label (notification_bar )
87- time_label .set_text ("00:00:00.000" )
88- time_label .align (lv .ALIGN .LEFT_MID , 0 , 0 )
89- time_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
90- temp_label = lv .label (notification_bar )
91- temp_label .set_text ("00.00°C" )
92- temp_label .align_to (time_label , lv .ALIGN .OUT_RIGHT_MID , PADDING_TINY , 0 )
93- temp_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
94- memfree_label = lv .label (notification_bar )
95- memfree_label .set_text ("" )
96- memfree_label .align_to (temp_label , lv .ALIGN .OUT_RIGHT_MID , PADDING_TINY , 0 )
97- memfree_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
98- #style = lv.style_t()
99- #style.init()
100- #style.set_text_font(lv.font_montserrat_8) # tiny font
101- #memfree_label.add_style(style, 0)
102- # Notification icon (bell)
103- #notif_icon = lv.label(notification_bar)
104- #notif_icon.set_text(lv.SYMBOL.BELL)
105- #notif_icon.align_to(time_label, lv.ALIGN.OUT_RIGHT_MID, PADDING_TINY, 0)
106- #notif_icon.set_style_text_color(COLOR_TEXT_WHITE, 0)
107- # Battery icon
108- battery_icon = lv .label (notification_bar )
109- battery_icon .set_text (lv .SYMBOL .BATTERY_FULL )
110- battery_icon .align (lv .ALIGN .RIGHT_MID , - PADDING_TINY , 0 )
111- battery_icon .set_style_text_color (COLOR_TEXT_WHITE , 0 )
112- # WiFi icon
113- wifi_icon = lv .label (notification_bar )
114- wifi_icon .set_text (lv .SYMBOL .WIFI )
115- wifi_icon .align_to (battery_icon , lv .ALIGN .OUT_LEFT_MID , - PADDING_TINY , 0 )
116- wifi_icon .set_style_text_color (COLOR_TEXT_WHITE , 0 )
117- wifi_icon .add_flag (lv .obj .FLAG .HIDDEN )
118- # Battery percentage - not shown to conserve space
119- #battery_label = lv.label(notification_bar)
120- #battery_label.set_text("100%")
121- #battery_label.align(lv.ALIGN.RIGHT_MID, 0, 0)
122- #battery_label.set_style_text_color(COLOR_TEXT_WHITE, 0)
123- # Update time
124- import time
125- def update_time (timer ):
126- ticks = time .ticks_ms ()
127- hours = (ticks // 3600000 ) % 24
128- minutes = (ticks // 60000 ) % 60
129- seconds = (ticks // 1000 ) % 60
130- milliseconds = ticks % 1000
131- time_label .set_text (f"{ hours :02d} :{ minutes :02d} :{ seconds :02d} .{ milliseconds :03d} " )
132- import network
133- def update_wifi_icon (timer ):
134- try :
135- if network .WLAN (network .STA_IF ).isconnected ():
136- wifi_icon .remove_flag (lv .obj .FLAG .HIDDEN )
137- else :
138- wifi_icon .add_flag (lv .obj .FLAG .HIDDEN )
139- except lv .LvReferenceError :
140- print ("update_wifi_icon caught LvReferenceError" )
141- import esp32
142- def update_temperature (timer ):
143- temp_label .set_text (f"{ esp32 .mcu_temperature ():.2f} °C" )
144- import gc
145- def update_memfree (timer ):
146- gc .collect ()
147- memfree_label .set_text (f"{ gc .mem_free ()} " )
148- timer1 = lv .timer_create (update_time , CLOCK_UPDATE_INTERVAL , None )
149- timer2 = lv .timer_create (update_temperature , TEMPERATURE_UPDATE_INTERVAL , None )
150- timer3 = lv .timer_create (update_memfree , MEMFREE_UPDATE_INTERVAL , None )
151- timer4 = lv .timer_create (update_wifi_icon , WIFI_ICON_UPDATE_INTERVAL , None )
152- #notification_bar.add_event_cb(toggle_drawer, lv.EVENT.CLICKED, None)
153- return timer1 , timer2 , timer3 , timer4
154-
15575
15676drawer = lv .obj (lv .layer_top ())
15777drawer .set_size (lv .pct (100 ),lv .pct (100 ))
15878drawer .set_pos (0 ,- TFT_VER_RES ) # off screen initially
15979drawer .set_style_bg_color (COLOR_DRAWER_BG ,0 )
16080drawer .set_scroll_dir (lv .DIR .NONE )
16181drawer .set_style_pad_all (0 , 0 )
162- add_notification_bar (drawer )
82+
83+ # Create notification bar object
84+ notification_bar = lv .obj (drawer )
85+ notification_bar .set_style_bg_color (COLOR_NOTIF_BAR_BG , 0 )
86+ notification_bar .set_size (TFT_HOR_RES , NOTIFICATION_BAR_HEIGHT )
87+ notification_bar .set_pos (0 , 0 )
88+ notification_bar .set_scrollbar_mode (lv .SCROLLBAR_MODE .OFF )
89+ notification_bar .set_scroll_dir (lv .DIR .VER )
90+ notification_bar .set_style_border_width (0 , 0 )
91+ notification_bar .set_style_radius (0 , 0 )
92+ # Time label
93+ time_label = lv .label (notification_bar )
94+ time_label .set_text ("00:00:00.000" )
95+ time_label .align (lv .ALIGN .LEFT_MID , 0 , 0 )
96+ time_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
97+ temp_label = lv .label (notification_bar )
98+ temp_label .set_text ("00.00°C" )
99+ temp_label .align_to (time_label , lv .ALIGN .OUT_RIGHT_MID , PADDING_TINY , 0 )
100+ temp_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
101+ memfree_label = lv .label (notification_bar )
102+ memfree_label .set_text ("" )
103+ memfree_label .align_to (temp_label , lv .ALIGN .OUT_RIGHT_MID , PADDING_TINY , 0 )
104+ memfree_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
105+ #style = lv.style_t()
106+ #style.init()
107+ #style.set_text_font(lv.font_montserrat_8) # tiny font
108+ #memfree_label.add_style(style, 0)
109+ # Notification icon (bell)
110+ #notif_icon = lv.label(notification_bar)
111+ #notif_icon.set_text(lv.SYMBOL.BELL)
112+ #notif_icon.align_to(time_label, lv.ALIGN.OUT_RIGHT_MID, PADDING_TINY, 0)
113+ #notif_icon.set_style_text_color(COLOR_TEXT_WHITE, 0)
114+ # Battery icon
115+ battery_icon = lv .label (notification_bar )
116+ battery_icon .set_text (lv .SYMBOL .BATTERY_FULL )
117+ battery_icon .align (lv .ALIGN .RIGHT_MID , - PADDING_TINY , 0 )
118+ battery_icon .set_style_text_color (COLOR_TEXT_WHITE , 0 )
119+ # WiFi icon
120+ wifi_icon = lv .label (notification_bar )
121+ wifi_icon .set_text (lv .SYMBOL .WIFI )
122+ wifi_icon .align_to (battery_icon , lv .ALIGN .OUT_LEFT_MID , - PADDING_TINY , 0 )
123+ wifi_icon .set_style_text_color (COLOR_TEXT_WHITE , 0 )
124+ wifi_icon .add_flag (lv .obj .FLAG .HIDDEN )
125+ # Battery percentage - not shown to conserve space
126+ #battery_label = lv.label(notification_bar)
127+ #battery_label.set_text("100%")
128+ #battery_label.align(lv.ALIGN.RIGHT_MID, 0, 0)
129+ #battery_label.set_style_text_color(COLOR_TEXT_WHITE, 0)
130+ # Update time
131+ import time
132+ def update_time (timer ):
133+ ticks = time .ticks_ms ()
134+ hours = (ticks // 3600000 ) % 24
135+ minutes = (ticks // 60000 ) % 60
136+ seconds = (ticks // 1000 ) % 60
137+ milliseconds = ticks % 1000
138+ time_label .set_text (f"{ hours :02d} :{ minutes :02d} :{ seconds :02d} " )
139+ import network
140+ def update_wifi_icon (timer ):
141+ try :
142+ if network .WLAN (network .STA_IF ).isconnected ():
143+ wifi_icon .remove_flag (lv .obj .FLAG .HIDDEN )
144+ else :
145+ wifi_icon .add_flag (lv .obj .FLAG .HIDDEN )
146+ except lv .LvReferenceError :
147+ print ("update_wifi_icon caught LvReferenceError" )
148+ import esp32
149+ def update_temperature (timer ):
150+ temp_label .set_text (f"{ esp32 .mcu_temperature ():.2f} °C" )
151+ import gc
152+ def update_memfree (timer ):
153+ gc .collect ()
154+ memfree_label .set_text (f"{ gc .mem_free ()} " )
155+ timer1 = lv .timer_create (update_time , CLOCK_UPDATE_INTERVAL , None )
156+ timer2 = lv .timer_create (update_temperature , TEMPERATURE_UPDATE_INTERVAL , None )
157+ timer3 = lv .timer_create (update_memfree , MEMFREE_UPDATE_INTERVAL , None )
158+ timer4 = lv .timer_create (update_wifi_icon , WIFI_ICON_UPDATE_INTERVAL , None )
159+ #notification_bar.add_event_cb(toggle_drawer, lv.EVENT.CLICKED, None)
160+
161+
163162slider_label = lv .label (drawer )
164163slider_label .set_text (f"{ SLIDER_DEFAULT_VALUE } %" )
165164slider_label .set_style_text_color (COLOR_TEXT_WHITE ,0 )
0 commit comments