From cb7d1392f8bccc89490c4bb840ab29c7bcc13477 Mon Sep 17 00:00:00 2001 From: Joan Date: Wed, 31 Dec 2025 12:28:12 +0100 Subject: [PATCH] Larger font for data, labels at top --- matrix.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/matrix.py b/matrix.py index 92fa3ac..0d59aee 100644 --- a/matrix.py +++ b/matrix.py @@ -118,6 +118,8 @@ class Matrix64Display(SampleBase): font_dir = "/home/pi/rpi-rgb-led-matrix/fonts" time_font = graphics.Font() time_font.LoadFont(f"{font_dir}/7x13.bdf") + data_font = graphics.Font() + data_font.LoadFont(f"{font_dir}/5x8.bdf") small_font = graphics.Font() small_font.LoadFont(f"{font_dir}/4x6.bdf") @@ -125,7 +127,7 @@ class Matrix64Display(SampleBase): time_color = graphics.Color(20, 75, 200) humidity_color = graphics.Color(100, 180, 255) # Light blue for humidity hdd_color = graphics.Color(80, 80, 80) # Dim gray for HDD temps - label_color = graphics.Color(100, 100, 100) # Gray for labels + label_color = graphics.Color(120, 120, 120) # Gray for labels # Initial data fetch self.update_brightness() @@ -149,31 +151,32 @@ class Matrix64Display(SampleBase): # === Weather Icon (top-left, 24x24 area) === draw_weather_icon(canvas, 0, 0, self.weather_desc) - # === Outdoor Weather (right side, row 1) === + # === Labels at top (right side) === + graphics.DrawText(canvas, small_font, 28, 6, label_color, "Out") + graphics.DrawText(canvas, small_font, 48, 6, label_color, "In") + + # === Temperatures (row below labels) === if self.temperature is not None: temp_str = format_temp(self.temperature) temp_color = get_temperature_color(self.temperature) - graphics.DrawText(canvas, small_font, 26, 6, temp_color, temp_str) + graphics.DrawText(canvas, data_font, 26, 14, temp_color, temp_str) - if self.humidity is not None: - hum_str = format_humidity(self.humidity) - graphics.DrawText(canvas, small_font, 48, 6, humidity_color, hum_str) - - # === Indoor Weather (right side, row 2) === if self.interior_temperature is not None: temp_str = format_temp(self.interior_temperature) temp_color = get_temperature_color(self.interior_temperature) - graphics.DrawText(canvas, small_font, 26, 14, temp_color, temp_str) + graphics.DrawText(canvas, data_font, 46, 14, temp_color, temp_str) + + # === Humidity (row below temps) === + if self.humidity is not None: + hum_str = format_humidity(self.humidity) + graphics.DrawText(canvas, data_font, 26, 22, humidity_color, hum_str) if self.interior_humidity is not None: hum_str = format_humidity(self.interior_humidity) - graphics.DrawText(canvas, small_font, 48, 14, humidity_color, hum_str) - - # === Labels for Out/In === - graphics.DrawText(canvas, small_font, 26, 22, label_color, "Out In") + graphics.DrawText(canvas, data_font, 46, 22, humidity_color, hum_str) # === Time Display (centered) === - time_len = len(time_str) * 7 # 7x13 font is ~7px wide + time_len = len(time_str) * 7 time_x = (64 - time_len) // 2 graphics.DrawText(canvas, time_font, time_x, 38, time_color, time_str) @@ -181,8 +184,8 @@ class Matrix64Display(SampleBase): if self.hdd_temps and len(self.hdd_temps) > 4: row1 = " ".join(str(int(t[0]))[:2] for t in self.hdd_temps[1:4]) row2 = " ".join(str(int(t[0]))[:2] for t in self.hdd_temps[4:]) - graphics.DrawText(canvas, small_font, 14, 50, hdd_color, row1) - graphics.DrawText(canvas, small_font, 14, 58, hdd_color, row2) + graphics.DrawText(canvas, data_font, 10, 50, hdd_color, row1) + graphics.DrawText(canvas, data_font, 10, 60, hdd_color, row2) time.sleep(0.5) canvas = self.matrix.SwapOnVSync(canvas)