Optimize: update temp avoid extra casting

This commit is contained in:
alfrix 2024-05-02 15:02:51 -03:00
parent 8c9e2fd4c6
commit 80668faa3e
2 changed files with 4 additions and 4 deletions

View File

@ -174,9 +174,9 @@ class ScreenPanel:
show_power = show_target and self._show_heater_power and power is not None
new_label_text = f"{int(temp):3}"
new_label_text = f"{temp:.0f}"
if show_target:
new_label_text += f"/{int(target)}"
new_label_text += f"/{target:.0f}"
if dev not in self.devices:
new_label_text += "°"
if show_power:
@ -184,7 +184,7 @@ class ScreenPanel:
# The label should wrap, but it doesn't work
# this is a workaround
new_label_text += "\n "
new_label_text += f" {int(power * 100):3}%"
new_label_text += f" {power * 100:3.0f}%"
if dev in self.labels:
self.labels[dev].set_label(new_label_text)

View File

@ -265,7 +265,7 @@ class BasePanel(ScreenPanel):
elif self.titlebar_name_type == "short":
name = device.split()[1] if len(device.split()) > 1 else device
name = f"{name[:1].upper()}: "
self.labels[device].set_label(f"{name}{int(temp)}°")
self.labels[device].set_label(f"{name}{temp:.0f}°")
if (self.current_extruder and 'toolhead' in data and 'extruder' in data['toolhead']
and data["toolhead"]["extruder"] != self.current_extruder):