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