settings: Screen blanking settings
This commit is contained in:
1 parent
874dd509bf
commit
d6bf77870b
5 files changed
+60
-15
No files matched your search
+28
-1
@@ -10,6 +10,15 @@ from os import path
|
||||
|
||||
logger = logging.getLogger("KlipperScreen.config")
|
||||
|
||||
SCREEN_BLANKING_OPTIONS = [
|
||||
"300", #5 Minutes
|
||||
"900", #15 Minutes
|
||||
"1800", #30 Minutes
|
||||
"3600", #1 Hour
|
||||
"7200", #2 Hours
|
||||
"14400", #4 Hours
|
||||
]
|
||||
|
||||
class ConfigError(Exception):
|
||||
pass
|
||||
|
||||
@@ -19,8 +28,9 @@ class KlipperScreenConfig:
|
||||
do_not_edit_line = "#~# --- Do not edit below this line. This section is auto generated --- #~#"
|
||||
do_not_edit_prefix = "#~#"
|
||||
|
||||
def __init__(self, configfile, lang=None):
|
||||
def __init__(self, configfile, lang=None, screen=None):
|
||||
_ = lang.gettext
|
||||
_n = lang.ngettext
|
||||
|
||||
self.configurable_options = [
|
||||
{"invert_x": {"section": "main", "name": _("Invert X"), "type": "binary", "value": "False"}},
|
||||
@@ -32,10 +42,27 @@ class KlipperScreenConfig:
|
||||
{"name": _("Duration Only"), "value": "duration"},
|
||||
{"name": _("Filament Used"), "value": "filament"},
|
||||
{"name": _("Slicer"), "value": "slicer"}
|
||||
]}},
|
||||
{"screen_blanking": {"section": "main", "name": _("Screen Blanking Time"), "type": "dropdown",
|
||||
"value": "3600", "callback": screen.set_screenblanking_timeout, "options":[
|
||||
{"name": _("Off"), "value": "off"}
|
||||
]}}
|
||||
#{"": {"section": "main", "name": _(""), "type": ""}}
|
||||
]
|
||||
|
||||
index = self.configurable_options.index(
|
||||
[i for i in self.configurable_options if list(i)[0]=="screen_blanking"][0])
|
||||
for num in SCREEN_BLANKING_OPTIONS:
|
||||
hour = int(int(num)/3600)
|
||||
if hour > 0:
|
||||
name = str(hour) + " " + _n("hour","hours", hour)
|
||||
else:
|
||||
name = str(int(int(num)/60)) + " " + _("minutes")
|
||||
self.configurable_options[index]['screen_blanking']['options'].append({
|
||||
"name": name,
|
||||
"value": num
|
||||
})
|
||||
|
||||
self.default_config_path = "%s/ks_includes/%s" % (os.getcwd(), self.configfile_name)
|
||||
self.config = configparser.ConfigParser()
|
||||
self.config_path = self.get_config_file_location(configfile)
|
||||
|
||||
@@ -100,16 +100,12 @@ class Printer:
|
||||
self.set_dev_stat(x, "temperature", d["temperature"])
|
||||
|
||||
if "webhooks" in data or "idle_timeout" in data or "pause_resume" in data or "print_stats" in data:
|
||||
logger.debug("Evaluating state: %s" % data)
|
||||
logger.debug("State info: %s %s %s" % (self.data['webhooks'], self.data['idle_timeout'],
|
||||
self.data['print_stats']))
|
||||
self.evaluate_state()
|
||||
|
||||
def evaluate_state(self):
|
||||
wh_state = self.data['webhooks']['state'].lower() # possible values: startup, ready, shutdown, error
|
||||
idle_state = self.data['idle_timeout']['state'].lower() # possible values: Idle, printing, ready
|
||||
print_state = self.data['print_stats']['state'].lower() # possible values: complete, paused, printing, standby
|
||||
logger.debug("State evaluations: %s %s %s" % (wh_state, idle_state, print_state))
|
||||
|
||||
if wh_state == "ready":
|
||||
new_state = "ready"
|
||||
|
||||
Reference in new issue
Block a user