UI improvements: bordered feedback, centered titles, cloud animation, Tesla margins
This commit is contained in:
62
matrix.py
62
matrix.py
@@ -225,9 +225,16 @@ class Matrix64Display(SampleBase):
|
||||
time_font, data_font, small_font = fonts
|
||||
time_color, humidity_color, hdd_color, label_color, line_color = colors
|
||||
|
||||
for y in range(24, 44):
|
||||
# Black background
|
||||
for y in range(22, 46):
|
||||
graphics.DrawLine(canvas, 0, y, 63, y, graphics.Color(0, 0, 0))
|
||||
|
||||
# Border lines
|
||||
border_color = graphics.Color(60, 60, 60)
|
||||
graphics.DrawLine(canvas, 0, 22, 63, 22, border_color)
|
||||
graphics.DrawLine(canvas, 0, 45, 63, 45, border_color)
|
||||
|
||||
# Message
|
||||
msg_color = graphics.Color(0, 255, 100)
|
||||
msg_len = len(self.feedback_message) * 7
|
||||
x = (64 - msg_len) // 2
|
||||
@@ -241,8 +248,9 @@ class Matrix64Display(SampleBase):
|
||||
now = datetime.datetime.now()
|
||||
time_str = f"{now.hour:02d}:{now.minute:02d}:{now.second:02d}"
|
||||
|
||||
anim_offset = int(math.sin(self.animation_frame * 0.3) * 2)
|
||||
draw_weather_icon(canvas, anim_offset, 0, self.weather_desc)
|
||||
# Weather Icon (cloud moves, sun/icon stays fixed)
|
||||
cloud_offset = int(math.sin(self.animation_frame * 0.3) * 2)
|
||||
draw_weather_icon(canvas, 0, 0, self.weather_desc, cloud_offset)
|
||||
|
||||
graphics.DrawLine(canvas, 28, 0, 28, 25, line_color)
|
||||
|
||||
@@ -279,25 +287,29 @@ class Matrix64Display(SampleBase):
|
||||
time_font, data_font, small_font = fonts
|
||||
time_color, humidity_color, hdd_color, label_color, line_color = colors
|
||||
|
||||
graphics.DrawText(canvas, data_font, 4, 8, time_color, "Discos")
|
||||
# Centered title
|
||||
title = "Discos"
|
||||
title_len = len(title) * 5
|
||||
title_x = (64 - title_len) // 2
|
||||
graphics.DrawText(canvas, data_font, title_x, 8, time_color, title)
|
||||
graphics.DrawLine(canvas, 0, 10, 63, 10, line_color)
|
||||
|
||||
if self.hdd_temps and len(self.hdd_temps) > 1:
|
||||
temps = [(i+1, int(t[0])) for i, t in enumerate(self.hdd_temps[1:7]) if t]
|
||||
|
||||
y = 20
|
||||
y = 22
|
||||
for idx, (num, temp_val) in enumerate(temps[:3]):
|
||||
temp_color = get_hdd_color(temp_val)
|
||||
graphics.DrawText(canvas, data_font, 0, y, label_color, f"{num}:")
|
||||
graphics.DrawText(canvas, data_font, 14, y, temp_color, f"{temp_val}C")
|
||||
y += 10
|
||||
graphics.DrawText(canvas, data_font, 2, y, label_color, f"{num}:")
|
||||
graphics.DrawText(canvas, data_font, 16, y, temp_color, f"{temp_val}C")
|
||||
y += 11
|
||||
|
||||
y = 20
|
||||
y = 22
|
||||
for idx, (num, temp_val) in enumerate(temps[3:6]):
|
||||
temp_color = get_hdd_color(temp_val)
|
||||
graphics.DrawText(canvas, data_font, 34, y, label_color, f"{num}:")
|
||||
graphics.DrawText(canvas, data_font, 48, y, temp_color, f"{temp_val}C")
|
||||
y += 10
|
||||
y += 11
|
||||
|
||||
if self.auto_cycle:
|
||||
graphics.DrawText(canvas, small_font, 58, 62, label_color, "A")
|
||||
@@ -323,8 +335,9 @@ class Matrix64Display(SampleBase):
|
||||
|
||||
graphics.DrawLine(canvas, 0, 30, 63, 30, line_color)
|
||||
|
||||
anim_offset = int(math.sin(self.animation_frame * 0.3) * 2)
|
||||
draw_weather_icon(canvas, 4 + anim_offset, 34, self.weather_desc)
|
||||
# Weather icon (cloud animates, position fixed)
|
||||
cloud_offset = int(math.sin(self.animation_frame * 0.3) * 2)
|
||||
draw_weather_icon(canvas, 4, 34, self.weather_desc, cloud_offset)
|
||||
|
||||
if self.temperature is not None:
|
||||
temp_color = get_temperature_color(self.temperature)
|
||||
@@ -338,25 +351,28 @@ class Matrix64Display(SampleBase):
|
||||
time_font, data_font, small_font = fonts
|
||||
time_color, humidity_color, hdd_color, label_color, line_color = colors
|
||||
|
||||
# Title
|
||||
graphics.DrawText(canvas, data_font, 14, 8, time_color, "Tesla")
|
||||
# Centered title
|
||||
title = "Tesla"
|
||||
title_len = len(title) * 5
|
||||
title_x = (64 - title_len) // 2
|
||||
graphics.DrawText(canvas, data_font, title_x, 8, time_color, title)
|
||||
graphics.DrawLine(canvas, 0, 10, 63, 10, line_color)
|
||||
|
||||
if self.tesla:
|
||||
# Battery
|
||||
# Battery (with margin)
|
||||
battery = self.tesla.get("battery")
|
||||
if battery is not None:
|
||||
battery_color = graphics.Color(0, 255, 80) if battery > 20 else graphics.Color(255, 50, 50)
|
||||
graphics.DrawText(canvas, data_font, 0, 22, label_color, "Bat:")
|
||||
graphics.DrawText(canvas, time_font, 24, 24, battery_color, f"{battery}%")
|
||||
graphics.DrawText(canvas, data_font, 4, 24, label_color, "Bat")
|
||||
graphics.DrawText(canvas, time_font, 26, 26, battery_color, f"{battery}%")
|
||||
|
||||
# Range
|
||||
# Range (with margin)
|
||||
range_km = self.tesla.get("range")
|
||||
if range_km is not None:
|
||||
graphics.DrawText(canvas, data_font, 0, 36, label_color, "Km:")
|
||||
graphics.DrawText(canvas, time_font, 20, 38, time_color, f"{range_km}")
|
||||
graphics.DrawText(canvas, data_font, 4, 38, label_color, "Km")
|
||||
graphics.DrawText(canvas, time_font, 22, 40, time_color, f"{range_km}")
|
||||
|
||||
# Status
|
||||
# Status (centered)
|
||||
charging = self.tesla.get("charging", False)
|
||||
plugged = self.tesla.get("plugged", False)
|
||||
|
||||
@@ -370,7 +386,9 @@ class Matrix64Display(SampleBase):
|
||||
status = "Listo"
|
||||
status_color = graphics.Color(100, 100, 100)
|
||||
|
||||
graphics.DrawText(canvas, data_font, 4, 54, status_color, status)
|
||||
status_len = len(status) * 5
|
||||
status_x = (64 - status_len) // 2
|
||||
graphics.DrawText(canvas, data_font, status_x, 56, status_color, status)
|
||||
else:
|
||||
graphics.DrawText(canvas, data_font, 4, 32, label_color, "Sin datos")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user