diff --git a/library/lcd/lcd_comm.py b/library/lcd/lcd_comm.py index 5a79408b..10f14b17 100644 --- a/library/lcd/lcd_comm.py +++ b/library/lcd/lcd_comm.py @@ -235,6 +235,10 @@ def DisplayText( assert len(text) > 0, 'Text must not be empty' assert font_size > 0, "Font size must be > 0" + # If only width is specified, assume height based on font size (one-line text) + if width > 0 and height == 0: + height = font_size + if background_image is None: # A text bitmap is created with max width/height by default : text with solid background text_image = Image.new( diff --git a/library/stats.py b/library/stats.py index 58c86132..d70413f9 100644 --- a/library/stats.py +++ b/library/stats.py @@ -841,11 +841,6 @@ def stats(): wdescription_theme_data = weather_theme_data.get('WEATHER_DESCRIPTION', {}).get('TEXT', {}) whumidity_theme_data = weather_theme_data.get('HUMIDITY', {}).get('TEXT', {}) - # Retrieve information used to center description, if needed - center_description_length = 40 - if 'CENTER_LENGTH' in wdescription_theme_data: - center_description_length = wdescription_theme_data['CENTER_LENGTH'] - activate = True if wtemperature_theme_data.get("SHOW") or wfelt_theme_data.get( "SHOW") or wupdatetime_theme_data.get("SHOW") or wdescription_theme_data.get( "SHOW") or whumidity_theme_data.get("SHOW") else False @@ -861,8 +856,6 @@ def stats(): desc = "Cloudy" time = "@15:33" humidity = "45%" - if wdescription_theme_data['CENTER_LENGTH']: - desc = "x" * center_description_length else: # API Parameters lat = config.CONFIG_DATA['config'].get('WEATHER_LATITUDE', "") @@ -880,8 +873,6 @@ def stats(): temp = f"{data['current']['temp']:.1f}{deg}" feel = f"({data['current']['feels_like']:.1f}{deg})" desc = data['current']['weather'][0]['description'].capitalize() - if wdescription_theme_data['CENTER_LENGTH']: - desc = desc.center(center_description_length) humidity = f"{data['current']['humidity']:.0f}%" now = datetime.datetime.now() time = f"@{now.hour:02d}:{now.minute:02d}" diff --git a/res/themes/ColoredFlat/preview.png b/res/themes/ColoredFlat/preview.png index 1b98ede4..de9411c7 100644 Binary files a/res/themes/ColoredFlat/preview.png and b/res/themes/ColoredFlat/preview.png differ diff --git a/res/themes/ColoredFlat/theme.yaml b/res/themes/ColoredFlat/theme.yaml index 3f199233..ca56f5e3 100644 --- a/res/themes/ColoredFlat/theme.yaml +++ b/res/themes/ColoredFlat/theme.yaml @@ -532,14 +532,14 @@ STATS: WEATHER_DESCRIPTION: TEXT: SHOW: True - 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 ! - CENTER_LENGTH: 40 - X: 20 + X: 0 Y: 95 + WIDTH: 480 FONT: roboto-mono/RobotoMono-Bold.ttf FONT_SIZE: 18 FONT_COLOR: 247, 227, 227 BACKGROUND_IMAGE: background.png + ANCHOR: mb # Text is centered PING: INTERVAL: 1 TEXT: diff --git a/res/themes/theme_example.yaml b/res/themes/theme_example.yaml index 72b141d4..c34df53a 100644 --- a/res/themes/theme_example.yaml +++ b/res/themes/theme_example.yaml @@ -1508,8 +1508,6 @@ STATS: WEATHER_DESCRIPTION: TEXT: SHOW: True - 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 ! - CENTER_LENGTH: 40 X: 20 Y: 95 FONT: roboto-mono/RobotoMono-Bold.ttf