Add separator lines, bigger HDD font, push right

This commit is contained in:
Joan
2025-12-31 12:44:50 +01:00
parent 9055c13af7
commit ece26b44d3

View File

@@ -131,43 +131,55 @@ class Matrix64Display(SampleBase):
canvas.Clear() canvas.Clear()
# Line color for separators
line_color = graphics.Color(40, 40, 40)
# === Weather Icon (top-left, 24x24) === # === Weather Icon (top-left, 24x24) ===
draw_weather_icon(canvas, 0, 0, self.weather_desc) draw_weather_icon(canvas, 0, 0, self.weather_desc)
# === Vertical separator between weather and HDD ===
graphics.DrawLine(canvas, 25, 0, 25, 24, line_color)
# === HDD Temps (top-right, 3 rows of 2) === # === HDD Temps (top-right, 5x8 font, 3 rows of 2) ===
if self.hdd_temps and len(self.hdd_temps) > 1: if self.hdd_temps and len(self.hdd_temps) > 1:
temps = [str(int(t[0])) for t in self.hdd_temps[1:] if t] temps = [str(int(t[0])) for t in self.hdd_temps[1:] if t]
if len(temps) >= 2: if len(temps) >= 2:
row1 = " ".join(temps[:2]) row1 = " ".join(temps[:2])
graphics.DrawText(canvas, small_font, 28, 6, hdd_color, row1) graphics.DrawText(canvas, data_font, 34, 8, hdd_color, row1)
if len(temps) >= 4: if len(temps) >= 4:
row2 = " ".join(temps[2:4]) row2 = " ".join(temps[2:4])
graphics.DrawText(canvas, small_font, 28, 12, hdd_color, row2) graphics.DrawText(canvas, data_font, 34, 16, hdd_color, row2)
if len(temps) > 4: if len(temps) > 4:
row3 = " ".join(temps[4:6]) row3 = " ".join(temps[4:6])
graphics.DrawText(canvas, small_font, 28, 18, hdd_color, row3) graphics.DrawText(canvas, data_font, 34, 24, hdd_color, row3)
# === Clock (centered vertically, y=38) === # === Horizontal line above clock ===
graphics.DrawLine(canvas, 0, 26, 63, 26, line_color)
# === Clock (centered) ===
time_x = (64 - len(time_str) * 7) // 2 time_x = (64 - len(time_str) * 7) // 2
graphics.DrawText(canvas, time_font, time_x, 38, time_color, time_str) graphics.DrawText(canvas, time_font, time_x, 38, time_color, time_str)
# === Outdoor: Out + temp + humidity (y=50, 5x8 font) === # === Horizontal line below clock ===
graphics.DrawText(canvas, data_font, 0, 50, label_color, "Out") graphics.DrawLine(canvas, 0, 42, 63, 42, line_color)
# === Outdoor: Out + temp + humidity (y=52) ===
graphics.DrawText(canvas, data_font, 0, 52, label_color, "Out")
if self.temperature is not None: if self.temperature is not None:
temp_str = format_temp(self.temperature) temp_str = format_temp(self.temperature)
temp_color = get_temperature_color(self.temperature) temp_color = get_temperature_color(self.temperature)
graphics.DrawText(canvas, data_font, 20, 50, temp_color, temp_str) graphics.DrawText(canvas, data_font, 20, 52, temp_color, temp_str)
if self.humidity is not None: if self.humidity is not None:
graphics.DrawText(canvas, data_font, 48, 50, humidity_color, format_humidity(self.humidity)) graphics.DrawText(canvas, data_font, 48, 52, humidity_color, format_humidity(self.humidity))
# === Indoor: In + temp + humidity (y=60, 5x8 font) === # === Indoor: In + temp + humidity (y=62) ===
graphics.DrawText(canvas, data_font, 0, 60, label_color, "In") graphics.DrawText(canvas, data_font, 0, 62, label_color, "In")
if self.interior_temperature is not None: if self.interior_temperature is not None:
temp_str = format_temp(self.interior_temperature) temp_str = format_temp(self.interior_temperature)
temp_color = get_temperature_color(self.interior_temperature) temp_color = get_temperature_color(self.interior_temperature)
graphics.DrawText(canvas, data_font, 20, 60, temp_color, temp_str) graphics.DrawText(canvas, data_font, 20, 62, temp_color, temp_str)
if self.interior_humidity is not None: if self.interior_humidity is not None:
graphics.DrawText(canvas, data_font, 48, 60, humidity_color, format_humidity(self.interior_humidity)) graphics.DrawText(canvas, data_font, 48, 62, humidity_color, format_humidity(self.interior_humidity))
time.sleep(0.5) time.sleep(0.5)
canvas = self.matrix.SwapOnVSync(canvas) canvas = self.matrix.SwapOnVSync(canvas)