From 80668faa3eacf165d63ac62bf47ca542409c9860 Mon Sep 17 00:00:00 2001 From: alfrix Date: Thu, 2 May 2024 15:02:51 -0300 Subject: [PATCH] Optimize: update temp avoid extra casting --- ks_includes/screen_panel.py | 6 +++--- panels/base_panel.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ks_includes/screen_panel.py b/ks_includes/screen_panel.py index c987984f..b5fb5401 100644 --- a/ks_includes/screen_panel.py +++ b/ks_includes/screen_panel.py @@ -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) diff --git a/panels/base_panel.py b/panels/base_panel.py index 0830adb3..f7952d63 100644 --- a/panels/base_panel.py +++ b/panels/base_panel.py @@ -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):