Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement initial theme editor support for any screen resolution via config #648 #649

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions library/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def __init__(self):
elif config.CONFIG_DATA["display"]["REVISION"] == "D":
self.lcd = LcdCommRevD(com_port=config.CONFIG_DATA['config']['COM_PORT'],
update_queue=config.update_queue)
elif config.CONFIG_DATA["display"]["REVISION"].startswith("SIMU_"):
res_str = config.CONFIG_DATA["display"]["REVISION"][len("SIMU_"):]
display_width, display_height = map(int, res_str.split('x'))
self.lcd = LcdSimulated(display_width=display_height, # NOTE these seem to be reversed
display_height=display_width)
elif config.CONFIG_DATA["display"]["REVISION"] == "SIMU":
self.lcd = LcdSimulated(display_width=320,
display_height=480)
Expand Down
Binary file added res/themes/BigClock_320x240/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/themes/BigClock_320x240/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions res/themes/BigClock_320x240/theme.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
author: "@ChrisClark"
# Also see theme_example.yaml

display:
DISPLAY_SIZE: 2.8"
# DISPLAY_RESOLUTION - custom addition?
DISPLAY_RESOLUTION: 320, 240
DISPLAY_ORIENTATION: landscape
DISPLAY_RGB_LED: 255, 0, 0

static_images:
BACKGROUND:
PATH: background.png
X: 0
Y: 0
# unclear what WIDTH, HEIGHT are used for. Crop, stretch, repeat, etc. - there are no other directives for this config type. If ommited, defaults to 0 (zero)
WIDTH: 320
HEIGHT: 240

static_text:
TEXT:
TEXT: Hello World!
SHOW: True
#ANCHOR: mm # works great as centered
#ANCHOR: la # left
ANCHOR: ra # right # does not seem to work, unless this is right of text box? once Width is set this sort of works
#X: 32
#Y: 93
X: 0
Y: 93
WIDTH: 320
# Adding a width forces the size of the text box, rather than sizing to width of text string
FONT: roboto/Roboto-BoldItalic.ttf
FONT_SIZE: 20
FONT_COLOR: 0, 200, 200
BACKGROUND_COLOR: 0, 128, 0

STATS:
DATE:
INTERVAL: 1
DAY:
TEXT:
# Centered
SHOW: True
X: 1
Y: 10
FONT: roboto/Roboto-Bold.ttf
FONT_SIZE: 60
#FONT_SIZE: 20
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 0, 0, 0
WIDTH: 320
ANCHOR: mm
HOUR:
TEXT:
# In theme emulator, ALIGN appears to be ignored? ANCHOR seems to control this in Pillow
#ALIGN: left # left / center / right
#ALIGN: center
#ANCHOR: lt # does not work
#ANCHOR: lt # Check https://pillow.readthedocs.io/en/stable/handbook/text-anchors.html
ANCHOR: mm # works great as centered
#ANCHOR: la # left
#ANCHOR: ra # right
SHOW: True
# https://babel.pocoo.org/en/latest/api/dates.html full, long, medium, or short, or a custom date/time pattern
# short (6:48 PM) / medium (6:48:53 PM) / long (6:48:53 PM UTC) / full (6:48:53 PM Coordinated Universal Time) / custom pattern e.g. "HH:mm:ss zzz" (6:48:53 EDT)
#FORMAT: medium
#FORMAT: short
FORMAT: HH:mm
X: 1
Y: 130
FONT: roboto/Roboto-BoldItalic.ttf
FONT_SIZE: 60
FONT_COLOR: 200, 200, 200
BACKGROUND_COLOR: 50, 0, 0
WIDTH: 320
10 changes: 7 additions & 3 deletions theme-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@
config.load_theme()

# For theme editor, always use simulated LCD
if config.THEME_DATA["display"].get("DISPLAY_SIZE", '3.5"') == '5"':
config.CONFIG_DATA["display"]["REVISION"] = "SIMU5"
SIM_RESOLUTION = os.environ.get('SIM_RESOLUTION')
if SIM_RESOLUTION:
config.CONFIG_DATA["display"]["REVISION"] = "SIMU_" + SIM_RESOLUTION
else:
config.CONFIG_DATA["display"]["REVISION"] = "SIMU"
if config.THEME_DATA["display"].get("DISPLAY_SIZE", '3.5"') == '5"':
config.CONFIG_DATA["display"]["REVISION"] = "SIMU5"
else:
config.CONFIG_DATA["display"]["REVISION"] = "SIMU"

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

Expand Down