Fix issue with stale confiugration and temperature panel unassigned var #155

This commit is contained in:
Jordan 2021-05-13 23:01:06 -04:00
parent 7e3b919c62
commit a1bd702a92
3 changed files with 19 additions and 12 deletions

View File

@ -139,12 +139,14 @@ class Printer:
return
logging.debug("Changing state from '%s' to '%s'" % (self.state, state))
prev_state = self.state
self.state = state
if self.state_callbacks[state] != None:
logging.debug("Adding callback for state: %s" % state)
Gdk.threads_add_idle(
GLib.PRIORITY_HIGH_IDLE,
self.state_callbacks[state]
self.state_callbacks[state],
prev_state
)
def configure_power_devices(self, data):

View File

@ -27,15 +27,16 @@ class TemperaturePanel(ScreenPanel):
self.heaters = []
i = 0
for x in self._printer.get_tools():
if i == 0:
primary_tool = x
tools = self._printer.get_tools()
for x in tools:
self.labels[x] = self._gtk.ToggleButtonImage("extruder-"+str(i), self._gtk.formatTemperatureString(0, 0))
if i == 0:
self.labels[x].set_active(True)
self.heaters.append(x)
i += 1
self.labels[primary_tool].get_style_context().add_class('button_active')
if len(tools) > 0:
self.labels[tools[0]].get_style_context().add_class('button_active')
add_heaters = self._printer.get_heaters()
for h in add_heaters:

View File

@ -509,7 +509,7 @@ class KlipperScreen(Gtk.Window):
self.printer_select_prepanel = self._cur_panels[0]
self.show_panel("printer_select","printer_select","Printer Select", 2)
def state_disconnected(self):
def state_disconnected(self, prev_state):
if "printer_select" in self._cur_panels:
self.printer_select_callbacks = [self.state_disconnected]
return
@ -518,7 +518,7 @@ class KlipperScreen(Gtk.Window):
logging.debug("### Going to disconnected")
self.printer_initializing(_("Klipper has disconnected"))
def state_error(self):
def state_error(self, prev_state):
if "printer_select" in self._cur_panels:
self.printer_select_callbacks = [self.state_error]
return
@ -538,11 +538,11 @@ class KlipperScreen(Gtk.Window):
_("Klipper has encountered an error.")
)
def state_paused(self):
def state_paused(self, prev_state):
if "job_status" not in self._cur_panels:
self.printer_printing()
def state_printing(self):
def state_printing(self, prev_state):
if "printer_select" in self._cur_panels:
self.printer_select_callbacks = [self.state_printing]
return
@ -552,7 +552,7 @@ class KlipperScreen(Gtk.Window):
else:
self.panels["job_status"].new_print()
def state_ready(self):
def state_ready(self, prev_state):
if "printer_select" in self._cur_panels:
self.printer_select_callbacks = [self.state_ready]
return
@ -560,9 +560,13 @@ class KlipperScreen(Gtk.Window):
# Do not return to main menu if completing a job, timeouts/user input will return
if "job_status" in self._cur_panels or "main_menu" in self._cur_panels:
return
if prev_state not in ['paused','printing']:
self.init_printer()
self.printer_ready()
def state_startup(self):
def state_startup(self, prev_state):
if "printer_select" in self._cur_panels:
self.printer_select_callbacks = [self.state_startup]
return
@ -570,7 +574,7 @@ class KlipperScreen(Gtk.Window):
_ = self.lang.gettext
self.printer_initializing(_("Klipper is attempting to start"))
def state_shutdown(self):
def state_shutdown(self, prev_state):
if "printer_select" in self._cur_panels:
self.printer_select_callbacks = [self.state_shutdown]
return