Skip to content

Commit a76d2b7

Browse files
Fix logo in dark mode
1 parent 75b7e8d commit a76d2b7

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed
5.5 KB
Loading
Binary file not shown.

internal_filesystem/lib/mpos/ui/display.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# lib/mpos/ui/display.py
22
import lvgl as lv
3-
from mpos.ui.theme import _is_light_mode
43

54
_horizontal_resolution = None
65
_vertical_resolution = None
76
_dpi = None
87

9-
logo_url = "M:builtin/res/mipmap-mdpi/MicroPythonOS_logo_white_on_black_240x35.png"
8+
# White text on black logo works (for dark mode) and can be inverted (for light mode)
9+
logo_white = "M:builtin/res/mipmap-mdpi/MicroPythonOS-logo-white-long-w240.png"
10+
11+
# Black text on transparent logo works (for light mode) but can't be inverted (for dark mode)
12+
# Even when trying different blend modes (SUBTRACTIVE, ADDITIVE, MULTIPLY)
13+
# Even when it's on a white (instead of transparent) background
14+
#logo_black = "M:builtin/res/mipmap-mdpi/MicroPythonOS_logo_black_240x35.png"
15+
#logo_black = "M:builtin/res/mipmap-mdpi/MicroPythonOS-logo-black-long-w240.png"
1016

1117
def init_rootscreen():
1218
global _horizontal_resolution, _vertical_resolution, _dpi
@@ -18,9 +24,8 @@ def init_rootscreen():
1824
print(f"init_rootscreen set resolution to {_horizontal_resolution}x{_vertical_resolution} at {_dpi} DPI")
1925
try:
2026
img = lv.image(screen)
21-
img.set_src(logo_url)
22-
if not _is_light_mode:
23-
img.set_blend_mode(lv.BLEND_MODE.DIFFERENCE) # invert the logo color
27+
img.set_src(logo_white)
28+
img.set_blend_mode(lv.BLEND_MODE.DIFFERENCE)
2429
img.center()
2530
except Exception as e: # if image loading fails
2631
print(f"ERROR: logo image failed, LVGL will be in a bad state and the UI will hang: {e}")

internal_filesystem/lib/mpos/ui/theme.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ def set_theme(prefs):
7979
# Recreate keyboard button fix style if mode changed
8080
global _keyboard_button_fix_style
8181
_keyboard_button_fix_style = None # Force recreation with new theme colors
82+
83+
def is_light_mode():
84+
global _is_light_mode
85+
return _is_light_mode

0 commit comments

Comments
 (0)