Skip to content

Commit 1e709c2

Browse files
committed
Fix ColoredFlat theme centered weather by using provided text anchor and width
1 parent fd24d1a commit 1e709c2

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

library/lcd/lcd_comm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ def DisplayText(
235235
assert len(text) > 0, 'Text must not be empty'
236236
assert font_size > 0, "Font size must be > 0"
237237

238+
# If only width is specified, assume height based on font size (one-line text)
239+
if width > 0 and height == 0:
240+
height = font_size
241+
238242
if background_image is None:
239243
# A text bitmap is created with max width/height by default : text with solid background
240244
text_image = Image.new(

library/stats.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -841,11 +841,6 @@ def stats():
841841
wdescription_theme_data = weather_theme_data.get('WEATHER_DESCRIPTION', {}).get('TEXT', {})
842842
whumidity_theme_data = weather_theme_data.get('HUMIDITY', {}).get('TEXT', {})
843843

844-
# Retrieve information used to center description, if needed
845-
center_description_length = 40
846-
if 'CENTER_LENGTH' in wdescription_theme_data:
847-
center_description_length = wdescription_theme_data['CENTER_LENGTH']
848-
849844
activate = True if wtemperature_theme_data.get("SHOW") or wfelt_theme_data.get(
850845
"SHOW") or wupdatetime_theme_data.get("SHOW") or wdescription_theme_data.get(
851846
"SHOW") or whumidity_theme_data.get("SHOW") else False
@@ -861,8 +856,6 @@ def stats():
861856
desc = "Cloudy"
862857
time = "@15:33"
863858
humidity = "45%"
864-
if wdescription_theme_data['CENTER_LENGTH']:
865-
desc = "x" * center_description_length
866859
else:
867860
# API Parameters
868861
lat = config.CONFIG_DATA['config'].get('WEATHER_LATITUDE', "")
@@ -880,8 +873,6 @@ def stats():
880873
temp = f"{data['current']['temp']:.1f}{deg}"
881874
feel = f"({data['current']['feels_like']:.1f}{deg})"
882875
desc = data['current']['weather'][0]['description'].capitalize()
883-
if wdescription_theme_data['CENTER_LENGTH']:
884-
desc = desc.center(center_description_length)
885876
humidity = f"{data['current']['humidity']:.0f}%"
886877
now = datetime.datetime.now()
887878
time = f"@{now.hour:02d}:{now.minute:02d}"

res/themes/ColoredFlat/preview.png

1.12 KB
Loading

res/themes/ColoredFlat/theme.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,14 @@ STATS:
532532
WEATHER_DESCRIPTION:
533533
TEXT:
534534
SHOW: True
535-
CENTER: True # Used to center the description, on a 40 character basis or with CENTER_LENGTH below. Use MONO font for better results. Use fake static data for better positionning !
536-
CENTER_LENGTH: 40
537-
X: 20
535+
X: 0
538536
Y: 95
537+
WIDTH: 480
539538
FONT: roboto-mono/RobotoMono-Bold.ttf
540539
FONT_SIZE: 18
541540
FONT_COLOR: 247, 227, 227
542541
BACKGROUND_IMAGE: background.png
542+
ANCHOR: mb # Text is centered
543543
PING:
544544
INTERVAL: 1
545545
TEXT:

res/themes/theme_example.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,8 +1508,6 @@ STATS:
15081508
WEATHER_DESCRIPTION:
15091509
TEXT:
15101510
SHOW: True
1511-
CENTER: True # Used to center the description, on a 40 character basis or with CENTER_LENGTH below. Use MONO font for better results. Use fake static data for better positionning !
1512-
CENTER_LENGTH: 40
15131511
X: 20
15141512
Y: 95
15151513
FONT: roboto-mono/RobotoMono-Bold.ttf

0 commit comments

Comments
 (0)