Skip to content

Commit 388c3aa

Browse files
[display] use dict instead of judge
1 parent 0b07b9c commit 388c3aa

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

library/display.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,17 @@ def _get_theme_orientation() -> Orientation:
5555

5656

5757
def _get_theme_size() -> tuple[int, int]:
58-
if config.THEME_DATA["display"].get("DISPLAY_SIZE", '') == '0.96"':
59-
return 80, 160
60-
if config.THEME_DATA["display"].get("DISPLAY_SIZE", '') == '2.1"':
61-
return 480, 480
62-
elif config.THEME_DATA["display"].get("DISPLAY_SIZE", '') == '3.5"':
63-
return 320, 480
64-
elif config.THEME_DATA["display"].get("DISPLAY_SIZE", '') == '5"':
65-
return 480, 800
66-
elif config.THEME_DATA["display"].get("DISPLAY_SIZE", '') == '8.8"':
67-
return 480, 1920
68-
else:
58+
sizes = {
59+
'0.96"':(80, 160),
60+
'2.1"':(480, 480),
61+
'3.5"':(320, 480),
62+
'5"':(480, 800),
63+
'8.8"':(480, 1920),
64+
}
65+
if config.THEME_DATA["display"].get("DISPLAY_SIZE", '') not in sizes.keys():
6966
logger.warning(
70-
f'Cannot find valid DISPLAY_SIZE property in selected theme {config.CONFIG_DATA["config"]["THEME"]}, defaulting to 3.5"')
71-
return 320, 480
67+
f'Cannot find valid DISPLAY_SIZE property in selected theme {config.CONFIG_DATA["config"]["THEME"]}, defaulting to 3.5"')
68+
return sizes.get(config.THEME_DATA["display"].get("DISPLAY_SIZE", ''), (320, 480))
7269

7370

7471
class Display:

0 commit comments

Comments
 (0)