Fix logo in dark mode

This commit is contained in:
Thomas Farstrike
2026-01-21 16:18:44 +01:00
parent 75b7e8dd3b
commit a76d2b7826
4 changed files with 14 additions and 5 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

+10 -5
View File
@@ -1,12 +1,18 @@
# lib/mpos/ui/display.py
import lvgl as lv
from mpos.ui.theme import _is_light_mode
_horizontal_resolution = None
_vertical_resolution = None
_dpi = None
logo_url = "M:builtin/res/mipmap-mdpi/MicroPythonOS_logo_white_on_black_240x35.png"
# White text on black logo works (for dark mode) and can be inverted (for light mode)
logo_white = "M:builtin/res/mipmap-mdpi/MicroPythonOS-logo-white-long-w240.png"
# Black text on transparent logo works (for light mode) but can't be inverted (for dark mode)
# Even when trying different blend modes (SUBTRACTIVE, ADDITIVE, MULTIPLY)
# Even when it's on a white (instead of transparent) background
#logo_black = "M:builtin/res/mipmap-mdpi/MicroPythonOS_logo_black_240x35.png"
#logo_black = "M:builtin/res/mipmap-mdpi/MicroPythonOS-logo-black-long-w240.png"
def init_rootscreen():
global _horizontal_resolution, _vertical_resolution, _dpi
@@ -18,9 +24,8 @@ def init_rootscreen():
print(f"init_rootscreen set resolution to {_horizontal_resolution}x{_vertical_resolution} at {_dpi} DPI")
try:
img = lv.image(screen)
img.set_src(logo_url)
if not _is_light_mode:
img.set_blend_mode(lv.BLEND_MODE.DIFFERENCE) # invert the logo color
img.set_src(logo_white)
img.set_blend_mode(lv.BLEND_MODE.DIFFERENCE)
img.center()
except Exception as e: # if image loading fails
print(f"ERROR: logo image failed, LVGL will be in a bad state and the UI will hang: {e}")
+4
View File
@@ -79,3 +79,7 @@ def set_theme(prefs):
# Recreate keyboard button fix style if mode changed
global _keyboard_button_fix_style
_keyboard_button_fix_style = None # Force recreation with new theme colors
def is_light_mode():
global _is_light_mode
return _is_light_mode