base_panel and printer optimizations
This commit is contained in:
parent
52fdb5d5ba
commit
eecb41df93
@ -28,6 +28,7 @@ class Printer:
|
|||||||
self.cameras = []
|
self.cameras = []
|
||||||
self.available_commands = {}
|
self.available_commands = {}
|
||||||
self.spoolman = False
|
self.spoolman = False
|
||||||
|
self.temp_devices = self.sensors = None
|
||||||
|
|
||||||
def reinit(self, printer_info, data):
|
def reinit(self, printer_info, data):
|
||||||
self.config = data['configfile']['config']
|
self.config = data['configfile']['config']
|
||||||
@ -45,6 +46,7 @@ class Printer:
|
|||||||
self.store_timeout = GLib.timeout_add_seconds(1, self._update_temp_store)
|
self.store_timeout = GLib.timeout_add_seconds(1, self._update_temp_store)
|
||||||
self.tempstore_size = 1200
|
self.tempstore_size = 1200
|
||||||
self.available_commands = {}
|
self.available_commands = {}
|
||||||
|
self.temp_devices = self.sensors = None
|
||||||
|
|
||||||
for x in self.config.keys():
|
for x in self.config.keys():
|
||||||
if x[:8] == "extruder":
|
if x[:8] == "extruder":
|
||||||
@ -201,15 +203,12 @@ class Printer:
|
|||||||
fans = []
|
fans = []
|
||||||
if self.config_section_exists("fan"):
|
if self.config_section_exists("fan"):
|
||||||
fans.append("fan")
|
fans.append("fan")
|
||||||
fan_types = ["controller_fan", "fan_generic", "heater_fan"]
|
for fan_type in ["controller_fan", "fan_generic", "heater_fan"]:
|
||||||
for fan_type in fan_types:
|
|
||||||
fans.extend(iter(self.get_config_section_list(f"{fan_type} ")))
|
fans.extend(iter(self.get_config_section_list(f"{fan_type} ")))
|
||||||
return fans
|
return fans
|
||||||
|
|
||||||
def get_output_pins(self):
|
def get_output_pins(self):
|
||||||
output_pins = []
|
return self.get_config_section_list("output_pin ")
|
||||||
output_pins.extend(iter(self.get_config_section_list("output_pin ")))
|
|
||||||
return output_pins
|
|
||||||
|
|
||||||
def get_gcode_macros(self):
|
def get_gcode_macros(self):
|
||||||
macros = []
|
macros = []
|
||||||
@ -235,9 +234,10 @@ class Printer:
|
|||||||
return self.get_config_section_list("temperature_sensor")
|
return self.get_config_section_list("temperature_sensor")
|
||||||
|
|
||||||
def get_filament_sensors(self):
|
def get_filament_sensors(self):
|
||||||
sensors = list(self.get_config_section_list("filament_switch_sensor "))
|
if self.sensors is None:
|
||||||
sensors.extend(iter(self.get_config_section_list("filament_motion_sensor ")))
|
self.sensors = list(self.get_config_section_list("filament_switch_sensor "))
|
||||||
return sensors
|
self.sensors.extend(iter(self.get_config_section_list("filament_motion_sensor ")))
|
||||||
|
return self.sensors
|
||||||
|
|
||||||
def get_probe(self):
|
def get_probe(self):
|
||||||
probe_types = ["probe", "bltouch", "smart_effector", "dockable_probe"]
|
probe_types = ["probe", "bltouch", "smart_effector", "dockable_probe"]
|
||||||
@ -372,12 +372,14 @@ class Printer:
|
|||||||
return temp
|
return temp
|
||||||
|
|
||||||
def get_temp_devices(self):
|
def get_temp_devices(self):
|
||||||
devices = [
|
if self.temp_devices is None:
|
||||||
device
|
devices = [
|
||||||
for device in self.tools
|
device
|
||||||
if not device.startswith('extruder_stepper')
|
for device in self.tools
|
||||||
]
|
if not device.startswith('extruder_stepper')
|
||||||
return devices + self.get_heaters() + self.get_temp_sensors() + self.get_temp_fans()
|
]
|
||||||
|
self.temp_devices = devices + self.get_heaters() + self.get_temp_sensors() + self.get_temp_fans()
|
||||||
|
return self.temp_devices
|
||||||
|
|
||||||
def get_tools(self):
|
def get_tools(self):
|
||||||
return self.tools
|
return self.tools
|
||||||
|
@ -217,20 +217,18 @@ class BasePanel(ScreenPanel):
|
|||||||
|
|
||||||
if action != "notify_status_update" or self._screen.printer is None:
|
if action != "notify_status_update" or self._screen.printer is None:
|
||||||
return
|
return
|
||||||
devices = (self._printer.get_temp_devices())
|
for device in self._printer.get_temp_devices():
|
||||||
if devices is not None:
|
temp = self._printer.get_dev_stat(device, "temperature")
|
||||||
for device in devices:
|
if temp is not None and device in self.labels:
|
||||||
temp = self._printer.get_dev_stat(device, "temperature")
|
name = ""
|
||||||
if temp is not None and device in self.labels:
|
if not (device.startswith("extruder") or device.startswith("heater_bed")):
|
||||||
name = ""
|
if self.titlebar_name_type == "full":
|
||||||
if not (device.startswith("extruder") or device.startswith("heater_bed")):
|
name = device.split()[1] if len(device.split()) > 1 else device
|
||||||
if self.titlebar_name_type == "full":
|
name = f'{self.prettify(name)}: '
|
||||||
name = device.split()[1] if len(device.split()) > 1 else device
|
elif self.titlebar_name_type == "short":
|
||||||
name = f'{self.prettify(name)}: '
|
name = device.split()[1] if len(device.split()) > 1 else device
|
||||||
elif self.titlebar_name_type == "short":
|
name = f"{name[:1].upper()}: "
|
||||||
name = device.split()[1] if len(device.split()) > 1 else device
|
self.labels[device].set_label(f"{name}{int(temp)}°")
|
||||||
name = f"{name[:1].upper()}: "
|
|
||||||
self.labels[device].set_label(f"{name}{int(temp)}°")
|
|
||||||
|
|
||||||
with suppress(Exception):
|
with suppress(Exception):
|
||||||
if self.current_extruder is not False and data["toolhead"]["extruder"] != self.current_extruder:
|
if self.current_extruder is not False and data["toolhead"]["extruder"] != self.current_extruder:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user