1212SLIDER_MIN_VALUE = 1
1313SLIDER_MAX_VALUE = 100
1414SLIDER_DEFAULT_VALUE = 100
15- OFFSET_WIFI_ICON = - 60
16- OFFSET_BATTERY_ICON = - 40
1715
1816CLOCK_UPDATE_INTERVAL = 100 # 10 or even 1 ms doesn't seem to change the framerate but 100ms is enough
1917WIFI_ICON_UPDATE_INTERVAL = 1500
2018TEMPERATURE_UPDATE_INTERVAL = 2000
19+ MEMFREE_UPDATE_INTERVAL = 1000
2120
2221# Color palette
2322DARKPINK = lv .color_hex (0xEC048C )
@@ -82,34 +81,43 @@ def toggle_drawer(event):
8281time_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
8382
8483temp_label = lv .label (notification_bar )
85- temp_label .set_text ("" )
84+ temp_label .set_text ("00°C " )
8685temp_label .align_to (time_label , lv .ALIGN .OUT_RIGHT_MID , PADDING_TINY , 0 )
8786temp_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
8887
88+ memfree_label = lv .label (notification_bar )
89+ memfree_label .set_text ("" )
90+ memfree_label .align_to (temp_label , lv .ALIGN .OUT_RIGHT_MID , PADDING_TINY , 0 )
91+ memfree_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
92+ #style = lv.style_t()
93+ #style.init()
94+ #style.set_text_font(lv.font_montserrat_8) # tiny font
95+ #memfree_label.add_style(style, 0)
96+
8997# Notification icon (bell)
9098#notif_icon = lv.label(notification_bar)
9199#notif_icon.set_text(lv.SYMBOL.BELL)
92100#notif_icon.align_to(time_label, lv.ALIGN.OUT_RIGHT_MID, PADDING_TINY, 0)
93101#notif_icon.set_style_text_color(COLOR_TEXT_WHITE, 0)
94102
103+ # Battery icon
104+ battery_icon = lv .label (notification_bar )
105+ battery_icon .set_text (lv .SYMBOL .BATTERY_FULL )
106+ battery_icon .align (lv .ALIGN .RIGHT_MID , - PADDING_TINY , 0 )
107+ battery_icon .set_style_text_color (COLOR_TEXT_WHITE , 0 )
108+
95109# WiFi icon
96110wifi_icon = lv .label (notification_bar )
97111wifi_icon .set_text (lv .SYMBOL .WIFI )
98- wifi_icon .align ( lv .ALIGN .RIGHT_MID , OFFSET_WIFI_ICON , 0 )
112+ wifi_icon .align_to ( battery_icon , lv .ALIGN .OUT_LEFT_MID , - PADDING_TINY , 0 )
99113wifi_icon .set_style_text_color (COLOR_TEXT_WHITE , 0 )
100114wifi_icon .add_flag (lv .obj .FLAG .HIDDEN )
101115
102- # Battery icon
103- battery_icon = lv .label (notification_bar )
104- battery_icon .set_text (lv .SYMBOL .BATTERY_FULL )
105- battery_icon .align (lv .ALIGN .RIGHT_MID , OFFSET_BATTERY_ICON , 0 )
106- battery_icon .set_style_text_color (COLOR_TEXT_WHITE , 0 )
107-
108- # Battery percentage
109- battery_label = lv .label (notification_bar )
110- battery_label .set_text ("100%" )
111- battery_label .align (lv .ALIGN .RIGHT_MID , 0 , 0 )
112- battery_label .set_style_text_color (COLOR_TEXT_WHITE , 0 )
116+ # Battery percentage - not shown to conserve space
117+ #battery_label = lv.label(notification_bar)
118+ #battery_label.set_text("100%")
119+ #battery_label.align(lv.ALIGN.RIGHT_MID, 0, 0)
120+ #battery_label.set_style_text_color(COLOR_TEXT_WHITE, 0)
113121
114122
115123# Update time
@@ -134,9 +142,16 @@ def update_wifi_icon(timer):
134142def update_temperature (timer ):
135143 temp_label .set_text (f"{ esp32 .mcu_temperature ()} °C" )
136144
145+ import gc
146+ def update_memfree (timer ):
147+ memfree_label .set_text (f"{ gc .mem_free ()} " )
148+
137149lv .timer_create (update_time , CLOCK_UPDATE_INTERVAL , None )
138- lv .timer_create (update_wifi_icon , WIFI_ICON_UPDATE_INTERVAL , None )
139150lv .timer_create (update_temperature , TEMPERATURE_UPDATE_INTERVAL , None )
151+ lv .timer_create (update_memfree , MEMFREE_UPDATE_INTERVAL , None )
152+ lv .timer_create (update_wifi_icon , WIFI_ICON_UPDATE_INTERVAL , None )
153+
154+
140155
141156notification_bar .add_event_cb (toggle_drawer , lv .EVENT .CLICKED , None )
142157
0 commit comments