Skip to content

Commit 4b0eb25

Browse files
Add facilities for display size handling
1 parent 60b0bd0 commit 4b0eb25

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

internal_filesystem/lib/mpos/ui/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
th = None
88

9+
# These get set by init_rootscreen():
10+
horizontal_resolution = None
11+
vertical_resolution = None
12+
913
NOTIFICATION_BAR_HEIGHT=24
1014

1115
CLOCK_UPDATE_INTERVAL = 1000 # 10 or even 1 ms doesn't seem to change the framerate but 100ms is enough
@@ -109,7 +113,10 @@ def show_launcher():
109113
mpos.apps.restart_launcher()
110114

111115
def init_rootscreen():
116+
global horizontal_resolution, vertical_resolution
112117
rootscreen = lv.screen_active()
118+
horizontal_resolution = rootscreen.get_display().get_horizontal_resolution()
119+
vertical_resolution = rootscreen.get_display().get_vertical_resolution()
113120
# Create a style for the undecorated screen
114121
style = lv.style_t()
115122
style.init()
@@ -624,3 +631,11 @@ def handle_top_swipe():
624631
rect.add_event_cb(top_swipe_cb, lv.EVENT.RELEASED, None)
625632

626633

634+
def pct_of_display_width(percent):
635+
return round(horizontal_resolution * percent / 100)
636+
637+
def min_resolution():
638+
return min(mpos.ui.horizontal_resolution,mpos.ui.vertical_resolution)
639+
640+
def max_resolution():
641+
return max(mpos.ui.horizontal_resolution,mpos.ui.vertical_resolution)

0 commit comments

Comments
 (0)