main and temp: less tempstore dependency
This commit is contained in:
parent
dc5741d605
commit
f52b52f76a
@ -72,10 +72,9 @@ class Printer:
|
||||
or x.startswith('heater_generic ') \
|
||||
or x.startswith('temperature_sensor ') \
|
||||
or x.startswith('temperature_fan '):
|
||||
self.devices[x] = {
|
||||
"temperature": 0,
|
||||
"target": 0
|
||||
}
|
||||
self.devices[x] = {"temperature": 0}
|
||||
if not x.startswith('temperature_sensor '):
|
||||
self.devices[x]["target"] = 0
|
||||
# Support for hiding devices by name
|
||||
name = x.split()[1] if len(x.split()) > 1 else x
|
||||
if not name.startswith("_"):
|
||||
@ -282,8 +281,8 @@ class Printer:
|
||||
if self.tempstore is not None:
|
||||
return list(self.tempstore)
|
||||
|
||||
def get_temp_store_device_has_target(self, device):
|
||||
return device in self.tempstore and "targets" in self.tempstore[device]
|
||||
def device_has_target(self, device):
|
||||
return "target" in self.devices[device] or (device in self.tempstore and "targets" in self.tempstore[device])
|
||||
|
||||
def get_temp_store(self, device, section=False, results=0):
|
||||
if device not in self.tempstore:
|
||||
|
@ -34,7 +34,6 @@ class HeaterGraph(Gtk.DrawingArea):
|
||||
"fill": fill,
|
||||
"rgb": rgb
|
||||
}})
|
||||
self.max_length = max(self.max_length, len(self.printer.get_temp_store(name, ev_type)))
|
||||
|
||||
@staticmethod
|
||||
def event_cb(da, ev):
|
||||
|
@ -50,7 +50,7 @@ class MainPanel(MenuPanel):
|
||||
self.layout.show_all()
|
||||
|
||||
def update_graph_visibility(self):
|
||||
if self.left_panel is None:
|
||||
if self.left_panel is None or not self._printer.get_temp_store_devices():
|
||||
return
|
||||
count = 0
|
||||
for device in self.devices:
|
||||
@ -131,7 +131,7 @@ class MainPanel(MenuPanel):
|
||||
|
||||
rgb = self._gtk.get_temp_color(dev_type)
|
||||
|
||||
can_target = self._printer.get_temp_store_device_has_target(device)
|
||||
can_target = self._printer.device_has_target(device)
|
||||
self.labels['da'].add_object(device, "temperatures", rgb, False, True)
|
||||
if can_target:
|
||||
self.labels['da'].add_object(device, "targets", rgb, True, False)
|
||||
@ -224,7 +224,7 @@ class MainPanel(MenuPanel):
|
||||
self.left_panel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
self.left_panel.add(scroll)
|
||||
|
||||
for d in self._printer.get_temp_store_devices():
|
||||
for d in (self._printer.get_tools() + self._printer.get_heaters()):
|
||||
self.add_device(d)
|
||||
|
||||
return self.left_panel
|
||||
|
@ -175,6 +175,8 @@ class TemperaturePanel(ScreenPanel):
|
||||
logging.info(f"Setting {heater} to {target}")
|
||||
|
||||
def update_graph_visibility(self):
|
||||
if not self._printer.get_temp_store_devices():
|
||||
return
|
||||
count = 0
|
||||
for device in self.devices:
|
||||
visible = self._config.get_config().getboolean(f"graph {self._screen.connected_printer}",
|
||||
@ -335,7 +337,7 @@ class TemperaturePanel(ScreenPanel):
|
||||
else:
|
||||
name.get_style_context().add_class("graph_label_hidden")
|
||||
|
||||
can_target = self._printer.get_temp_store_device_has_target(device)
|
||||
can_target = self._printer.device_has_target(device)
|
||||
self.labels['da'].add_object(device, "temperatures", rgb, False, True)
|
||||
if can_target:
|
||||
self.labels['da'].add_object(device, "targets", rgb, True, False)
|
||||
@ -455,7 +457,7 @@ class TemperaturePanel(ScreenPanel):
|
||||
popover.connect('closed', self.popover_closed)
|
||||
self.labels['popover'] = popover
|
||||
|
||||
for d in self._printer.get_temp_store_devices():
|
||||
for d in (self._printer.get_tools() + self._printer.get_heaters()):
|
||||
self.add_device(d)
|
||||
|
||||
return self.left_panel
|
||||
|
Loading…
x
Reference in New Issue
Block a user