allow 2 different screen timeouts, one while printing the other if not
closes #311
This commit is contained in:
parent
629ca41b88
commit
750a7ee0b5
@ -161,7 +161,7 @@ class KlipperScreenConfig:
|
||||
'show_heater_power', "show_scroll_steppers", "auto_open_extrude"
|
||||
)
|
||||
strs = (
|
||||
'default_printer', 'language', 'print_sort_dir', 'theme', 'screen_blanking', 'font_size',
|
||||
'default_printer', 'language', 'print_sort_dir', 'theme', 'screen_blanking_printing', 'font_size',
|
||||
'print_estimate_method', 'screen_blanking', "screen_on_devices", "screen_off_devices", 'print_view',
|
||||
)
|
||||
numbers = (
|
||||
@ -266,6 +266,13 @@ class KlipperScreenConfig:
|
||||
"value": "3600", "callback": screen.set_screenblanking_timeout, "options": [
|
||||
{"name": _("Never"), "value": "off"}]
|
||||
}},
|
||||
{"screen_blanking_printing": {
|
||||
"section": "main", "name": _("Screen Power Off Time") + " (" + _("Printing") + ")",
|
||||
"type": "dropdown",
|
||||
"tooltip": _("Timeout for screen black-out or power-off during printing"),
|
||||
"value": "3600", "callback": screen.set_screenblanking_printing_timeout, "options": [
|
||||
{"name": _("Never"), "value": "off"}]
|
||||
}},
|
||||
{"24htime": {"section": "main", "name": _("24 Hour Time"), "type": "binary",
|
||||
"tooltip": _("Disable for 12hs with am / pm"),
|
||||
"value": "True"}},
|
||||
@ -326,16 +333,26 @@ class KlipperScreenConfig:
|
||||
for theme in themes:
|
||||
theme_opt.append({"name": theme, "value": theme})
|
||||
|
||||
index = self.configurable_options.index(
|
||||
[i for i in self.configurable_options if list(i)[0] == "screen_blanking"][0])
|
||||
i1 = i2 = None
|
||||
for i, option in enumerate(self.configurable_options):
|
||||
if list(option)[0] == "screen_blanking":
|
||||
i1 = i
|
||||
elif list(option)[0] == "screen_blanking_printing":
|
||||
i2 = i
|
||||
if i1 and i2:
|
||||
break
|
||||
for num in SCREEN_BLANKING_OPTIONS:
|
||||
hour = num // 3600
|
||||
minute = num / 60
|
||||
minute = num // 60
|
||||
if hour > 0:
|
||||
name = f'{hour} ' + ngettext("hour", "hours", hour)
|
||||
name = f'{hour} ' + gettext.ngettext("hour", "hours", hour)
|
||||
else:
|
||||
name = f'{minute:.0f} ' + ngettext("minute", "minutes", minute)
|
||||
self.configurable_options[index]['screen_blanking']['options'].append({
|
||||
name = f'{minute} ' + gettext.ngettext("minute", "minutes", minute)
|
||||
self.configurable_options[i1]['screen_blanking']['options'].append({
|
||||
"name": name,
|
||||
"value": f"{num}"
|
||||
})
|
||||
self.configurable_options[i2]['screen_blanking_printing']['options'].append({
|
||||
"name": name,
|
||||
"value": f"{num}"
|
||||
})
|
||||
|
@ -159,7 +159,7 @@ class Printer:
|
||||
self.state = state
|
||||
if self.state_callbacks[state] is not None:
|
||||
logging.debug(f"Adding callback for state: {state}")
|
||||
GLib.idle_add(self.state_cb, self.state_callbacks[state])
|
||||
GLib.idle_add(self.state_cb, state, self.state_callbacks[state])
|
||||
|
||||
def configure_power_devices(self, data):
|
||||
self.power_devices = {}
|
||||
|
29
screen.py
29
screen.py
@ -70,11 +70,6 @@ def set_text_direction(lang=None):
|
||||
return True
|
||||
|
||||
|
||||
def state_execute(callback):
|
||||
callback()
|
||||
return False
|
||||
|
||||
|
||||
class KlipperScreen(Gtk.Window):
|
||||
""" Class for creating a screen for Klipper via HDMI """
|
||||
_cur_panels = []
|
||||
@ -188,6 +183,15 @@ class KlipperScreen(Gtk.Window):
|
||||
+ _("Ended official support in June 2023") + "\n"
|
||||
+ _("KlipperScreen will drop support in June 2024"), 2)
|
||||
|
||||
def state_execute(self, state, callback):
|
||||
self.close_screensaver()
|
||||
if state in ("printing", "paused"):
|
||||
self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking_printing'))
|
||||
else:
|
||||
self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking'))
|
||||
callback()
|
||||
return False
|
||||
|
||||
def initial_connection(self):
|
||||
self.printers = self._config.get_printers()
|
||||
state_callbacks = {
|
||||
@ -200,7 +204,7 @@ class KlipperScreen(Gtk.Window):
|
||||
"shutdown": self.state_shutdown
|
||||
}
|
||||
for printer in self.printers:
|
||||
printer["data"] = Printer(state_execute, state_callbacks)
|
||||
printer["data"] = Printer(self.state_execute, state_callbacks)
|
||||
default_printer = self._config.get_main_config().get('default_printer')
|
||||
logging.debug(f"Default printer: {default_printer}")
|
||||
if [True for p in self.printers if default_printer in p]:
|
||||
@ -618,7 +622,14 @@ class KlipperScreen(Gtk.Window):
|
||||
def set_dpms(self, use_dpms):
|
||||
self.use_dpms = use_dpms
|
||||
logging.info(f"DPMS set to: {self.use_dpms}")
|
||||
self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking'))
|
||||
if self.printer.state in ("printing", "paused"):
|
||||
self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking_printing'))
|
||||
else:
|
||||
self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking'))
|
||||
|
||||
def set_screenblanking_printing_timeout(self, time):
|
||||
if self.printer.state in ("printing", "paused"):
|
||||
self.set_screenblanking_timeout(time)
|
||||
|
||||
def set_screenblanking_timeout(self, time):
|
||||
if not self.wayland:
|
||||
@ -673,13 +684,11 @@ class KlipperScreen(Gtk.Window):
|
||||
def state_disconnected(self):
|
||||
logging.debug("### Going to disconnected")
|
||||
self.printer.stop_tempstore_updates()
|
||||
self.close_screensaver()
|
||||
self.initialized = False
|
||||
self.reinit_count = 0
|
||||
self._init_printer(_("Klipper has disconnected"), remove=True)
|
||||
|
||||
def state_error(self):
|
||||
self.close_screensaver()
|
||||
msg = _("Klipper has encountered an error.") + "\n"
|
||||
state = self.printer.get_stat("webhooks", "state_message")
|
||||
if "FIRMWARE_RESTART" in state:
|
||||
@ -694,7 +703,6 @@ class KlipperScreen(Gtk.Window):
|
||||
self.show_panel("extrude", _("Extrude"))
|
||||
|
||||
def state_printing(self):
|
||||
self.close_screensaver()
|
||||
for dialog in self.dialogs:
|
||||
self.gtk.remove_dialog(dialog)
|
||||
self.show_panel("job_status", _("Printing"), remove_all=True)
|
||||
@ -714,7 +722,6 @@ class KlipperScreen(Gtk.Window):
|
||||
self.printer_initializing(_("Klipper is attempting to start"))
|
||||
|
||||
def state_shutdown(self):
|
||||
self.close_screensaver()
|
||||
self.printer.stop_tempstore_updates()
|
||||
msg = self.printer.get_stat("webhooks", "state_message")
|
||||
msg = msg if "ready" not in msg else ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user