From a0413a30be196a53f3bc836a1d6afa6f6350ebfd Mon Sep 17 00:00:00 2001 From: Matthieu Houdebine Date: Sun, 22 Dec 2024 17:54:23 +0100 Subject: [PATCH 1/2] Fix CI workflows for themes with spaces in name --- .github/workflows/themes-screenshot-on-pr.yml | 2 +- .github/workflows/themes-screenshot-on-push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/themes-screenshot-on-pr.yml b/.github/workflows/themes-screenshot-on-pr.yml index 76401c27..30f4b37a 100644 --- a/.github/workflows/themes-screenshot-on-pr.yml +++ b/.github/workflows/themes-screenshot-on-pr.yml @@ -35,7 +35,7 @@ jobs: # Setup selected theme in config.yaml echo "Using theme $theme" - sed -i "/THEME:/c\ THEME: $theme" config.yaml + sed -i '/THEME:/c\ THEME: "$theme"' config.yaml # For tests there is no real HW: use simulated LCD mode # Check if theme is for 5" diff --git a/.github/workflows/themes-screenshot-on-push.yml b/.github/workflows/themes-screenshot-on-push.yml index 1c023337..6070e7d9 100644 --- a/.github/workflows/themes-screenshot-on-push.yml +++ b/.github/workflows/themes-screenshot-on-push.yml @@ -46,7 +46,7 @@ jobs: # Setup selected theme in config.yaml echo "Using theme $theme" - sed -i "/THEME:/c\ THEME: $theme" config.yaml + sed -i '/THEME:/c\ THEME: "$theme"' config.yaml # For tests there is no real HW: use simulated LCD mode # Check if theme is for 5" From 4f0d915312d989806f2a25fb45a9fabcfdc5fe78 Mon Sep 17 00:00:00 2001 From: Matthieu Houdebine Date: Sun, 22 Dec 2024 18:05:32 +0100 Subject: [PATCH 2/2] Add LineGraph new properties: axis legend font and font size --- library/lcd/lcd_comm.py | 8 ++--- library/stats.py | 2 ++ res/themes/ColoredFlat/theme.yaml | 12 +++++++ res/themes/CustomDataExample/theme.yaml | 2 ++ res/themes/LandscapeModernDevice35/theme.yaml | 10 ++++++ res/themes/TaskManager5inch/theme.yaml | 12 ++++--- res/themes/theme_example.yaml | 36 +++++++++++++++++++ 7 files changed, 74 insertions(+), 8 deletions(-) diff --git a/library/lcd/lcd_comm.py b/library/lcd/lcd_comm.py index 25cd4030..6ef3d5f9 100644 --- a/library/lcd/lcd_comm.py +++ b/library/lcd/lcd_comm.py @@ -354,8 +354,8 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int, line_width: int = 2, graph_axis: bool = True, axis_color: Tuple[int, int, int] = (0, 0, 0), - font: str = "./res/fonts/roboto/Roboto-Black.ttf", - font_size: int = 10, + axis_font: str = "./res/fonts/roboto/Roboto-Black.ttf", + axis_font_size: int = 10, background_color: Tuple[int, int, int] = (255, 255, 255), background_image: str = None): # Generate a plot graph and display it @@ -434,13 +434,13 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int, # Draw Legend draw.line([0, 0, 1, 0], fill=axis_color) text = f"{int(max_value)}" - ttfont = ImageFont.truetype(font, font_size) + ttfont = ImageFont.truetype(axis_font, axis_font_size) left, top, right, bottom = ttfont.getbbox(text) draw.text((2, 0 - top), text, font=ttfont, fill=axis_color) text = f"{int(min_value)}" - ttfont = ImageFont.truetype(font, font_size) + ttfont = ImageFont.truetype(axis_font, axis_font_size) left, top, right, bottom = ttfont.getbbox(text) draw.text((width - 1 - right, height - 2 - bottom), text, font=ttfont, fill=axis_color) diff --git a/library/stats.py b/library/stats.py index 63cbe394..0c32f2f6 100644 --- a/library/stats.py +++ b/library/stats.py @@ -234,6 +234,8 @@ def display_themed_line_graph(theme_data, values): line_width=theme_data.get("LINE_WIDTH", 2), graph_axis=theme_data.get("AXIS", False), axis_color=theme_data.get("AXIS_COLOR", line_color), # If no color specified, use line color for axis + axis_font=config.FONTS_DIR + theme_data.get("AXIS_FONT", "roboto/Roboto-Black.ttf"), + axis_font_size=theme_data.get("AXIS_FONT_SIZE", 10), background_color=theme_data.get("BACKGROUND_COLOR", (0, 0, 0)), background_image=get_theme_file_path(theme_data.get("BACKGROUND_IMAGE", None)) ) diff --git a/res/themes/ColoredFlat/theme.yaml b/res/themes/ColoredFlat/theme.yaml index ca56f5e3..19eff46c 100644 --- a/res/themes/ColoredFlat/theme.yaml +++ b/res/themes/ColoredFlat/theme.yaml @@ -61,6 +61,8 @@ STATS: LINE_COLOR: 247, 227, 227 AXIS: true AXIS_COLOR: 247, 227, 227 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png FREQUENCY: INTERVAL: 1 @@ -152,6 +154,8 @@ STATS: LINE_COLOR: 247, 227, 227 AXIS: True AXIS_COLOR: 247, 227, 227 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png MEMORY: GRAPH: @@ -263,6 +267,8 @@ STATS: LINE_COLOR: 247, 227, 227 AXIS: true AXIS_COLOR: 247, 227, 227 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png USED: SHOW: True @@ -425,6 +431,8 @@ STATS: LINE_COLOR: 247, 227, 227 AXIS: True AXIS_COLOR: 247, 227, 227 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png UPLOADED: TEXT: @@ -457,6 +465,8 @@ STATS: LINE_COLOR: 247, 227, 227 AXIS: True AXIS_COLOR: 247, 227, 227 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png DOWNLOADED: TEXT: @@ -564,4 +574,6 @@ STATS: LINE_COLOR: 247, 227, 227 AXIS: True AXIS_COLOR: 247, 227, 227 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png diff --git a/res/themes/CustomDataExample/theme.yaml b/res/themes/CustomDataExample/theme.yaml index 2ce10777..571fb96c 100644 --- a/res/themes/CustomDataExample/theme.yaml +++ b/res/themes/CustomDataExample/theme.yaml @@ -98,6 +98,8 @@ STATS: LINE_COLOR: 61, 184, 225 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png diff --git a/res/themes/LandscapeModernDevice35/theme.yaml b/res/themes/LandscapeModernDevice35/theme.yaml index 58265368..1fea6028 100644 --- a/res/themes/LandscapeModernDevice35/theme.yaml +++ b/res/themes/LandscapeModernDevice35/theme.yaml @@ -53,6 +53,8 @@ STATS: AXIS: True #AXIS_COLOR: 100, 207, 213 AXIS_COLOR: 255, 255, 50 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png TEMPERATURE: INTERVAL: 5 @@ -239,6 +241,8 @@ STATS: LINE_WIDTH: 1 AXIS: True AXIS_COLOR: 255, 255, 50 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png TEXT: SHOW: True @@ -265,6 +269,8 @@ STATS: LINE_WIDTH: 1 AXIS: True AXIS_COLOR: 255, 255, 50 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png TEXT: SHOW: True @@ -292,6 +298,8 @@ STATS: LINE_WIDTH: 1 AXIS: True AXIS_COLOR: 255, 255, 50 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png TEXT: SHOW: True @@ -319,6 +327,8 @@ STATS: LINE_WIDTH: 1 AXIS: True AXIS_COLOR: 255, 255, 50 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 BACKGROUND_IMAGE: background.png TEXT: SHOW: True diff --git a/res/themes/TaskManager5inch/theme.yaml b/res/themes/TaskManager5inch/theme.yaml index 2f3a41af..457545b5 100644 --- a/res/themes/TaskManager5inch/theme.yaml +++ b/res/themes/TaskManager5inch/theme.yaml @@ -145,7 +145,6 @@ STATS: AUTOSCALE: False LINE_COLOR: 0, 64, 128 AXIS: False - AXIS_COLOR: 255, 135, 0 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png TEXT: @@ -171,6 +170,8 @@ STATS: LINE_COLOR: 61, 184, 225 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png TEMPERATURE: @@ -187,6 +188,8 @@ STATS: LINE_COLOR: 61, 184, 225 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png FPS: @@ -203,6 +206,8 @@ STATS: LINE_COLOR: 61, 184, 225 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png FAN_SPEED: @@ -219,6 +224,8 @@ STATS: LINE_COLOR: 61, 184, 225 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png MEMORY: @@ -236,7 +243,6 @@ STATS: AUTOSCALE: False LINE_COLOR: 255, 128, 255 AXIS: False - AXIS_COLOR: 255, 135, 0 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png PERCENT_TEXT: @@ -272,7 +278,6 @@ STATS: AUTOSCALE: False LINE_COLOR: 0, 255, 0 AXIS: False - AXIS_COLOR: 255, 135, 0 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png PERCENT_TEXT: @@ -300,7 +305,6 @@ STATS: AUTOSCALE: True LINE_COLOR: 128, 0, 0 AXIS: False - AXIS_COLOR: 255, 135, 0 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png TEXT: diff --git a/res/themes/theme_example.yaml b/res/themes/theme_example.yaml index c34df53a..39f0eae2 100644 --- a/res/themes/theme_example.yaml +++ b/res/themes/theme_example.yaml @@ -139,6 +139,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png FREQUENCY: @@ -211,6 +213,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png LOAD: @@ -345,6 +349,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png FAN_SPEED: @@ -417,6 +423,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png GPU: @@ -491,6 +499,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png MEMORY_PERCENT: @@ -559,6 +569,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png MEMORY_USED: @@ -665,6 +677,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png FPS: @@ -733,6 +747,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png FAN_SPEED: @@ -801,6 +817,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png FREQUENCY: @@ -869,6 +887,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png MEMORY: @@ -924,6 +944,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png VIRTUAL: @@ -974,6 +996,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png USED: @@ -1098,6 +1122,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png TEXT: @@ -1209,6 +1235,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png UPLOADED: @@ -1261,6 +1289,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png DOWNLOADED: @@ -1314,6 +1344,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png UPLOADED: @@ -1366,6 +1398,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png DOWNLOADED: @@ -1563,6 +1597,8 @@ STATS: LINE_WIDTH: 2 AXIS: True AXIS_COLOR: 255, 135, 0 + AXIS_FONT: roboto/Roboto-Black.ttf + AXIS_FONT_SIZE: 10 # BACKGROUND_COLOR: 0, 0, 0 BACKGROUND_IMAGE: background.png TEXT: