Skip to content

Commit 5729e61

Browse files
committed
Implement initial theme editor support for any screen resolution via config mathoudebine#648
Adds OPTIONAL new environment variable; SIM_RESOLUTION which if set should be AAAxBBB where AAA is horizontal resolution and BBB us vertical resolution. Windows example: set SIM_RESOLUTION=320x240 Linux shell example: export SIM_RESOLUTION=320x240 Includes a sample clock that expects 320x240 resolution.
1 parent 2fcdeb1 commit 5729e61

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

library/display.py

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ def __init__(self):
6767
elif config.CONFIG_DATA["display"]["REVISION"] == "D":
6868
self.lcd = LcdCommRevD(com_port=config.CONFIG_DATA['config']['COM_PORT'],
6969
update_queue=config.update_queue)
70+
elif config.CONFIG_DATA["display"]["REVISION"].startswith("SIMU_"):
71+
res_str = config.CONFIG_DATA["display"]["REVISION"][len("SIMU_"):]
72+
display_width, display_height = map(int, res_str.split('x'))
73+
self.lcd = LcdSimulated(display_width=display_height, # NOTE these seem to be reversed
74+
display_height=display_width)
7075
elif config.CONFIG_DATA["display"]["REVISION"] == "SIMU":
7176
self.lcd = LcdSimulated(display_width=320,
7277
display_height=480)
399 Bytes
Loading
13.4 KB
Loading
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
author: "@ChrisClark"
3+
4+
display:
5+
DISPLAY_ORIENTATION: landscape
6+
DISPLAY_RGB_LED: 255, 0, 0
7+
8+
static_images:
9+
BACKGROUND:
10+
PATH: background.png
11+
X: 0
12+
Y: 0
13+
WIDTH: 320
14+
HEIGHT: 240
15+
16+
STATS:
17+
DATE:
18+
INTERVAL: 1
19+
DAY:
20+
TEXT:
21+
# Centered
22+
SHOW: True
23+
X: 1
24+
Y: 10
25+
FONT: roboto/Roboto-Bold.ttf
26+
FONT_SIZE: 60
27+
FONT_COLOR: 200, 200, 200
28+
BACKGROUND_COLOR: 0, 0, 0
29+
WIDTH: 320
30+
ANCHOR: mm
31+
HOUR:
32+
TEXT:
33+
# Centered
34+
SHOW: True
35+
# https://babel.pocoo.org/en/latest/api/dates.html full, long, medium, or short, or a custom date/time pattern
36+
#FORMAT: medium
37+
#FORMAT: short
38+
FORMAT: HH:mm
39+
X: 1
40+
Y: 130
41+
FONT: roboto/Roboto-BoldItalic.ttf
42+
FONT_SIZE: 60
43+
FONT_COLOR: 200, 200, 200
44+
BACKGROUND_COLOR: 50, 0, 0
45+
WIDTH: 320
46+
ANCHOR: mm

theme-editor.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@
7676
config.load_theme()
7777

7878
# For theme editor, always use simulated LCD
79-
if config.THEME_DATA["display"].get("DISPLAY_SIZE", '3.5"') == '5"':
80-
config.CONFIG_DATA["display"]["REVISION"] = "SIMU5"
79+
SIM_RESOLUTION = os.environ.get('SIM_RESOLUTION')
80+
if SIM_RESOLUTION:
81+
config.CONFIG_DATA["display"]["REVISION"] = "SIMU_" + SIM_RESOLUTION
8182
else:
82-
config.CONFIG_DATA["display"]["REVISION"] = "SIMU"
83+
if config.THEME_DATA["display"].get("DISPLAY_SIZE", '3.5"') == '5"':
84+
config.CONFIG_DATA["display"]["REVISION"] = "SIMU5"
85+
else:
86+
config.CONFIG_DATA["display"]["REVISION"] = "SIMU"
8387

8488
from library.display import display # Only import display after hardcoded config is set
8589

0 commit comments

Comments
 (0)