From bf8077e2c0a6f20ec4f06e3add14f9c5c802207f Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Wed, 13 Dec 2023 12:55:39 +0000 Subject: [PATCH 01/13] STEAPP-841: added the raw command --- klippy/extras/wizard/__init__.py | 21 ++++++ klippy/extras/wizard/wizard.py | 113 +++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 klippy/extras/wizard/__init__.py create mode 100644 klippy/extras/wizard/wizard.py diff --git a/klippy/extras/wizard/__init__.py b/klippy/extras/wizard/__init__.py new file mode 100644 index 000000000000..270099b05ff7 --- /dev/null +++ b/klippy/extras/wizard/__init__.py @@ -0,0 +1,21 @@ +# Package definition for the extras/display directory +# +# Copyright (C) 2018 Kevin O'Connor +# +# This file may be distributed under the terms of the GNU GPLv3 license. +from . import wizard + +# def load_config(config): +# return wizard.load_config(config) + +def load_config_prefix(config): + # if not config.has_section('display'): + # raise config.error( + # "0018: A primary [display] section must be defined in printer.cfg " + # "to use auxilary displays") + # name = config.get_name().split()[-1] + # if name == "display": + # raise config.error( + # "0019: Section name [display display] is not valid. " + # "Please choose a different postfix.") + return wizard.load_config_prefix(config) diff --git a/klippy/extras/wizard/wizard.py b/klippy/extras/wizard/wizard.py new file mode 100644 index 000000000000..d44ca3abf110 --- /dev/null +++ b/klippy/extras/wizard/wizard.py @@ -0,0 +1,113 @@ +import traceback, logging, ast, copy, json +import jinja2 + + +class Wizard: + def __init__(self, config): + if len(config.get_name().split()) > 2: + raise config.error( + "Name of section '%s' contains illegal whitespace" + % (config.get_name())) + self.name = config.get_name().split()[1] + # self.alias = self.name.upper() + self.printer = printer = config.get_printer() + # gcode_macro = printer.load_object(config, 'gcode_macro') + # self.template = gcode_macro.load_template(config, 'gcode') + self.gcode = printer.lookup_object('gcode') + self.cmd_desc = config.get("description", "G-Code macro") + # self.gcode.register_command(self.alias, self.cmd, + # desc=self.cmd_desc) + self.gcode.register_mux_command("SET_WIZARD_VARIABLE", "WIZARD", + self.name, self.cmd_SET_WIZARD_VARIABLE, + desc=self.cmd_SET_WIZARD_VARIABLE_help) + self.gcode.register_mux_command("SET_WIZARD_ENABLE", "WIZARD", + self.name, self.cmd_SET_WIZARD_ENABLE, + desc=self.cmd_SET_WIZARD_ENABLE_help) + self.gcode.register_mux_command("SET_WIZARD_STEP", "WIZARD", + self.name, self.cmd_SET_WIZARD_STEP, + desc=self.cmd_SET_WIZARD_STEP_help) + self.gcode.register_mux_command("RESET_WIZARD", "WIZARD", + self.name, self.cmd_RESET_WIZARD, + desc=self.cmd_RESET_WIZARD_help) + self.in_script = False + self.variables = {} + self._variables_bk = {} + prefix = 'variable_' + for option in config.get_prefix_options(prefix): + try: + literal = ast.literal_eval(config.get(option)) + json.dumps(literal, separators=(',', ':')) + self.variables[option[len(prefix):]] = literal + self._variables_bk[option[len(prefix):]] = literal + except (SyntaxError, TypeError, ValueError) as e: + raise config.error( + "Option '%s' in section '%s' is not a valid literal: %s" % ( + option, config.get_name(), e)) + self.image = config.get('image', 'image_path') + self.type = config.getlists('type', []) + self.steps = config.getlists('steps', 'image_path') + self.current_step = self.steps[0] + self.enabled = False + self.error = '' + + def get_status(self, eventtime): + state = {'current_step': self.current_step, + 'enabled': self.enabled, + 'error': self.error, + 'variables': self.variables, + # for debug + 'self.steps': self.steps} + return state + + cmd_SET_WIZARD_VARIABLE_help = "Set the value of a wizard variable to wizard" + def cmd_SET_WIZARD_VARIABLE(self, gcmd): + variable = gcmd.get('VARIABLE') + value = gcmd.get('VALUE') + if variable not in self.variables: + raise gcmd.error("Unknown wizard variable '%s'" % (variable,)) + try: + literal = ast.literal_eval(value) + json.dumps(literal, separators=(',', ':')) + except (SyntaxError, TypeError, ValueError) as e: + raise gcmd.error("Unable to parse '%s' as a literal: %s" % + (value, e)) + v = dict(self.variables) + v[variable] = literal + self.variables = v + + cmd_SET_WIZARD_ENABLE_help = "Set the enable to WIZARD" + def cmd_SET_WIZARD_ENABLE(self, gcmd): + self.enabled = True if gcmd.get_int('ENABLE', self.enabled) else False + self.error = gcmd.get('ERROR', self.error) + + cmd_SET_WIZARD_STEP_help = "Set the step to WIZARD" + def cmd_SET_WIZARD_STEP(self, gcmd): + step = gcmd.get('STEP') + if step not in self.steps: + raise gcmd.error("Unknown step: '%s'" % step) + self.current_step = step + + cmd_RESET_WIZARD_help = "Set the enable to WIZARD" + def cmd_RESET_WIZARD(self, gcmd): + self.error = '' + self.enabled = False + self.current_step = self.steps[0] + self.variables = dict(self._variables_bk) + + # def cmd(self, gcmd): + # self.enabled = True + # if self.in_script: + # raise gcmd.error("Macro %s called recursively" % (self.alias,)) + # kwparams = dict(self.variables) + # kwparams.update(self.template.create_template_context()) + # kwparams['params'] = gcmd.get_command_parameters() + # kwparams['rawparams'] = gcmd.get_raw_command_parameters() + # self.in_script = True + # try: + # self.template.run_gcode_from_command(kwparams) + # finally: + # self.in_script = False + # self.enabled = False + +def load_config_prefix(config): + return Wizard(config) From 39369039711a4843483e877d350e9c340e4a2730 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Thu, 14 Dec 2023 06:37:28 +0000 Subject: [PATCH 02/13] STEAPP-842: added raw code --- klippy/extras/wizard/wizard.py | 7 ++-- klippy/extras/wizard/wizard_step.py | 60 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 klippy/extras/wizard/wizard_step.py diff --git a/klippy/extras/wizard/wizard.py b/klippy/extras/wizard/wizard.py index d44ca3abf110..143b86fc9103 100644 --- a/klippy/extras/wizard/wizard.py +++ b/klippy/extras/wizard/wizard.py @@ -29,7 +29,7 @@ def __init__(self, config): self.gcode.register_mux_command("RESET_WIZARD", "WIZARD", self.name, self.cmd_RESET_WIZARD, desc=self.cmd_RESET_WIZARD_help) - self.in_script = False + # self.in_script = False self.variables = {} self._variables_bk = {} prefix = 'variable_' @@ -56,7 +56,8 @@ def get_status(self, eventtime): 'error': self.error, 'variables': self.variables, # for debug - 'self.steps': self.steps} + 'self.steps': self.steps, + 'self.type': self.type} return state cmd_SET_WIZARD_VARIABLE_help = "Set the value of a wizard variable to wizard" @@ -87,7 +88,7 @@ def cmd_SET_WIZARD_STEP(self, gcmd): raise gcmd.error("Unknown step: '%s'" % step) self.current_step = step - cmd_RESET_WIZARD_help = "Set the enable to WIZARD" + cmd_RESET_WIZARD_help = "Reset state the wizard" def cmd_RESET_WIZARD(self, gcmd): self.error = '' self.enabled = False diff --git a/klippy/extras/wizard/wizard_step.py b/klippy/extras/wizard/wizard_step.py new file mode 100644 index 000000000000..93bfc01ff5bb --- /dev/null +++ b/klippy/extras/wizard/wizard_step.py @@ -0,0 +1,60 @@ +import traceback, logging, ast, copy, json +import jinja2 + + +class WizardStep: + def __init__(self, config): + if len(config.get_name().split()) > 2: + raise config.error( + "Name of section '%s' contains illegal whitespace" + % (config.get_name())) + name = config.get_name().split()[1] + self.alias = name.upper() + self.printer = printer = config.get_printer() + gcode_macro = printer.load_object(config, 'gcode_macro') + self.template_action = gcode_macro.load_template(config, 'action_gcode') + self.template_cancel = gcode_macro.load_template(config, 'cancel_gcode') + self.gcode = printer.lookup_object('gcode') + self.cmd_desc = config.get("description", "G-Code macro") + self.gcode.register_command(self.alias, self.cmd, + desc=self.cmd_desc) + self.gcode.register_mux_command("EXECUTE_WIZARD_STEP", "STEP", + name, self.cmd_EXECUTE_WIZARD_STEP, + desc=self.cmd_EXECUTE_WIZARD_STEP_help) + self.gcode.register_mux_command("CANCEL_WIZARD_STEP", "STEP", + name, self.cmd_CANCEL_WIZARD_STEP, + desc=self.cmd_CANCEL_WIZARD_STEP_help) + self.in_script = False + + self.image = config.get('image', 'image_path') + self.landscape = config.getboolean('landscape', False) + self.description = config.get('description', '') + self.warning = config.get('warning', '') + self.info = config.get('info', '') + self.countdown = config.getint('countdown', 0) + + cmd_EXECUTE_WIZARD_STEP_help = "Set the enable to WIZARD" + def cmd_EXECUTE_WIZARD_STEP(self, gcmd): + gcmd.respond_info('-----EXECUTE_WIZARD_STEP') + + cmd_CANCEL_WIZARD_STEP_help = "Set the step to WIZARD" + def cmd_CANCEL_WIZARD_STEP(self, gcmd): + gcmd.respond_info('-----EXECUTE_WIZARD_STEP') + + def cmd(self, gcmd): + if self.in_script: + raise gcmd.error("Macro %s called recursively" % (self.alias,)) + kwparams = {} + kwparams.update(self.template_action.create_template_context()) + kwparams['params'] = gcmd.get_command_parameters() + kwparams['rawparams'] = gcmd.get_raw_command_parameters() + self.in_script = True + try: + self.template_action.run_gcode_from_command(kwparams) + finally: + self.template_cancel.run_gcode_from_command(kwparams) + self.in_script = False + +def load_config_prefix(config): + return WizardStep(config) + From 59230bea1bf61400975438f3df46af36bcfc1976 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Thu, 14 Dec 2023 13:01:48 +0000 Subject: [PATCH 03/13] STEAPP-842: added wizard_step_buttons --- klippy/extras/wizard/__init__.py | 16 ++++-- klippy/extras/wizard/wizard.py | 4 ++ klippy/extras/wizard/wizard_step.py | 59 ++++++++++++++-------- klippy/extras/wizard/wizard_step_button.py | 37 ++++++++++++++ klippy/klippy.py | 2 + 5 files changed, 95 insertions(+), 23 deletions(-) create mode 100644 klippy/extras/wizard/wizard_step_button.py diff --git a/klippy/extras/wizard/__init__.py b/klippy/extras/wizard/__init__.py index 270099b05ff7..3c6fb59f5e61 100644 --- a/klippy/extras/wizard/__init__.py +++ b/klippy/extras/wizard/__init__.py @@ -3,13 +3,23 @@ # Copyright (C) 2018 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. -from . import wizard +from . import wizard, wizard_step, wizard_step_button # def load_config(config): # return wizard.load_config(config) def load_config_prefix(config): - # if not config.has_section('display'): + name = config.get_name() + if 'wizard_step ' in name: + return wizard_step.load_config_prefix(config) + elif 'wizard ' in name: + return wizard.load_config_prefix(config) + elif 'wizard_step_button ' in name: + return wizard_step_button.load_config_prefix(config) + else: + raise config.error( + "do not parse section") + # elif config.has_section('wizard_step_slider'): # raise config.error( # "0018: A primary [display] section must be defined in printer.cfg " # "to use auxilary displays") @@ -18,4 +28,4 @@ def load_config_prefix(config): # raise config.error( # "0019: Section name [display display] is not valid. " # "Please choose a different postfix.") - return wizard.load_config_prefix(config) + # return wizard.load_config_prefix(config) diff --git a/klippy/extras/wizard/wizard.py b/klippy/extras/wizard/wizard.py index 143b86fc9103..162d083f0a71 100644 --- a/klippy/extras/wizard/wizard.py +++ b/klippy/extras/wizard/wizard.py @@ -50,6 +50,10 @@ def __init__(self, config): self.enabled = False self.error = '' + def update_status(self, current_step): + logging.info('-----------------update status %s' % current_step) + self.current_step = current_step + def get_status(self, eventtime): state = {'current_step': self.current_step, 'enabled': self.enabled, diff --git a/klippy/extras/wizard/wizard_step.py b/klippy/extras/wizard/wizard_step.py index 93bfc01ff5bb..9ec80bd87ab9 100644 --- a/klippy/extras/wizard/wizard_step.py +++ b/klippy/extras/wizard/wizard_step.py @@ -8,53 +8,72 @@ def __init__(self, config): raise config.error( "Name of section '%s' contains illegal whitespace" % (config.get_name())) - name = config.get_name().split()[1] - self.alias = name.upper() + full_name = config.get_name().split() + self.name = full_name[1].upper() + self.in_script = False + # load objects self.printer = printer = config.get_printer() gcode_macro = printer.load_object(config, 'gcode_macro') + self.gcode = printer.lookup_object('gcode') + # create template self.template_action = gcode_macro.load_template(config, 'action_gcode') self.template_cancel = gcode_macro.load_template(config, 'cancel_gcode') - self.gcode = printer.lookup_object('gcode') + # get params from config self.cmd_desc = config.get("description", "G-Code macro") - self.gcode.register_command(self.alias, self.cmd, - desc=self.cmd_desc) - self.gcode.register_mux_command("EXECUTE_WIZARD_STEP", "STEP", - name, self.cmd_EXECUTE_WIZARD_STEP, - desc=self.cmd_EXECUTE_WIZARD_STEP_help) - self.gcode.register_mux_command("CANCEL_WIZARD_STEP", "STEP", - name, self.cmd_CANCEL_WIZARD_STEP, - desc=self.cmd_CANCEL_WIZARD_STEP_help) - self.in_script = False - self.image = config.get('image', 'image_path') self.landscape = config.getboolean('landscape', False) self.description = config.get('description', '') self.warning = config.get('warning', '') self.info = config.get('info', '') self.countdown = config.getint('countdown', 0) + # register gcode commands + key = 'STEP' + # key = full_name[0].split('_')[-1].upper() + self.gcode.register_mux_command("EXECUTE_WIZARD_STEP", key, + self.name, self.cmd_EXECUTE_WIZARD_STEP, + desc=self.cmd_EXECUTE_WIZARD_STEP_help) + self.gcode.register_mux_command("CANCEL_WIZARD_STEP", key, + self.name, self.cmd_CANCEL_WIZARD_STEP, + desc=self.cmd_CANCEL_WIZARD_STEP_help) + # self.gcode.register_command(self.alias, self.cmd, + # desc=self.cmd_desc) - cmd_EXECUTE_WIZARD_STEP_help = "Set the enable to WIZARD" + + + cmd_EXECUTE_WIZARD_STEP_help = "Run gcode in the 'action_gcode' section" def cmd_EXECUTE_WIZARD_STEP(self, gcmd): gcmd.respond_info('-----EXECUTE_WIZARD_STEP') + self.cmd(gcmd=gcmd, gcode='action_gcode') - cmd_CANCEL_WIZARD_STEP_help = "Set the step to WIZARD" + cmd_CANCEL_WIZARD_STEP_help = "Run gcode in the 'cancel_gcode' section" def cmd_CANCEL_WIZARD_STEP(self, gcmd): gcmd.respond_info('-----EXECUTE_WIZARD_STEP') + self.cmd(gcmd=gcmd, gcode='cancel_gcode') - def cmd(self, gcmd): + def cmd(self, gcmd, gcode): if self.in_script: - raise gcmd.error("Macro %s called recursively" % (self.alias,)) - kwparams = {} + raise gcmd.error("Macro %s called recursively" % (self.name,)) + # update status to the wizard + wizard_name = gcmd.get('WIZARD') + wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) + wizard_obj.update_status(current_step=self.name) + # kwparams = {} + kwparams = dict(wizard_obj.variables) kwparams.update(self.template_action.create_template_context()) kwparams['params'] = gcmd.get_command_parameters() kwparams['rawparams'] = gcmd.get_raw_command_parameters() + kwparams['wizard'] = wizard_name self.in_script = True try: - self.template_action.run_gcode_from_command(kwparams) + if gcode == 'action_gcode': + self.template_action.run_gcode_from_command(kwparams) + elif gcode == 'cancel_gcode': + self.template_cancel.run_gcode_from_command(kwparams) finally: - self.template_cancel.run_gcode_from_command(kwparams) + # self.template_cancel.run_gcode_from_command(kwparams) self.in_script = False + def load_config_prefix(config): return WizardStep(config) diff --git a/klippy/extras/wizard/wizard_step_button.py b/klippy/extras/wizard/wizard_step_button.py new file mode 100644 index 000000000000..2baede1ac5e7 --- /dev/null +++ b/klippy/extras/wizard/wizard_step_button.py @@ -0,0 +1,37 @@ +from wizard_step import WizardStep + + +class WizardStepButton(WizardStep): + def __init__(self, config): + # super(WizardStepButton, self).__init__(config) + WizardStep.__init__(self, config) + gcode_macro = self.printer.load_object(config, 'gcode_macro') + self.template = gcode_macro.load_template(config, 'button_%s_gcode' % self.name) + self.gcode.register_mux_command("WIZARD_STEP_BUTTON", 'BUTTON', + self.name, self.cmd_WIZARD_STEP_BUTTON, + desc=self.cmd_WIZARD_STEP_BUTTON_help) + + cmd_WIZARD_STEP_BUTTON_help = "Run gcode in the 'button_%s_gcode' section" + def cmd_WIZARD_STEP_BUTTON(self, gcmd): + if self.in_script: + raise gcmd.error("Macro %s called recursively" % (self.name,)) + # update status to the wizard + wizard_name = gcmd.get('WIZARD') + wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) + wizard_obj.update_status(current_step=self.name) + # kwparams = {} + kwparams = dict(wizard_obj.variables) + kwparams.update(self.template_action.create_template_context()) + kwparams['params'] = gcmd.get_command_parameters() + kwparams['rawparams'] = gcmd.get_raw_command_parameters() + kwparams['wizard'] = wizard_name + self.in_script = True + try: + self.template.run_gcode_from_command(kwparams) + finally: + # self.template_cancel.run_gcode_from_command(kwparams) + self.in_script = False + +def load_config_prefix(config): + return WizardStepButton(config) + diff --git a/klippy/klippy.py b/klippy/klippy.py index 15025c5a0ca4..00d5849405f8 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -110,6 +110,8 @@ def load_object(self, config, section, default=configfile.sentinel): return self.objects[section] module_parts = section.split() module_name = module_parts[0] + if 'wizard' in section: + module_name = 'wizard' py_name = os.path.join(os.path.dirname(__file__), 'extras', module_name + '.py') py_dirname = os.path.join(os.path.dirname(__file__), From 5c0d69f173165e80e40d889feccc5191a0ec853a Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Thu, 14 Dec 2023 13:06:23 +0000 Subject: [PATCH 04/13] STEAPP-842: added config for wizards --- HTE530-5-4-22.cfg | 2 + stereotech_config/wizards/wizards.cfg | 80 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 stereotech_config/wizards/wizards.cfg diff --git a/HTE530-5-4-22.cfg b/HTE530-5-4-22.cfg index 562d78b400da..ef724e225006 100644 --- a/HTE530-5-4-22.cfg +++ b/HTE530-5-4-22.cfg @@ -42,6 +42,8 @@ path: /home/ste/uploads [include stereotech_config/common/variables.cfg] [include stereotech_config/common/diagnostics.cfg] +[include stereotech_config/wizards/wizards.cfg] + [gcode_macro CONSTANTS] description: Holds printer constants variable_probe_a_horizontal: 159, 246.5, 40 diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg new file mode 100644 index 000000000000..be09d733ef33 --- /dev/null +++ b/stereotech_config/wizards/wizards.cfg @@ -0,0 +1,80 @@ +# wizard +# SET_WIZARD_ENABLE WIZARD=CALIBRATE ENABLE=1 ERROR=error_message +# SET_WIZARD_STEP WIZARD=MY STEP=step1 +# SET_WIZARD_VARIABLE WIZARD=MY VARIABLE= VALUE= +# RESET_WIZARD WIZARD=MY + +# wizard_step +# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_1 +# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_1 + +# wizard_step_button +# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 +# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 +# WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=STEP_BUTTON_1 + + +[wizard CALIBRATE] +image: path/to/image/wizard/CALIBRATE +type: 3d, 5d, any +steps: STEP_1, STEP_2 +variable_a: 1 +variable_b: 2 + +[wizard_step STEP_0] +image: path/to/image/wizard/STEP_0 +landscape: false +description: description STEP_0 +warning: warning STEP_0 +countdown: 10 +info: info about STSTEP_0 +action_gcode: + {action_respond_info('-------------------start STEP_0')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_0')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step STEP_1] +image: path/to/image/wizard/STEP_1 +landscape: false +description: description STEP_1 +warning: warning STEP_1 +countdown: 10 +info: info about STEP_1 +action_gcode: + {action_respond_info('-------------------start STEP_1')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_1')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step STEP_2] +image: path/to/image/wizard/STEP_2 +landscape: false +description: description STEP_2 +warning: warning STEP_2 +countdown: 20 +info: info about STEP_2 +action_gcode: + {action_respond_info('-------------------start STEP_2')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_2')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step_button STEP_BUTTON_1] +image: path/to/image/wizard/STEP_BUTTON_1 +landscape: false +description: description STEP_BUTTON_1 +warning: warning STEP_BUTTON_1 +countdown: 20 +info: info about STEP_BUTTON_1 +button_STEP_BUTTON_1_gcode: + {action_respond_info('-------------------button_STEP_BUTTON_1_gcode')} +action_gcode: + {action_respond_info('-------------------start STEP_BUTTON_1')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_BUTTON_1')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 From 17c66f65f8913f5f34e89260940927b3639e7ca7 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Thu, 14 Dec 2023 13:55:00 +0000 Subject: [PATCH 05/13] STEAPP-842: added wizard_step_wizards --- klippy/extras/wizard/wizard_step_wizards.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 klippy/extras/wizard/wizard_step_wizards.py diff --git a/klippy/extras/wizard/wizard_step_wizards.py b/klippy/extras/wizard/wizard_step_wizards.py new file mode 100644 index 000000000000..2b8422f6c0b4 --- /dev/null +++ b/klippy/extras/wizard/wizard_step_wizards.py @@ -0,0 +1,13 @@ +from wizard_step import WizardStep + + +class WizardStepWizards(WizardStep): + def __init__(self, config): + # super(WizardStepButton, self).__init__(config) + WizardStep.__init__(self, config) + self.wizards = config.getlists('wizards', []) + a = '' + +def load_config_prefix(config): + return WizardStepWizards(config) + From eee362eaa686d20f0f2766fee0a4ed0c4f65d01e Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Thu, 14 Dec 2023 14:28:13 +0000 Subject: [PATCH 06/13] STEAPP-842: added wizard_step_selector.py --- klippy/extras/wizard/__init__.py | 8 ++- klippy/extras/wizard/wizard.py | 2 +- klippy/extras/wizard/wizard_step.py | 4 +- klippy/extras/wizard/wizard_step_button.py | 2 +- klippy/extras/wizard/wizard_step_selectors.py | 50 +++++++++++++++++++ klippy/extras/wizard/wizard_step_wizards.py | 1 - stereotech_config/wizards/wizards.cfg | 41 +++++++++++++++ 7 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 klippy/extras/wizard/wizard_step_selectors.py diff --git a/klippy/extras/wizard/__init__.py b/klippy/extras/wizard/__init__.py index 3c6fb59f5e61..237ac7694061 100644 --- a/klippy/extras/wizard/__init__.py +++ b/klippy/extras/wizard/__init__.py @@ -3,7 +3,7 @@ # Copyright (C) 2018 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. -from . import wizard, wizard_step, wizard_step_button +from . import wizard, wizard_step, wizard_step_button, wizard_step_wizards, wizard_step_selectors # def load_config(config): # return wizard.load_config(config) @@ -16,9 +16,13 @@ def load_config_prefix(config): return wizard.load_config_prefix(config) elif 'wizard_step_button ' in name: return wizard_step_button.load_config_prefix(config) + elif 'wizard_step_wizards ' in name: + return wizard_step_wizards.load_config_prefix(config) + elif 'wizard_step_selectors ' in name: + return wizard_step_selectors.load_config_prefix(config) else: raise config.error( - "do not parse section") + "do not parse section: %s" % name) # elif config.has_section('wizard_step_slider'): # raise config.error( # "0018: A primary [display] section must be defined in printer.cfg " diff --git a/klippy/extras/wizard/wizard.py b/klippy/extras/wizard/wizard.py index 162d083f0a71..774a10ca74b3 100644 --- a/klippy/extras/wizard/wizard.py +++ b/klippy/extras/wizard/wizard.py @@ -45,7 +45,7 @@ def __init__(self, config): option, config.get_name(), e)) self.image = config.get('image', 'image_path') self.type = config.getlists('type', []) - self.steps = config.getlists('steps', 'image_path') + self.steps = config.getlists('steps', []) self.current_step = self.steps[0] self.enabled = False self.error = '' diff --git a/klippy/extras/wizard/wizard_step.py b/klippy/extras/wizard/wizard_step.py index 9ec80bd87ab9..84098158964c 100644 --- a/klippy/extras/wizard/wizard_step.py +++ b/klippy/extras/wizard/wizard_step.py @@ -42,19 +42,17 @@ def __init__(self, config): cmd_EXECUTE_WIZARD_STEP_help = "Run gcode in the 'action_gcode' section" def cmd_EXECUTE_WIZARD_STEP(self, gcmd): - gcmd.respond_info('-----EXECUTE_WIZARD_STEP') self.cmd(gcmd=gcmd, gcode='action_gcode') cmd_CANCEL_WIZARD_STEP_help = "Run gcode in the 'cancel_gcode' section" def cmd_CANCEL_WIZARD_STEP(self, gcmd): - gcmd.respond_info('-----EXECUTE_WIZARD_STEP') self.cmd(gcmd=gcmd, gcode='cancel_gcode') def cmd(self, gcmd, gcode): if self.in_script: raise gcmd.error("Macro %s called recursively" % (self.name,)) # update status to the wizard - wizard_name = gcmd.get('WIZARD') + wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) wizard_obj.update_status(current_step=self.name) # kwparams = {} diff --git a/klippy/extras/wizard/wizard_step_button.py b/klippy/extras/wizard/wizard_step_button.py index 2baede1ac5e7..9bcd9d6978f0 100644 --- a/klippy/extras/wizard/wizard_step_button.py +++ b/klippy/extras/wizard/wizard_step_button.py @@ -16,7 +16,7 @@ def cmd_WIZARD_STEP_BUTTON(self, gcmd): if self.in_script: raise gcmd.error("Macro %s called recursively" % (self.name,)) # update status to the wizard - wizard_name = gcmd.get('WIZARD') + wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) wizard_obj.update_status(current_step=self.name) # kwparams = {} diff --git a/klippy/extras/wizard/wizard_step_selectors.py b/klippy/extras/wizard/wizard_step_selectors.py new file mode 100644 index 000000000000..9d8534754ea6 --- /dev/null +++ b/klippy/extras/wizard/wizard_step_selectors.py @@ -0,0 +1,50 @@ +from wizard_step import WizardStep + + +class WizardStepSelectors(WizardStep): + def __init__(self, config): + # super(WizardStepButton, self).__init__(config) + WizardStep.__init__(self, config) + self.items = config.getlists('items', []) + self.selected = '' + + gcode_macro = self.printer.load_object(config, 'gcode_macro') + self.template = gcode_macro.load_template(config, 'select_gcode') + self.gcode.register_mux_command("WIZARD_STEP_SELECT", 'STEP', + self.name, self.cmd_WIZARD_STEP_SELECT, + desc=self.cmd_WIZARD_STEP_SELECT_help) + + def get_status(self, eventtime): + state = {'selected': self.selected} + return state + + cmd_WIZARD_STEP_SELECT_help = "Run gcode in the 'select_gcode' section" + def cmd_WIZARD_STEP_SELECT(self, gcmd): + if self.in_script: + raise gcmd.error("Macro %s called recursively" % (self.name,)) + selected = gcmd.get('ITEM') + if selected not in self.items: + raise gcmd.error("the selected item %s not in the items %s" % (selected, self.items)) + self.selected = selected + # update status to the wizard + wizard_name = gcmd.get('WIZARD').upper() + wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) + wizard_obj.update_status(current_step=self.name) + # kwparams = {} + # create context + kwparams = dict(wizard_obj.variables) + kwparams.update(self.template_action.create_template_context()) + kwparams['params'] = gcmd.get_command_parameters() + kwparams['rawparams'] = gcmd.get_raw_command_parameters() + kwparams['wizard'] = wizard_name + kwparams['selected'] = self.selected + self.in_script = True + try: + self.template.run_gcode_from_command(kwparams) + finally: + # self.template_cancel.run_gcode_from_command(kwparams) + self.in_script = False + +def load_config_prefix(config): + return WizardStepSelectors(config) + diff --git a/klippy/extras/wizard/wizard_step_wizards.py b/klippy/extras/wizard/wizard_step_wizards.py index 2b8422f6c0b4..a8b8d8853659 100644 --- a/klippy/extras/wizard/wizard_step_wizards.py +++ b/klippy/extras/wizard/wizard_step_wizards.py @@ -6,7 +6,6 @@ def __init__(self, config): # super(WizardStepButton, self).__init__(config) WizardStep.__init__(self, config) self.wizards = config.getlists('wizards', []) - a = '' def load_config_prefix(config): return WizardStepWizards(config) diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg index be09d733ef33..26bb8281d021 100644 --- a/stereotech_config/wizards/wizards.cfg +++ b/stereotech_config/wizards/wizards.cfg @@ -13,6 +13,15 @@ # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 # WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=STEP_BUTTON_1 +# wizard_step_wizards +# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_WIZARDS_1 +# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_WIZARDS_1 + +# wizard_step_selector +# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SELECTOR_1 +# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SELECTOR_1 +# WIZARD_STEP_SELECT WIZARD=CALIBRATE STEP=STEP_SELECTOR_1 ITEM=item3 + [wizard CALIBRATE] image: path/to/image/wizard/CALIBRATE @@ -78,3 +87,35 @@ cancel_gcode: {action_respond_info('------------------CANCEL STEP_BUTTON_1')} RESET_WIZARD WIZARD={wizard} # HOME_POSITION ABORT=1 + +[wizard_step_wizards STEP_WIZARDS_1] +image: path/to/image/wizard/STEP_WIZARDS_1 +landscape: false +description: description STEP_WIZARDS_1 +warning: warning STEP_WIZARDS_1 +countdown: 20 +info: info about STEP_WIZARDS_1 +wizards: wizard1, wizard2 +action_gcode: + {action_respond_info('-------------------start STEP_WIZARDS_1')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_WIZARDS_1')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step_selectors STEP_SELECTOR_1] +image: path/to/image/wizard/STEP_SELECTOR_1 +landscape: false +description: description STEP_SELECTOR_1 +warning: warning STEP_SELECTOR_1 +countdown: 20 +info: info about STEP_SELECTOR_1 +items: item1, item2, item3 +select_gcode: + {action_respond_info('-------------------select_gcode STEP_SELECTOR_1 selected=%s, wizard=%s' % (selected, wizard))} +action_gcode: + {action_respond_info('-------------------start STEP_SELECTOR_1')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_SELECTOR_1')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 \ No newline at end of file From 886a496246dfe6ada5973b4ccbd2e2b908209295 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Fri, 15 Dec 2023 06:05:56 +0000 Subject: [PATCH 07/13] STEAPP-842: added wizard_step_slider --- klippy/extras/wizard/__init__.py | 11 +++++-- klippy/extras/wizard/wizard_step_selectors.py | 8 ++--- klippy/extras/wizard/wizard_step_slider.py | 29 +++++++++++++++++++ stereotech_config/wizards/wizards.cfg | 22 ++++++++++++++ 4 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 klippy/extras/wizard/wizard_step_slider.py diff --git a/klippy/extras/wizard/__init__.py b/klippy/extras/wizard/__init__.py index 237ac7694061..820cdcec37b2 100644 --- a/klippy/extras/wizard/__init__.py +++ b/klippy/extras/wizard/__init__.py @@ -3,9 +3,14 @@ # Copyright (C) 2018 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. -from . import wizard, wizard_step, wizard_step_button, wizard_step_wizards, wizard_step_selectors +from . import wizard,\ + wizard_step,\ + wizard_step_button,\ + wizard_step_wizards,\ + wizard_step_selectors, \ + wizard_step_slider -# def load_config(config): +# def load_confi g(config): # return wizard.load_config(config) def load_config_prefix(config): @@ -20,6 +25,8 @@ def load_config_prefix(config): return wizard_step_wizards.load_config_prefix(config) elif 'wizard_step_selectors ' in name: return wizard_step_selectors.load_config_prefix(config) + elif 'wizard_step_slider ' in name: + return wizard_step_slider.load_config_prefix(config) else: raise config.error( "do not parse section: %s" % name) diff --git a/klippy/extras/wizard/wizard_step_selectors.py b/klippy/extras/wizard/wizard_step_selectors.py index 9d8534754ea6..a70fe86a8906 100644 --- a/klippy/extras/wizard/wizard_step_selectors.py +++ b/klippy/extras/wizard/wizard_step_selectors.py @@ -14,10 +14,6 @@ def __init__(self, config): self.name, self.cmd_WIZARD_STEP_SELECT, desc=self.cmd_WIZARD_STEP_SELECT_help) - def get_status(self, eventtime): - state = {'selected': self.selected} - return state - cmd_WIZARD_STEP_SELECT_help = "Run gcode in the 'select_gcode' section" def cmd_WIZARD_STEP_SELECT(self, gcmd): if self.in_script: @@ -45,6 +41,10 @@ def cmd_WIZARD_STEP_SELECT(self, gcmd): # self.template_cancel.run_gcode_from_command(kwparams) self.in_script = False + def get_status(self, eventtime): + state = {'selected': self.selected} + return state + def load_config_prefix(config): return WizardStepSelectors(config) diff --git a/klippy/extras/wizard/wizard_step_slider.py b/klippy/extras/wizard/wizard_step_slider.py new file mode 100644 index 000000000000..9e27fa20369c --- /dev/null +++ b/klippy/extras/wizard/wizard_step_slider.py @@ -0,0 +1,29 @@ +from wizard_step import WizardStep + + +class WizardStepSlider(WizardStep): + def __init__(self, config): + # super(WizardStepButton, self).__init__(config) + WizardStep.__init__(self, config) + self.slider_data = {} + options = config.get_prefix_options('slider') + for option in options: + self.slider_data.update({option: config.getint(option)}) + self.gcode.register_mux_command("WIZARD_STEP_SLIDER", 'SLIDER', + self.name, self.cmd_WIZARD_STEP_SLIDER, + desc=self.cmd_WIZARD_STEP_SLIDER_help) + + cmd_WIZARD_STEP_SLIDER_help = "set update value to the slider data" + def cmd_WIZARD_STEP_SLIDER(self, gcmd): + variable = gcmd.get('VARIABLE').lower() + value = gcmd.get_int('VALUE') + if variable not in self.slider_data: + raise gcmd.error("failure set value:%s to variable:%s in the slider %s" % (value, variable, self.name)) + self.slider_data.update({variable: value}) + + def get_status(self, eventtime): + return self.slider_data + +def load_config_prefix(config): + return WizardStepSlider(config) + diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg index 26bb8281d021..bf0565c89143 100644 --- a/stereotech_config/wizards/wizards.cfg +++ b/stereotech_config/wizards/wizards.cfg @@ -22,6 +22,10 @@ # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SELECTOR_1 # WIZARD_STEP_SELECT WIZARD=CALIBRATE STEP=STEP_SELECTOR_1 ITEM=item3 +# wizard_step_slider +# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SLIDER_1 +# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SLIDER_1 +# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=STEP_SLIDER_1 VARIABLE=slider_STEP_SLIDER_1_min VALUE=12 [wizard CALIBRATE] image: path/to/image/wizard/CALIBRATE @@ -113,6 +117,24 @@ info: info about STEP_SELECTOR_1 items: item1, item2, item3 select_gcode: {action_respond_info('-------------------select_gcode STEP_SELECTOR_1 selected=%s, wizard=%s' % (selected, wizard))} +action_gcode: + {action_respond_info('-------------------start STEP_SELECTOR_1')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_SELECTOR_1')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step_slider STEP_SLIDER_1] +image: path/to/image/wizard/STEP_SLIDER_1 +landscape: false +description: description STEP_SLIDER_1 +warning: warning STEP_SLIDER_1 +countdown: 20 +info: info about STEP_SLIDER_1 +slider_STEP_SLIDER_1_min: 0 +slider_STEP_SLIDER_1_max: 100 +slider_STEP_SLIDER_1_step: 1 +slider_STEP_SLIDER_1_default: 20 action_gcode: {action_respond_info('-------------------start STEP_SELECTOR_1')} cancel_gcode: From e31c9b2c1a2acbc778eb32721081c551cb652a71 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Fri, 15 Dec 2023 07:02:58 +0000 Subject: [PATCH 08/13] STEAPP-842: added wizard_step_jog --- klippy/extras/wizard/__init__.py | 22 ++----- klippy/extras/wizard/wizard_step.py | 12 ++-- klippy/extras/wizard/wizard_step_button.py | 8 +-- klippy/extras/wizard/wizard_step_jog.py | 61 +++++++++++++++++++ klippy/extras/wizard/wizard_step_selectors.py | 11 ++-- klippy/extras/wizard/wizard_step_slider.py | 2 +- klippy/extras/wizard/wizard_step_wizards.py | 1 - stereotech_config/wizards/wizards.cfg | 27 +++++++- 8 files changed, 107 insertions(+), 37 deletions(-) create mode 100644 klippy/extras/wizard/wizard_step_jog.py diff --git a/klippy/extras/wizard/__init__.py b/klippy/extras/wizard/__init__.py index 820cdcec37b2..f030c3dbb8b6 100644 --- a/klippy/extras/wizard/__init__.py +++ b/klippy/extras/wizard/__init__.py @@ -1,17 +1,11 @@ -# Package definition for the extras/display directory -# -# Copyright (C) 2018 Kevin O'Connor -# -# This file may be distributed under the terms of the GNU GPLv3 license. from . import wizard,\ wizard_step,\ wizard_step_button,\ wizard_step_wizards,\ wizard_step_selectors, \ - wizard_step_slider + wizard_step_slider, \ + wizard_step_jog -# def load_confi g(config): -# return wizard.load_config(config) def load_config_prefix(config): name = config.get_name() @@ -27,16 +21,8 @@ def load_config_prefix(config): return wizard_step_selectors.load_config_prefix(config) elif 'wizard_step_slider ' in name: return wizard_step_slider.load_config_prefix(config) + elif 'wizard_step_jog ' in name: + return wizard_step_jog.load_config_prefix(config) else: raise config.error( "do not parse section: %s" % name) - # elif config.has_section('wizard_step_slider'): - # raise config.error( - # "0018: A primary [display] section must be defined in printer.cfg " - # "to use auxilary displays") - # name = config.get_name().split()[-1] - # if name == "display": - # raise config.error( - # "0019: Section name [display display] is not valid. " - # "Please choose a different postfix.") - # return wizard.load_config_prefix(config) diff --git a/klippy/extras/wizard/wizard_step.py b/klippy/extras/wizard/wizard_step.py index 84098158964c..a052c16b5c4b 100644 --- a/klippy/extras/wizard/wizard_step.py +++ b/klippy/extras/wizard/wizard_step.py @@ -8,18 +8,18 @@ def __init__(self, config): raise config.error( "Name of section '%s' contains illegal whitespace" % (config.get_name())) - full_name = config.get_name().split() - self.name = full_name[1].upper() + section_name = config.get_name().split() + self.name = section_name[1].upper() self.in_script = False # load objects self.printer = printer = config.get_printer() - gcode_macro = printer.load_object(config, 'gcode_macro') + self.gcode_macro = printer.load_object(config, 'gcode_macro') self.gcode = printer.lookup_object('gcode') # create template - self.template_action = gcode_macro.load_template(config, 'action_gcode') - self.template_cancel = gcode_macro.load_template(config, 'cancel_gcode') + self.template_action = self.gcode_macro.load_template(config, 'action_gcode') + self.template_cancel = self.gcode_macro.load_template(config, 'cancel_gcode') # get params from config - self.cmd_desc = config.get("description", "G-Code macro") + self.cmd_desc = config.get("description", "G-Code wizard") self.image = config.get('image', 'image_path') self.landscape = config.getboolean('landscape', False) self.description = config.get('description', '') diff --git a/klippy/extras/wizard/wizard_step_button.py b/klippy/extras/wizard/wizard_step_button.py index 9bcd9d6978f0..28d345cc5688 100644 --- a/klippy/extras/wizard/wizard_step_button.py +++ b/klippy/extras/wizard/wizard_step_button.py @@ -5,8 +5,9 @@ class WizardStepButton(WizardStep): def __init__(self, config): # super(WizardStepButton, self).__init__(config) WizardStep.__init__(self, config) - gcode_macro = self.printer.load_object(config, 'gcode_macro') - self.template = gcode_macro.load_template(config, 'button_%s_gcode' % self.name) + # create template + self.template_button = self.gcode_macro.load_template(config, 'button_%s_gcode' % self.name) + # register commands self.gcode.register_mux_command("WIZARD_STEP_BUTTON", 'BUTTON', self.name, self.cmd_WIZARD_STEP_BUTTON, desc=self.cmd_WIZARD_STEP_BUTTON_help) @@ -27,9 +28,8 @@ def cmd_WIZARD_STEP_BUTTON(self, gcmd): kwparams['wizard'] = wizard_name self.in_script = True try: - self.template.run_gcode_from_command(kwparams) + self.template_button.run_gcode_from_command(kwparams) finally: - # self.template_cancel.run_gcode_from_command(kwparams) self.in_script = False def load_config_prefix(config): diff --git a/klippy/extras/wizard/wizard_step_jog.py b/klippy/extras/wizard/wizard_step_jog.py new file mode 100644 index 000000000000..15655cb66dce --- /dev/null +++ b/klippy/extras/wizard/wizard_step_jog.py @@ -0,0 +1,61 @@ +from wizard_step import WizardStep + + +class WizardStepJog(WizardStep): + def __init__(self, config): + # super(WizardStepButton, self).__init__(config) + WizardStep.__init__(self, config) + # get options + self.axes = config.getlists('axes') + self.steps = config.getfloatlist('steps') + self.default_step = config.getfloat('default_step') + # create template + self.template_jog = self.gcode_macro.load_template(config, 'jog_gcode') + # register gcode commands + self.gcode.register_mux_command("WIZARD_STEP_JOG", 'STEP', + self.name, self.cmd_WIZARD_STEP_JOG, + desc=self.cmd_WIZARD_STEP_JOG_help) + self.gcode.register_mux_command("WIZARD_STEP_SET_STEP", 'STEP', + self.name, self.cmd_WIZARD_STEP_SET_STEP, + desc=self.cmd_WIZARD_STEP_SET_STEP_help) + + cmd_WIZARD_STEP_SET_STEP_help = "set step for moving the axis" + def cmd_WIZARD_STEP_SET_STEP(self, gcmd): + value = gcmd.get_float('VALUE') + if value not in self.steps: + raise gcmd.error( + "error setting the value:%s to move the axis, the value is out of range" % (value,)) + self.default_step = value + + cmd_WIZARD_STEP_JOG_help = "perform axis movement" + def cmd_WIZARD_STEP_JOG(self, gcmd): + axis = gcmd.get('AXIS').lower() + if axis not in self.axes: + raise gcmd.error( + "error moved the axis:%s, the axis not availability" % (axis,)) + if self.in_script: + raise gcmd.error("Macro %s called recursively" % (self.name,)) + # update status to the wizard + wizard_name = gcmd.get('WIZARD').upper() + wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) + wizard_obj.update_status(current_step=self.name) + # kwparams = {} + kwparams = dict(wizard_obj.variables) + kwparams.update(self.template_action.create_template_context()) + kwparams['params'] = gcmd.get_command_parameters() + kwparams['rawparams'] = gcmd.get_raw_command_parameters() + kwparams['wizard'] = wizard_name + kwparams['axis'] = axis + kwparams['step'] = self.default_step + self.in_script = True + try: + self.template_jog.run_gcode_from_command(kwparams) + finally: + self.in_script = False + + def get_status(self, eventtime): + return {'step': self.default_step} + +def load_config_prefix(config): + return WizardStepJog(config) + diff --git a/klippy/extras/wizard/wizard_step_selectors.py b/klippy/extras/wizard/wizard_step_selectors.py index a70fe86a8906..7c310048c60a 100644 --- a/klippy/extras/wizard/wizard_step_selectors.py +++ b/klippy/extras/wizard/wizard_step_selectors.py @@ -3,16 +3,16 @@ class WizardStepSelectors(WizardStep): def __init__(self, config): - # super(WizardStepButton, self).__init__(config) WizardStep.__init__(self, config) + # get options self.items = config.getlists('items', []) - self.selected = '' - - gcode_macro = self.printer.load_object(config, 'gcode_macro') - self.template = gcode_macro.load_template(config, 'select_gcode') + # create template + self.template = self.gcode_macro.load_template(config, 'select_gcode') + # register commands self.gcode.register_mux_command("WIZARD_STEP_SELECT", 'STEP', self.name, self.cmd_WIZARD_STEP_SELECT, desc=self.cmd_WIZARD_STEP_SELECT_help) + self.selected = '' cmd_WIZARD_STEP_SELECT_help = "Run gcode in the 'select_gcode' section" def cmd_WIZARD_STEP_SELECT(self, gcmd): @@ -38,7 +38,6 @@ def cmd_WIZARD_STEP_SELECT(self, gcmd): try: self.template.run_gcode_from_command(kwparams) finally: - # self.template_cancel.run_gcode_from_command(kwparams) self.in_script = False def get_status(self, eventtime): diff --git a/klippy/extras/wizard/wizard_step_slider.py b/klippy/extras/wizard/wizard_step_slider.py index 9e27fa20369c..f2c7d1a1202d 100644 --- a/klippy/extras/wizard/wizard_step_slider.py +++ b/klippy/extras/wizard/wizard_step_slider.py @@ -13,7 +13,7 @@ def __init__(self, config): self.name, self.cmd_WIZARD_STEP_SLIDER, desc=self.cmd_WIZARD_STEP_SLIDER_help) - cmd_WIZARD_STEP_SLIDER_help = "set update value to the slider data" + cmd_WIZARD_STEP_SLIDER_help = "update value to the slider data" def cmd_WIZARD_STEP_SLIDER(self, gcmd): variable = gcmd.get('VARIABLE').lower() value = gcmd.get_int('VALUE') diff --git a/klippy/extras/wizard/wizard_step_wizards.py b/klippy/extras/wizard/wizard_step_wizards.py index a8b8d8853659..5bddd0dff54a 100644 --- a/klippy/extras/wizard/wizard_step_wizards.py +++ b/klippy/extras/wizard/wizard_step_wizards.py @@ -3,7 +3,6 @@ class WizardStepWizards(WizardStep): def __init__(self, config): - # super(WizardStepButton, self).__init__(config) WizardStep.__init__(self, config) self.wizards = config.getlists('wizards', []) diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg index bf0565c89143..40ae26e4fbf5 100644 --- a/stereotech_config/wizards/wizards.cfg +++ b/stereotech_config/wizards/wizards.cfg @@ -27,6 +27,12 @@ # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SLIDER_1 # WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=STEP_SLIDER_1 VARIABLE=slider_STEP_SLIDER_1_min VALUE=12 +# wizard_step_jog +# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 +# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 +# WIZARD_STEP_JOG WIZARD=CALIBRATE STEP=STEP_JOG_1 AXIS=z +# WIZARD_STEP_SET_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 VALUE=50 + [wizard CALIBRATE] image: path/to/image/wizard/CALIBRATE type: 3d, 5d, any @@ -140,4 +146,23 @@ action_gcode: cancel_gcode: {action_respond_info('------------------CANCEL STEP_SELECTOR_1')} RESET_WIZARD WIZARD={wizard} - # HOME_POSITION ABORT=1 \ No newline at end of file + # HOME_POSITION ABORT=1 + +[wizard_step_jog STEP_JOG_1] +image: path/to/image/wizard/STEP_JOG_1 +landscape: false +description: description STEP_JOG_1 +warning: warning STEP_JOG_1 +countdown: 20 +info: info about STEP_JOG_1 +axes: x, y, z, a, c +steps: 0.1, 1, 10, 20 +default_step: 10 +jog_gcode: + {action_respond_info('-------------------jog_gcode STEP_JOG_1 axis=%s, step=%s' % (axis, step))} +action_gcode: + {action_respond_info('-------------------start STEP_JOG_1')} +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_JOG_1')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 From f2d66b8986bfb03a32c0fc0441fd8c3481842b02 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Mon, 18 Dec 2023 13:03:21 +0000 Subject: [PATCH 09/13] STEAPP-842: edited modules --- klippy/extras/wizard/__init__.py | 33 +-- klippy/extras/wizard/wizard.py | 83 +++---- klippy/extras/wizard/wizard_step.py | 39 +-- klippy/extras/wizard/wizard_step_button.py | 12 +- klippy/extras/wizard/wizard_step_jog.py | 27 +- ...p_selectors.py => wizard_step_selector.py} | 24 +- klippy/extras/wizard/wizard_step_slider.py | 6 +- klippy/extras/wizard/wizard_step_wizards.py | 1 - stereotech_config/wizards/change_material.cfg | 231 ++++++++++++++++++ stereotech_config/wizards/wizards.cfg | 93 ++++--- 10 files changed, 356 insertions(+), 193 deletions(-) rename klippy/extras/wizard/{wizard_step_selectors.py => wizard_step_selector.py} (68%) create mode 100644 stereotech_config/wizards/change_material.cfg diff --git a/klippy/extras/wizard/__init__.py b/klippy/extras/wizard/__init__.py index f030c3dbb8b6..50af2078a78d 100644 --- a/klippy/extras/wizard/__init__.py +++ b/klippy/extras/wizard/__init__.py @@ -1,28 +1,11 @@ -from . import wizard,\ - wizard_step,\ - wizard_step_button,\ - wizard_step_wizards,\ - wizard_step_selectors, \ - wizard_step_slider, \ - wizard_step_jog +import importlib def load_config_prefix(config): - name = config.get_name() - if 'wizard_step ' in name: - return wizard_step.load_config_prefix(config) - elif 'wizard ' in name: - return wizard.load_config_prefix(config) - elif 'wizard_step_button ' in name: - return wizard_step_button.load_config_prefix(config) - elif 'wizard_step_wizards ' in name: - return wizard_step_wizards.load_config_prefix(config) - elif 'wizard_step_selectors ' in name: - return wizard_step_selectors.load_config_prefix(config) - elif 'wizard_step_slider ' in name: - return wizard_step_slider.load_config_prefix(config) - elif 'wizard_step_jog ' in name: - return wizard_step_jog.load_config_prefix(config) - else: - raise config.error( - "do not parse section: %s" % name) + mod_name = 'extras.wizard.' + config.get_name().split()[0] + try: + mod = importlib.import_module(mod_name) + # init_func = getattr(mod, init_func, None) + mod.load_config_prefix(config) + except Exception as e: + raise Exception('2050: No module named %s, error: %s' % (mod_name, e)) diff --git a/klippy/extras/wizard/wizard.py b/klippy/extras/wizard/wizard.py index 774a10ca74b3..11513a092ac5 100644 --- a/klippy/extras/wizard/wizard.py +++ b/klippy/extras/wizard/wizard.py @@ -9,27 +9,8 @@ def __init__(self, config): "Name of section '%s' contains illegal whitespace" % (config.get_name())) self.name = config.get_name().split()[1] - # self.alias = self.name.upper() - self.printer = printer = config.get_printer() - # gcode_macro = printer.load_object(config, 'gcode_macro') - # self.template = gcode_macro.load_template(config, 'gcode') - self.gcode = printer.lookup_object('gcode') - self.cmd_desc = config.get("description", "G-Code macro") - # self.gcode.register_command(self.alias, self.cmd, - # desc=self.cmd_desc) - self.gcode.register_mux_command("SET_WIZARD_VARIABLE", "WIZARD", - self.name, self.cmd_SET_WIZARD_VARIABLE, - desc=self.cmd_SET_WIZARD_VARIABLE_help) - self.gcode.register_mux_command("SET_WIZARD_ENABLE", "WIZARD", - self.name, self.cmd_SET_WIZARD_ENABLE, - desc=self.cmd_SET_WIZARD_ENABLE_help) - self.gcode.register_mux_command("SET_WIZARD_STEP", "WIZARD", - self.name, self.cmd_SET_WIZARD_STEP, - desc=self.cmd_SET_WIZARD_STEP_help) - self.gcode.register_mux_command("RESET_WIZARD", "WIZARD", - self.name, self.cmd_RESET_WIZARD, - desc=self.cmd_RESET_WIZARD_help) - # self.in_script = False + self.enabled = False + self.error = '' self.variables = {} self._variables_bk = {} prefix = 'variable_' @@ -43,38 +24,48 @@ def __init__(self, config): raise config.error( "Option '%s' in section '%s' is not a valid literal: %s" % ( option, config.get_name(), e)) + # get options from config self.image = config.get('image', 'image_path') self.type = config.getlists('type', []) self.steps = config.getlists('steps', []) self.current_step = self.steps[0] - self.enabled = False - self.error = '' - - def update_status(self, current_step): - logging.info('-----------------update status %s' % current_step) - self.current_step = current_step + # load objects + self.printer = printer = config.get_printer() + self.gcode = printer.lookup_object('gcode') + # register commands + self.gcode.register_mux_command("SET_WIZARD_VARIABLE", "WIZARD", + self.name, self.cmd_SET_WIZARD_VARIABLE, + desc=self.cmd_SET_WIZARD_VARIABLE_help) + self.gcode.register_mux_command("SET_WIZARD_ENABLE", "WIZARD", + self.name, self.cmd_SET_WIZARD_ENABLE, + desc=self.cmd_SET_WIZARD_ENABLE_help) + self.gcode.register_mux_command("SET_WIZARD_STEP", "WIZARD", + self.name, self.cmd_SET_WIZARD_STEP, + desc=self.cmd_SET_WIZARD_STEP_help) + self.gcode.register_mux_command("RESET_WIZARD", "WIZARD", + self.name, self.cmd_RESET_WIZARD, + desc=self.cmd_RESET_WIZARD_help) - def get_status(self, eventtime): - state = {'current_step': self.current_step, - 'enabled': self.enabled, - 'error': self.error, - 'variables': self.variables, - # for debug - 'self.steps': self.steps, - 'self.type': self.type} - return state + def get_status(self, eventtime=None): + return {'current_step': self.current_step, + 'enabled': self.enabled, + 'error': self.error, + 'variables': self.variables, + 'name': self.name, + 'steps': self.steps, + 'type': self.type} cmd_SET_WIZARD_VARIABLE_help = "Set the value of a wizard variable to wizard" def cmd_SET_WIZARD_VARIABLE(self, gcmd): variable = gcmd.get('VARIABLE') value = gcmd.get('VALUE') if variable not in self.variables: - raise gcmd.error("Unknown wizard variable '%s'" % (variable,)) + raise gcmd.error("2051: Unknown wizard variable '%s'" % (variable,)) try: literal = ast.literal_eval(value) json.dumps(literal, separators=(',', ':')) except (SyntaxError, TypeError, ValueError) as e: - raise gcmd.error("Unable to parse '%s' as a literal: %s" % + raise gcmd.error("2052: Unable to parse '%s' as a literal: %s" % (value, e)) v = dict(self.variables) v[variable] = literal @@ -89,7 +80,7 @@ def cmd_SET_WIZARD_ENABLE(self, gcmd): def cmd_SET_WIZARD_STEP(self, gcmd): step = gcmd.get('STEP') if step not in self.steps: - raise gcmd.error("Unknown step: '%s'" % step) + raise gcmd.error("2053: Unknown step: '%s'" % step) self.current_step = step cmd_RESET_WIZARD_help = "Reset state the wizard" @@ -99,20 +90,6 @@ def cmd_RESET_WIZARD(self, gcmd): self.current_step = self.steps[0] self.variables = dict(self._variables_bk) - # def cmd(self, gcmd): - # self.enabled = True - # if self.in_script: - # raise gcmd.error("Macro %s called recursively" % (self.alias,)) - # kwparams = dict(self.variables) - # kwparams.update(self.template.create_template_context()) - # kwparams['params'] = gcmd.get_command_parameters() - # kwparams['rawparams'] = gcmd.get_raw_command_parameters() - # self.in_script = True - # try: - # self.template.run_gcode_from_command(kwparams) - # finally: - # self.in_script = False - # self.enabled = False def load_config_prefix(config): return Wizard(config) diff --git a/klippy/extras/wizard/wizard_step.py b/klippy/extras/wizard/wizard_step.py index a052c16b5c4b..d1bb6b19a65d 100644 --- a/klippy/extras/wizard/wizard_step.py +++ b/klippy/extras/wizard/wizard_step.py @@ -1,7 +1,3 @@ -import traceback, logging, ast, copy, json -import jinja2 - - class WizardStep: def __init__(self, config): if len(config.get_name().split()) > 2: @@ -15,10 +11,7 @@ def __init__(self, config): self.printer = printer = config.get_printer() self.gcode_macro = printer.load_object(config, 'gcode_macro') self.gcode = printer.lookup_object('gcode') - # create template - self.template_action = self.gcode_macro.load_template(config, 'action_gcode') - self.template_cancel = self.gcode_macro.load_template(config, 'cancel_gcode') - # get params from config + # get options from config self.cmd_desc = config.get("description", "G-Code wizard") self.image = config.get('image', 'image_path') self.landscape = config.getboolean('landscape', False) @@ -26,41 +19,35 @@ def __init__(self, config): self.warning = config.get('warning', '') self.info = config.get('info', '') self.countdown = config.getint('countdown', 0) + # create template + self.template_action = self.gcode_macro.load_template(config, 'action_gcode') + self.template_cancel = self.gcode_macro.load_template(config, 'cancel_gcode') # register gcode commands - key = 'STEP' - # key = full_name[0].split('_')[-1].upper() - self.gcode.register_mux_command("EXECUTE_WIZARD_STEP", key, + self.gcode.register_mux_command("EXECUTE_WIZARD_STEP", 'STEP', self.name, self.cmd_EXECUTE_WIZARD_STEP, desc=self.cmd_EXECUTE_WIZARD_STEP_help) - self.gcode.register_mux_command("CANCEL_WIZARD_STEP", key, + self.gcode.register_mux_command("CANCEL_WIZARD_STEP", 'STEP', self.name, self.cmd_CANCEL_WIZARD_STEP, desc=self.cmd_CANCEL_WIZARD_STEP_help) - # self.gcode.register_command(self.alias, self.cmd, - # desc=self.cmd_desc) - - - cmd_EXECUTE_WIZARD_STEP_help = "Run gcode in the 'action_gcode' section" + cmd_EXECUTE_WIZARD_STEP_help = "Run gcode in the 'action_gcode' option" def cmd_EXECUTE_WIZARD_STEP(self, gcmd): self.cmd(gcmd=gcmd, gcode='action_gcode') - cmd_CANCEL_WIZARD_STEP_help = "Run gcode in the 'cancel_gcode' section" + cmd_CANCEL_WIZARD_STEP_help = "Run gcode in the 'cancel_gcode' option" def cmd_CANCEL_WIZARD_STEP(self, gcmd): self.cmd(gcmd=gcmd, gcode='cancel_gcode') def cmd(self, gcmd, gcode): if self.in_script: - raise gcmd.error("Macro %s called recursively" % (self.name,)) - # update status to the wizard + raise gcmd.error("2054: Macro %s called recursively" % (self.name,)) wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) - wizard_obj.update_status(current_step=self.name) - # kwparams = {} - kwparams = dict(wizard_obj.variables) - kwparams.update(self.template_action.create_template_context()) + kwparams = self.template_action.create_template_context() + kwparams['wizard'] = wizard_obj.get_status() + kwparams['wizard'].update({'wizard_step_name': self.name}) kwparams['params'] = gcmd.get_command_parameters() kwparams['rawparams'] = gcmd.get_raw_command_parameters() - kwparams['wizard'] = wizard_name self.in_script = True try: if gcode == 'action_gcode': @@ -68,10 +55,8 @@ def cmd(self, gcmd, gcode): elif gcode == 'cancel_gcode': self.template_cancel.run_gcode_from_command(kwparams) finally: - # self.template_cancel.run_gcode_from_command(kwparams) self.in_script = False def load_config_prefix(config): return WizardStep(config) - diff --git a/klippy/extras/wizard/wizard_step_button.py b/klippy/extras/wizard/wizard_step_button.py index 28d345cc5688..243a65f06df6 100644 --- a/klippy/extras/wizard/wizard_step_button.py +++ b/klippy/extras/wizard/wizard_step_button.py @@ -3,7 +3,6 @@ class WizardStepButton(WizardStep): def __init__(self, config): - # super(WizardStepButton, self).__init__(config) WizardStep.__init__(self, config) # create template self.template_button = self.gcode_macro.load_template(config, 'button_%s_gcode' % self.name) @@ -15,17 +14,15 @@ def __init__(self, config): cmd_WIZARD_STEP_BUTTON_help = "Run gcode in the 'button_%s_gcode' section" def cmd_WIZARD_STEP_BUTTON(self, gcmd): if self.in_script: - raise gcmd.error("Macro %s called recursively" % (self.name,)) + raise gcmd.error("2054: Macro %s called recursively" % (self.name,)) # update status to the wizard wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) - wizard_obj.update_status(current_step=self.name) - # kwparams = {} - kwparams = dict(wizard_obj.variables) - kwparams.update(self.template_action.create_template_context()) + kwparams = self.template_action.create_template_context() + kwparams['wizard'] = wizard_obj.get_status() + kwparams['wizard'].update({'wizard_step_name': self.name}) kwparams['params'] = gcmd.get_command_parameters() kwparams['rawparams'] = gcmd.get_raw_command_parameters() - kwparams['wizard'] = wizard_name self.in_script = True try: self.template_button.run_gcode_from_command(kwparams) @@ -34,4 +31,3 @@ def cmd_WIZARD_STEP_BUTTON(self, gcmd): def load_config_prefix(config): return WizardStepButton(config) - diff --git a/klippy/extras/wizard/wizard_step_jog.py b/klippy/extras/wizard/wizard_step_jog.py index 15655cb66dce..96c14b5a3fba 100644 --- a/klippy/extras/wizard/wizard_step_jog.py +++ b/klippy/extras/wizard/wizard_step_jog.py @@ -3,12 +3,11 @@ class WizardStepJog(WizardStep): def __init__(self, config): - # super(WizardStepButton, self).__init__(config) WizardStep.__init__(self, config) # get options - self.axes = config.getlists('axes') + self.axes = config.getlists('axes', ['x', 'y', 'z']) self.steps = config.getfloatlist('steps') - self.default_step = config.getfloat('default_step') + self.default_step = config.getfloat('default_step', 10) # create template self.template_jog = self.gcode_macro.load_template(config, 'jog_gcode') # register gcode commands @@ -19,34 +18,35 @@ def __init__(self, config): self.name, self.cmd_WIZARD_STEP_SET_STEP, desc=self.cmd_WIZARD_STEP_SET_STEP_help) - cmd_WIZARD_STEP_SET_STEP_help = "set step for moving the axis" + cmd_WIZARD_STEP_SET_STEP_help = "Set step for moving the axis" def cmd_WIZARD_STEP_SET_STEP(self, gcmd): value = gcmd.get_float('VALUE') if value not in self.steps: raise gcmd.error( - "error setting the value:%s to move the axis, the value is out of range" % (value,)) + "2057: error setting the value:%s to move the axis, the value is out of range" % (value,)) self.default_step = value - cmd_WIZARD_STEP_JOG_help = "perform axis movement" + cmd_WIZARD_STEP_JOG_help = "Perform axis movement" def cmd_WIZARD_STEP_JOG(self, gcmd): axis = gcmd.get('AXIS').lower() + # get direction move, 1-positive, 0-negative moving + direction = gcmd.get('DIRECTION', 1) if axis not in self.axes: raise gcmd.error( - "error moved the axis:%s, the axis not availability" % (axis,)) + "2058: error moved the axis:%s, the axis not availability" % (axis,)) if self.in_script: - raise gcmd.error("Macro %s called recursively" % (self.name,)) + raise gcmd.error("2059: Macro %s called recursively" % (self.name,)) # update status to the wizard wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) - wizard_obj.update_status(current_step=self.name) - # kwparams = {} - kwparams = dict(wizard_obj.variables) - kwparams.update(self.template_action.create_template_context()) + kwparams = self.template_action.create_template_context() + kwparams['wizard'] = wizard_obj.get_status() + kwparams['wizard'].update({'wizard_step_name': self.name}) kwparams['params'] = gcmd.get_command_parameters() kwparams['rawparams'] = gcmd.get_raw_command_parameters() - kwparams['wizard'] = wizard_name kwparams['axis'] = axis kwparams['step'] = self.default_step + kwparams['direction'] = direction self.in_script = True try: self.template_jog.run_gcode_from_command(kwparams) @@ -58,4 +58,3 @@ def get_status(self, eventtime): def load_config_prefix(config): return WizardStepJog(config) - diff --git a/klippy/extras/wizard/wizard_step_selectors.py b/klippy/extras/wizard/wizard_step_selector.py similarity index 68% rename from klippy/extras/wizard/wizard_step_selectors.py rename to klippy/extras/wizard/wizard_step_selector.py index 7c310048c60a..9a4cfecf7eaf 100644 --- a/klippy/extras/wizard/wizard_step_selectors.py +++ b/klippy/extras/wizard/wizard_step_selector.py @@ -1,9 +1,10 @@ from wizard_step import WizardStep -class WizardStepSelectors(WizardStep): +class WizardStepSelector(WizardStep): def __init__(self, config): WizardStep.__init__(self, config) + self.selected = '' # get options self.items = config.getlists('items', []) # create template @@ -12,27 +13,22 @@ def __init__(self, config): self.gcode.register_mux_command("WIZARD_STEP_SELECT", 'STEP', self.name, self.cmd_WIZARD_STEP_SELECT, desc=self.cmd_WIZARD_STEP_SELECT_help) - self.selected = '' cmd_WIZARD_STEP_SELECT_help = "Run gcode in the 'select_gcode' section" def cmd_WIZARD_STEP_SELECT(self, gcmd): if self.in_script: - raise gcmd.error("Macro %s called recursively" % (self.name,)) + raise gcmd.error("2054: Macro %s called recursively" % (self.name,)) selected = gcmd.get('ITEM') if selected not in self.items: - raise gcmd.error("the selected item %s not in the items %s" % (selected, self.items)) + raise gcmd.error("2056: The selected item %s not in the items %s" % (selected, self.items)) self.selected = selected - # update status to the wizard wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) - wizard_obj.update_status(current_step=self.name) - # kwparams = {} - # create context - kwparams = dict(wizard_obj.variables) - kwparams.update(self.template_action.create_template_context()) + kwparams = self.template_action.create_template_context() + kwparams['wizard'] = wizard_obj.get_status() + kwparams['wizard'].update({'wizard_step_name': self.name}) kwparams['params'] = gcmd.get_command_parameters() kwparams['rawparams'] = gcmd.get_raw_command_parameters() - kwparams['wizard'] = wizard_name kwparams['selected'] = self.selected self.in_script = True try: @@ -41,9 +37,9 @@ def cmd_WIZARD_STEP_SELECT(self, gcmd): self.in_script = False def get_status(self, eventtime): - state = {'selected': self.selected} - return state + return {'selected': self.selected + } def load_config_prefix(config): - return WizardStepSelectors(config) + return WizardStepSelector(config) diff --git a/klippy/extras/wizard/wizard_step_slider.py b/klippy/extras/wizard/wizard_step_slider.py index f2c7d1a1202d..a13f17843545 100644 --- a/klippy/extras/wizard/wizard_step_slider.py +++ b/klippy/extras/wizard/wizard_step_slider.py @@ -3,12 +3,13 @@ class WizardStepSlider(WizardStep): def __init__(self, config): - # super(WizardStepButton, self).__init__(config) WizardStep.__init__(self, config) + # get options from config self.slider_data = {} options = config.get_prefix_options('slider') for option in options: self.slider_data.update({option: config.getint(option)}) + # register gcode commands self.gcode.register_mux_command("WIZARD_STEP_SLIDER", 'SLIDER', self.name, self.cmd_WIZARD_STEP_SLIDER, desc=self.cmd_WIZARD_STEP_SLIDER_help) @@ -18,7 +19,7 @@ def cmd_WIZARD_STEP_SLIDER(self, gcmd): variable = gcmd.get('VARIABLE').lower() value = gcmd.get_int('VALUE') if variable not in self.slider_data: - raise gcmd.error("failure set value:%s to variable:%s in the slider %s" % (value, variable, self.name)) + raise gcmd.error("2055: Failure set value:%s to variable:%s in the slider %s" % (value, variable, self.name)) self.slider_data.update({variable: value}) def get_status(self, eventtime): @@ -26,4 +27,3 @@ def get_status(self, eventtime): def load_config_prefix(config): return WizardStepSlider(config) - diff --git a/klippy/extras/wizard/wizard_step_wizards.py b/klippy/extras/wizard/wizard_step_wizards.py index 5bddd0dff54a..ef644feff1db 100644 --- a/klippy/extras/wizard/wizard_step_wizards.py +++ b/klippy/extras/wizard/wizard_step_wizards.py @@ -8,4 +8,3 @@ def __init__(self, config): def load_config_prefix(config): return WizardStepWizards(config) - diff --git a/stereotech_config/wizards/change_material.cfg b/stereotech_config/wizards/change_material.cfg new file mode 100644 index 000000000000..dba82f5e1211 --- /dev/null +++ b/stereotech_config/wizards/change_material.cfg @@ -0,0 +1,231 @@ +[wizard CHANGE_MATERIAL] +image: wizards/change_material/change_material.jpg +type: any +steps: CHANGE_MATERIAL_0, STEP_2 +variable_needed_action: '' +variable_manufacturer_select: '' +variable_seria_select: '' + + + +# ---------------------------------------------------------------------------step0 + +[wizard_step CHANGE_MATERIAL_0] +image: wizards/change_material/change_material.jpg +landscape: false +description: This wizard will help you to change insert or remove the material +warning: none +countdown: 0 +info: none +action_gcode: + {action_respond_info('-------------------start CHANGE_MATERIAL_0')} + SET_WIZARD_ENABLE WIZARD=CHANGE_MATERIAL ENABLE=1 # ERROR=error_message +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_0')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step_button CHANGE_MATERIAL_BUTTON_0] +image: none +landscape: false +description: START +warning: none +countdown: none +info: none +button_STEP_BUTTON_1_gcode: + {action_respond_info('-------------------CHANGE_MATERIAL_BUTTON_0')} + {% if printer.extruders|int > 1 %} + SET_WIZARD_STEP WIZARD=CHANGE_MATERIAL STEP=CHANGE_MATERIAL_1 + {% else %} + SET_WIZARD_STEP WIZARD=CHANGE_MATERIAL STEP=CHANGE_MATERIAL_2 + ACTIVATE_EXTRUDER EXTRUDER=extruder + {% endif %} +action_gcode: + # pass +cancel_gcode: + # pass + +# ---------------------------------------------------------------------------step1 + +[wizard_step CHANGE_MATERIAL_1] +image: wizards/change_material/change_material01.jpg +landscape: false +description: Select the extruder where you want change the material +warning: none +countdown: 1 +info: none +action_gcode: + # pass +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_0')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step_selector CHANGE_MATERIAL_SELECTOR_1] +image: none +landscape: false +description: none +warning: none +countdown: none +info: none +items: extruder, extruder1 +#select_gcode: +action_gcode: + {% set selected = printer['wizard_step_selector CHANGE_MATERIAL_SELECTOR_1'].selected %} + ACTIVATE_EXTRUDER EXTRUDER={selected} + SET_WIZARD_STEP WIZARD={wizard.name} STEP={} +cancel_gcode: + # pass + +[wizard_step_button CHANGE_MATERIAL_BUTTON_1] +image: none +landscape: false +description: NEXT +warning: none +countdown: none +info: none +button_STEP_BUTTON_1_gcode: + {action_respond_info('-------------------CHANGE_MATERIAL_BUTTON_1')} + SET_WIZARD_STEP WIZARD=CHANGE_MATERIAL STEP=CHANGE_MATERIAL_2 +action_gcode: + # pass +cancel_gcode: + # pass + +# ---------------------------------------------------------------------------step2 + +[wizard_step CHANGE_MATERIAL_2] +image: wizards/change_material/change_material02.jpg +landscape: false +description: Select the needed action +warning: none +countdown: 2 +info: none +action_gcode: + # pass +cancel_gcode: + {action_respond_info('------------------CANCEL STEP_0')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step_selector CHANGE_MATERIAL_SELECTOR_2] +image: none +landscape: false +description: none +warning: none +countdown: none +info: none +items: Insert, Change, Remove +select_gcode: + {action_respond_info('-------------------select_gcode CHANGE_MATERIAL_SELECTOR_2 selected=%s, wizard=%s' % (selected, wizard))} + SET_WIZARD_VARIABLE WIZARD={wizard.name} VARIABLE=needed_action VALUE={selected} +action_gcode: + # pass +cancel_gcode: + # pass + +[wizard_step_button CHANGE_MATERIAL_BUTTON_2] +image: none +landscape: false +description: NEXT +warning: none +countdown: none +info: none +button_STEP_BUTTON_1_gcode: + {action_respond_info('-------------------CHANGE_MATERIAL_BUTTON_2')} + {% if wizard.variables['needed_action'] == 'Insert' %} + SET_WIZARD_STEP WIZARD={wizard} STEP=CHANGE_MATERIAL_4 # ?????????????????????????? + {% else %} + SET_WIZARD_STEP WIZARD={wizard} STEP=CHANGE_MATERIAL_3 + {% endif %} +action_gcode: + # pass +cancel_gcode: + # pass + +# ---------------------------------------------------------------------------step3 + +[wizard_step CHANGE_MATERIAL_3] +# change or reemove material +image: wizards/change_material/change_material02.jpg +landscape: false +description: Select Current Material +warning: none +countdown: 2 +info: none +action_gcode: + # pass +cancel_gcode: + {action_respond_info('------------------CANCEL CHANGE_MATERIAL_3')} + RESET_WIZARD WIZARD={wizard} + # HOME_POSITION ABORT=1 + +[wizard_step_selector CHANGE_MATERIAL_SELECTOR_3_0] +image: none +landscape: false +description: Manufacturer select +warning: none +countdown: none +info: none +items: Stereotech, Another +select_gcode: + {action_respond_info('-------------------select_gcode CHANGE_MATERIAL_SELECTOR_3_0 selected=%s, wizard=%s' % (selected, wizard))} + SET_WIZARD_VARIABLE WIZARD={wizard} VARIABLE=manufacturer_select VALUE={selected} +action_gcode: + # pass +cancel_gcode: + # pass + +[wizard_step_selector CHANGE_MATERIAL_SELECTOR_3_1] +image: none +landscape: false +description: Seria select +warning: none +countdown: none +info: none +items: Proto, Enduse, Fiberpart, Sealant +select_gcode: + {action_respond_info('-------------------select_gcode CHANGE_MATERIAL_SELECTOR_2 selected=%s, wizard=%s' % (selected, wizard))} + SET_WIZARD_VARIABLE WIZARD={wizard} VARIABLE=seria_select VALUE={selected} + WIZARD_STEP_SELECT WIZARD={wizard} STEP=CHANGE_MATERIAL_SELECTOR_3_2 ITEM= +action_gcode: + # pass +cancel_gcode: + # pass + +Name select +ABS G4 +# step 4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +[wizard_step_selector CHANGE_MATERIAL_SELECTOR_3_2] +image: none +landscape: false +description: Name selected +warning: none +countdown: none +info: none +items: PLA, PVA, Remove +select_gcode: + {action_respond_info('-------------------select_gcode CHANGE_MATERIAL_SELECTOR_2 selected=%s, wizard=%s' % (selected, wizard))} + SET_WIZARD_VARIABLE WIZARD={wizard} VARIABLE=data1 VALUE={selected} +action_gcode: + # pass +cancel_gcode: + # pass + + +[wizard_step_selector MY] +image: none +landscape: false +description: none +warning: none +countdown: none +info: none +items: PLA, PVA, Remove +select_gcode: + {action_respond_info('-------------------select_gcode CHANGE_MATERIAL_SELECTOR_2 selected=%s, wizard=%s' % (selected, wizard))} + SET_WIZARD_VARIABLE WIZARD={wizard} VARIABLE=data1 VALUE={selected} +action_gcode: + # pass +cancel_gcode: + # pass \ No newline at end of file diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg index 40ae26e4fbf5..b3a826e54171 100644 --- a/stereotech_config/wizards/wizards.cfg +++ b/stereotech_config/wizards/wizards.cfg @@ -36,7 +36,7 @@ [wizard CALIBRATE] image: path/to/image/wizard/CALIBRATE type: 3d, 5d, any -steps: STEP_1, STEP_2 +steps: STEP_0, STEP_BUTTON_1, STEP_WIZARDS_1, STEP_SELECTOR_1, STEP_SLIDER_1 variable_a: 1 variable_b: 2 @@ -48,39 +48,11 @@ warning: warning STEP_0 countdown: 10 info: info about STSTEP_0 action_gcode: + SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} {action_respond_info('-------------------start STEP_0')} cancel_gcode: {action_respond_info('------------------CANCEL STEP_0')} - RESET_WIZARD WIZARD={wizard} - # HOME_POSITION ABORT=1 - -[wizard_step STEP_1] -image: path/to/image/wizard/STEP_1 -landscape: false -description: description STEP_1 -warning: warning STEP_1 -countdown: 10 -info: info about STEP_1 -action_gcode: - {action_respond_info('-------------------start STEP_1')} -cancel_gcode: - {action_respond_info('------------------CANCEL STEP_1')} - RESET_WIZARD WIZARD={wizard} - # HOME_POSITION ABORT=1 - -[wizard_step STEP_2] -image: path/to/image/wizard/STEP_2 -landscape: false -description: description STEP_2 -warning: warning STEP_2 -countdown: 20 -info: info about STEP_2 -action_gcode: - {action_respond_info('-------------------start STEP_2')} -cancel_gcode: - {action_respond_info('------------------CANCEL STEP_2')} - RESET_WIZARD WIZARD={wizard} - # HOME_POSITION ABORT=1 + RESET_WIZARD WIZARD={wizard.name} [wizard_step_button STEP_BUTTON_1] image: path/to/image/wizard/STEP_BUTTON_1 @@ -92,11 +64,11 @@ info: info about STEP_BUTTON_1 button_STEP_BUTTON_1_gcode: {action_respond_info('-------------------button_STEP_BUTTON_1_gcode')} action_gcode: - {action_respond_info('-------------------start STEP_BUTTON_1')} + {action_respond_info('-------------------action_gcode STEP_BUTTON_1')} + SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} cancel_gcode: - {action_respond_info('------------------CANCEL STEP_BUTTON_1')} - RESET_WIZARD WIZARD={wizard} - # HOME_POSITION ABORT=1 + {action_respond_info('------------------cancel_gcode STEP_BUTTON_1')} + RESET_WIZARD WIZARD={wizard.name} [wizard_step_wizards STEP_WIZARDS_1] image: path/to/image/wizard/STEP_WIZARDS_1 @@ -107,11 +79,11 @@ countdown: 20 info: info about STEP_WIZARDS_1 wizards: wizard1, wizard2 action_gcode: - {action_respond_info('-------------------start STEP_WIZARDS_1')} + {action_respond_info('-------------------action_gcode STEP_WIZARDS_1')} + SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} cancel_gcode: - {action_respond_info('------------------CANCEL STEP_WIZARDS_1')} - RESET_WIZARD WIZARD={wizard} - # HOME_POSITION ABORT=1 + {action_respond_info('------------------cancel_gcode STEP_WIZARDS_1')} + RESET_WIZARD WIZARD={wizard.name} [wizard_step_selectors STEP_SELECTOR_1] image: path/to/image/wizard/STEP_SELECTOR_1 @@ -124,10 +96,11 @@ items: item1, item2, item3 select_gcode: {action_respond_info('-------------------select_gcode STEP_SELECTOR_1 selected=%s, wizard=%s' % (selected, wizard))} action_gcode: - {action_respond_info('-------------------start STEP_SELECTOR_1')} + {action_respond_info('-------------------action_gcode STEP_SELECTOR_1')} + SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} cancel_gcode: - {action_respond_info('------------------CANCEL STEP_SELECTOR_1')} - RESET_WIZARD WIZARD={wizard} + {action_respond_info('------------------cancel_gcode STEP_SELECTOR_1')} + RESET_WIZARD WIZARD={wizard.name} # HOME_POSITION ABORT=1 [wizard_step_slider STEP_SLIDER_1] @@ -142,10 +115,11 @@ slider_STEP_SLIDER_1_max: 100 slider_STEP_SLIDER_1_step: 1 slider_STEP_SLIDER_1_default: 20 action_gcode: - {action_respond_info('-------------------start STEP_SELECTOR_1')} + {action_respond_info('-------------------action_gcode STEP_SELECTOR_1')} + SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} cancel_gcode: - {action_respond_info('------------------CANCEL STEP_SELECTOR_1')} - RESET_WIZARD WIZARD={wizard} + {action_respond_info('------------------cancel_gcode STEP_SELECTOR_1')} + RESET_WIZARD WIZARD={wizard.name} # HOME_POSITION ABORT=1 [wizard_step_jog STEP_JOG_1] @@ -161,8 +135,31 @@ default_step: 10 jog_gcode: {action_respond_info('-------------------jog_gcode STEP_JOG_1 axis=%s, step=%s' % (axis, step))} action_gcode: - {action_respond_info('-------------------start STEP_JOG_1')} + {action_respond_info('-------------------action_gcode STEP_JOG_1')} + SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} cancel_gcode: - {action_respond_info('------------------CANCEL STEP_JOG_1')} - RESET_WIZARD WIZARD={wizard} + {action_respond_info('------------------cancel_gcode STEP_JOG_1')} + RESET_WIZARD WIZARD={wizard.name} # HOME_POSITION ABORT=1 + + +# ???????????????????????????????? + +# [wizard_step_material-selector material-selector_1] +# image: path/to/image/wizard/STEP_JOG_1 +# landscape: false +# description: description STEP_JOG_1 +# warning: warning STEP_JOG_1 +# countdown: 20 +# info: info about STEP_JOG_1 +# axes: x, y, z, a, c +# steps: 0.1, 1, 10, 20 +# default_step: 10 +# jog_gcode: +# {action_respond_info('-------------------jog_gcode STEP_JOG_1 axis=%s, step=%s' % (axis, step))} +# action_gcode: +# {action_respond_info('-------------------start STEP_JOG_1')} +# cancel_gcode: +# {action_respond_info('------------------CANCEL STEP_JOG_1')} +# RESET_WIZARD WIZARD={wizard.name} +# # HOME_POSITION ABORT=1 \ No newline at end of file From cc840da8a9048fef3548de70da1f84e7e6a0155e Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Mon, 18 Dec 2023 14:04:42 +0000 Subject: [PATCH 10/13] STEAPP-842: added code error --- docs/stereotech/error_list_guide.txt | 10 ++++++++++ klippy/extras/wizard/__init__.py | 3 +-- klippy/extras/wizard/wizard.py | 3 +-- stereotech_config/wizards/wizards.cfg | 25 +++++++++++++------------ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/docs/stereotech/error_list_guide.txt b/docs/stereotech/error_list_guide.txt index 9bae5f8f821e..ca64d1294743 100644 --- a/docs/stereotech/error_list_guide.txt +++ b/docs/stereotech/error_list_guide.txt @@ -112,6 +112,16 @@ config: 2047: auto_wcs: improperly formatted entry for point %s 2048: The parameter value is out of range, param=%smm max=%smm, min=0.0mm. Check params. 2049: Large difference between two values (x1-x2 or y1-y2), maximum difference=%smm. Check the parameters. + 2050: No module named %s, error: %s + 2051: Unknown wizard variable '%s' + 2052: Unable to parse '%s' as a literal: %s + 2053: Unknown step: '%s' + 2054: Macro %s called recursively + 2055: Failure set value:%s to variable:%s in the slider %s + 2056: The selected item %s not in the items %s + 2057: error setting the value:%s to move the axis, the value is out of range + 2058: error moved the axis:%s, the axis not availability + 2059: Macro %s called recursively перефирия(mcu): 301: Timeout on wait for '%s' response diff --git a/klippy/extras/wizard/__init__.py b/klippy/extras/wizard/__init__.py index 50af2078a78d..b843bc586528 100644 --- a/klippy/extras/wizard/__init__.py +++ b/klippy/extras/wizard/__init__.py @@ -5,7 +5,6 @@ def load_config_prefix(config): mod_name = 'extras.wizard.' + config.get_name().split()[0] try: mod = importlib.import_module(mod_name) - # init_func = getattr(mod, init_func, None) - mod.load_config_prefix(config) + return mod.load_config_prefix(config) except Exception as e: raise Exception('2050: No module named %s, error: %s' % (mod_name, e)) diff --git a/klippy/extras/wizard/wizard.py b/klippy/extras/wizard/wizard.py index 11513a092ac5..663d8bfa6cb1 100644 --- a/klippy/extras/wizard/wizard.py +++ b/klippy/extras/wizard/wizard.py @@ -1,5 +1,4 @@ -import traceback, logging, ast, copy, json -import jinja2 +import ast, json class Wizard: diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg index b3a826e54171..b60f70140d77 100644 --- a/stereotech_config/wizards/wizards.cfg +++ b/stereotech_config/wizards/wizards.cfg @@ -1,12 +1,12 @@ # wizard # SET_WIZARD_ENABLE WIZARD=CALIBRATE ENABLE=1 ERROR=error_message -# SET_WIZARD_STEP WIZARD=MY STEP=step1 -# SET_WIZARD_VARIABLE WIZARD=MY VARIABLE= VALUE= -# RESET_WIZARD WIZARD=MY +# SET_WIZARD_STEP WIZARD=CALIBRATE STEP=step1 +# SET_WIZARD_VARIABLE WIZARD=CALIBRATE VARIABLE=a VALUE=17 +# RESET_WIZARD WIZARD=CALIBRATE # wizard_step -# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_1 -# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_1 +# CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_0 +# EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_0 # wizard_step_button # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 @@ -30,13 +30,13 @@ # wizard_step_jog # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 -# WIZARD_STEP_JOG WIZARD=CALIBRATE STEP=STEP_JOG_1 AXIS=z -# WIZARD_STEP_SET_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 VALUE=50 +# WIZARD_STEP_JOG WIZARD=CALIBRATE STEP=STEP_JOG_1 AXIS=z DIRECTION=0 +# WIZARD_STEP_SET_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 VALUE=20 [wizard CALIBRATE] image: path/to/image/wizard/CALIBRATE type: 3d, 5d, any -steps: STEP_0, STEP_BUTTON_1, STEP_WIZARDS_1, STEP_SELECTOR_1, STEP_SLIDER_1 +steps: STEP_0, STEP_BUTTON_1, STEP_WIZARDS_1, STEP_SELECTOR_1, STEP_SLIDER_1, STEP_JOG_1 variable_a: 1 variable_b: 2 @@ -85,7 +85,7 @@ cancel_gcode: {action_respond_info('------------------cancel_gcode STEP_WIZARDS_1')} RESET_WIZARD WIZARD={wizard.name} -[wizard_step_selectors STEP_SELECTOR_1] +[wizard_step_selector STEP_SELECTOR_1] image: path/to/image/wizard/STEP_SELECTOR_1 landscape: false description: description STEP_SELECTOR_1 @@ -94,7 +94,7 @@ countdown: 20 info: info about STEP_SELECTOR_1 items: item1, item2, item3 select_gcode: - {action_respond_info('-------------------select_gcode STEP_SELECTOR_1 selected=%s, wizard=%s' % (selected, wizard))} + {action_respond_info('-------------------select_gcode STEP_SELECTOR_1 selected=%s, wizard=%s' % (selected, wizard.name))} action_gcode: {action_respond_info('-------------------action_gcode STEP_SELECTOR_1')} SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} @@ -133,9 +133,10 @@ axes: x, y, z, a, c steps: 0.1, 1, 10, 20 default_step: 10 jog_gcode: - {action_respond_info('-------------------jog_gcode STEP_JOG_1 axis=%s, step=%s' % (axis, step))} + {action_respond_info('-------------------jog_gcode STEP_JOG_1 (G1 %s%s, direction=%s)' % (axis|upper, step, direction))} action_gcode: {action_respond_info('-------------------action_gcode STEP_JOG_1')} + SET_WIZARD_ENABLE WIZARD=CALIBRATE ENABLE=1 ERROR=error_message SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} cancel_gcode: {action_respond_info('------------------cancel_gcode STEP_JOG_1')} @@ -156,7 +157,7 @@ cancel_gcode: # steps: 0.1, 1, 10, 20 # default_step: 10 # jog_gcode: -# {action_respond_info('-------------------jog_gcode STEP_JOG_1 axis=%s, step=%s' % (axis, step))} +# {action_respond_info('-------------------jog_gcode STEP_JOG_1 axis=%s, step=%s,' % (axis, step))} # action_gcode: # {action_respond_info('-------------------start STEP_JOG_1')} # cancel_gcode: From 353d1959891141b321f7b387b154f8d8371dba5e Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Mon, 18 Dec 2023 14:36:42 +0000 Subject: [PATCH 11/13] STEAPP-842: formatted the files --- klippy/extras/wizard/wizard.py | 14 ++++++++++---- klippy/extras/wizard/wizard_step.py | 15 ++++++++++----- klippy/extras/wizard/wizard_step_button.py | 8 ++++++-- klippy/extras/wizard/wizard_step_jog.py | 6 +++++- klippy/extras/wizard/wizard_step_selector.py | 11 +++++++---- klippy/extras/wizard/wizard_step_slider.py | 5 ++++- klippy/extras/wizard/wizard_step_wizards.py | 1 + 7 files changed, 43 insertions(+), 17 deletions(-) diff --git a/klippy/extras/wizard/wizard.py b/klippy/extras/wizard/wizard.py index 663d8bfa6cb1..e607b805daa3 100644 --- a/klippy/extras/wizard/wizard.py +++ b/klippy/extras/wizard/wizard.py @@ -1,12 +1,13 @@ -import ast, json +import ast +import json class Wizard: def __init__(self, config): if len(config.get_name().split()) > 2: raise config.error( - "Name of section '%s' contains illegal whitespace" - % (config.get_name())) + "Name of section '%s' contains illegal whitespace" + % (config.get_name())) self.name = config.get_name().split()[1] self.enabled = False self.error = '' @@ -55,11 +56,13 @@ def get_status(self, eventtime=None): 'type': self.type} cmd_SET_WIZARD_VARIABLE_help = "Set the value of a wizard variable to wizard" + def cmd_SET_WIZARD_VARIABLE(self, gcmd): variable = gcmd.get('VARIABLE') value = gcmd.get('VALUE') if variable not in self.variables: - raise gcmd.error("2051: Unknown wizard variable '%s'" % (variable,)) + raise gcmd.error( + "2051: Unknown wizard variable '%s'" % (variable,)) try: literal = ast.literal_eval(value) json.dumps(literal, separators=(',', ':')) @@ -71,11 +74,13 @@ def cmd_SET_WIZARD_VARIABLE(self, gcmd): self.variables = v cmd_SET_WIZARD_ENABLE_help = "Set the enable to WIZARD" + def cmd_SET_WIZARD_ENABLE(self, gcmd): self.enabled = True if gcmd.get_int('ENABLE', self.enabled) else False self.error = gcmd.get('ERROR', self.error) cmd_SET_WIZARD_STEP_help = "Set the step to WIZARD" + def cmd_SET_WIZARD_STEP(self, gcmd): step = gcmd.get('STEP') if step not in self.steps: @@ -83,6 +88,7 @@ def cmd_SET_WIZARD_STEP(self, gcmd): self.current_step = step cmd_RESET_WIZARD_help = "Reset state the wizard" + def cmd_RESET_WIZARD(self, gcmd): self.error = '' self.enabled = False diff --git a/klippy/extras/wizard/wizard_step.py b/klippy/extras/wizard/wizard_step.py index d1bb6b19a65d..0d37fa8d6b73 100644 --- a/klippy/extras/wizard/wizard_step.py +++ b/klippy/extras/wizard/wizard_step.py @@ -2,8 +2,8 @@ class WizardStep: def __init__(self, config): if len(config.get_name().split()) > 2: raise config.error( - "Name of section '%s' contains illegal whitespace" - % (config.get_name())) + "Name of section '%s' contains illegal whitespace" + % (config.get_name())) section_name = config.get_name().split() self.name = section_name[1].upper() self.in_script = False @@ -20,8 +20,10 @@ def __init__(self, config): self.info = config.get('info', '') self.countdown = config.getint('countdown', 0) # create template - self.template_action = self.gcode_macro.load_template(config, 'action_gcode') - self.template_cancel = self.gcode_macro.load_template(config, 'cancel_gcode') + self.template_action = self.gcode_macro.load_template( + config, 'action_gcode') + self.template_cancel = self.gcode_macro.load_template( + config, 'cancel_gcode') # register gcode commands self.gcode.register_mux_command("EXECUTE_WIZARD_STEP", 'STEP', self.name, self.cmd_EXECUTE_WIZARD_STEP, @@ -31,16 +33,19 @@ def __init__(self, config): desc=self.cmd_CANCEL_WIZARD_STEP_help) cmd_EXECUTE_WIZARD_STEP_help = "Run gcode in the 'action_gcode' option" + def cmd_EXECUTE_WIZARD_STEP(self, gcmd): self.cmd(gcmd=gcmd, gcode='action_gcode') cmd_CANCEL_WIZARD_STEP_help = "Run gcode in the 'cancel_gcode' option" + def cmd_CANCEL_WIZARD_STEP(self, gcmd): self.cmd(gcmd=gcmd, gcode='cancel_gcode') def cmd(self, gcmd, gcode): if self.in_script: - raise gcmd.error("2054: Macro %s called recursively" % (self.name,)) + raise gcmd.error( + "2054: Macro %s called recursively" % (self.name,)) wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) kwparams = self.template_action.create_template_context() diff --git a/klippy/extras/wizard/wizard_step_button.py b/klippy/extras/wizard/wizard_step_button.py index 243a65f06df6..6d253b944c13 100644 --- a/klippy/extras/wizard/wizard_step_button.py +++ b/klippy/extras/wizard/wizard_step_button.py @@ -5,16 +5,19 @@ class WizardStepButton(WizardStep): def __init__(self, config): WizardStep.__init__(self, config) # create template - self.template_button = self.gcode_macro.load_template(config, 'button_%s_gcode' % self.name) + self.template_button = self.gcode_macro.load_template( + config, 'button_%s_gcode' % self.name) # register commands self.gcode.register_mux_command("WIZARD_STEP_BUTTON", 'BUTTON', self.name, self.cmd_WIZARD_STEP_BUTTON, desc=self.cmd_WIZARD_STEP_BUTTON_help) cmd_WIZARD_STEP_BUTTON_help = "Run gcode in the 'button_%s_gcode' section" + def cmd_WIZARD_STEP_BUTTON(self, gcmd): if self.in_script: - raise gcmd.error("2054: Macro %s called recursively" % (self.name,)) + raise gcmd.error( + "2054: Macro %s called recursively" % (self.name,)) # update status to the wizard wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) @@ -29,5 +32,6 @@ def cmd_WIZARD_STEP_BUTTON(self, gcmd): finally: self.in_script = False + def load_config_prefix(config): return WizardStepButton(config) diff --git a/klippy/extras/wizard/wizard_step_jog.py b/klippy/extras/wizard/wizard_step_jog.py index 96c14b5a3fba..89498fcf3055 100644 --- a/klippy/extras/wizard/wizard_step_jog.py +++ b/klippy/extras/wizard/wizard_step_jog.py @@ -19,6 +19,7 @@ def __init__(self, config): desc=self.cmd_WIZARD_STEP_SET_STEP_help) cmd_WIZARD_STEP_SET_STEP_help = "Set step for moving the axis" + def cmd_WIZARD_STEP_SET_STEP(self, gcmd): value = gcmd.get_float('VALUE') if value not in self.steps: @@ -27,6 +28,7 @@ def cmd_WIZARD_STEP_SET_STEP(self, gcmd): self.default_step = value cmd_WIZARD_STEP_JOG_help = "Perform axis movement" + def cmd_WIZARD_STEP_JOG(self, gcmd): axis = gcmd.get('AXIS').lower() # get direction move, 1-positive, 0-negative moving @@ -35,7 +37,8 @@ def cmd_WIZARD_STEP_JOG(self, gcmd): raise gcmd.error( "2058: error moved the axis:%s, the axis not availability" % (axis,)) if self.in_script: - raise gcmd.error("2059: Macro %s called recursively" % (self.name,)) + raise gcmd.error( + "2059: Macro %s called recursively" % (self.name,)) # update status to the wizard wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) @@ -56,5 +59,6 @@ def cmd_WIZARD_STEP_JOG(self, gcmd): def get_status(self, eventtime): return {'step': self.default_step} + def load_config_prefix(config): return WizardStepJog(config) diff --git a/klippy/extras/wizard/wizard_step_selector.py b/klippy/extras/wizard/wizard_step_selector.py index 9a4cfecf7eaf..f5e314f8beca 100644 --- a/klippy/extras/wizard/wizard_step_selector.py +++ b/klippy/extras/wizard/wizard_step_selector.py @@ -15,12 +15,15 @@ def __init__(self, config): desc=self.cmd_WIZARD_STEP_SELECT_help) cmd_WIZARD_STEP_SELECT_help = "Run gcode in the 'select_gcode' section" + def cmd_WIZARD_STEP_SELECT(self, gcmd): if self.in_script: - raise gcmd.error("2054: Macro %s called recursively" % (self.name,)) + raise gcmd.error( + "2054: Macro %s called recursively" % (self.name,)) selected = gcmd.get('ITEM') if selected not in self.items: - raise gcmd.error("2056: The selected item %s not in the items %s" % (selected, self.items)) + raise gcmd.error( + "2056: The selected item %s not in the items %s" % (selected, self.items)) self.selected = selected wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) @@ -38,8 +41,8 @@ def cmd_WIZARD_STEP_SELECT(self, gcmd): def get_status(self, eventtime): return {'selected': self.selected - } + } + def load_config_prefix(config): return WizardStepSelector(config) - diff --git a/klippy/extras/wizard/wizard_step_slider.py b/klippy/extras/wizard/wizard_step_slider.py index a13f17843545..42b6f327fb21 100644 --- a/klippy/extras/wizard/wizard_step_slider.py +++ b/klippy/extras/wizard/wizard_step_slider.py @@ -15,15 +15,18 @@ def __init__(self, config): desc=self.cmd_WIZARD_STEP_SLIDER_help) cmd_WIZARD_STEP_SLIDER_help = "update value to the slider data" + def cmd_WIZARD_STEP_SLIDER(self, gcmd): variable = gcmd.get('VARIABLE').lower() value = gcmd.get_int('VALUE') if variable not in self.slider_data: - raise gcmd.error("2055: Failure set value:%s to variable:%s in the slider %s" % (value, variable, self.name)) + raise gcmd.error("2055: Failure set value:%s to variable:%s in the slider %s" % ( + value, variable, self.name)) self.slider_data.update({variable: value}) def get_status(self, eventtime): return self.slider_data + def load_config_prefix(config): return WizardStepSlider(config) diff --git a/klippy/extras/wizard/wizard_step_wizards.py b/klippy/extras/wizard/wizard_step_wizards.py index ef644feff1db..bdb53d7a975a 100644 --- a/klippy/extras/wizard/wizard_step_wizards.py +++ b/klippy/extras/wizard/wizard_step_wizards.py @@ -6,5 +6,6 @@ def __init__(self, config): WizardStep.__init__(self, config) self.wizards = config.getlists('wizards', []) + def load_config_prefix(config): return WizardStepWizards(config) From 4b17679037536d3ff0bd5b21db90f7e712c5cc22 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Thu, 28 Dec 2023 11:47:41 +0000 Subject: [PATCH 12/13] STEAPP-841: added dynamic loading of button templates --- docs/stereotech/error_list_guide.txt | 1 + klippy/extras/wizard/wizard_step_button.py | 22 +++++++++++++------- klippy/extras/wizard/wizard_step_slider.py | 2 +- stereotech_config/wizards/wizards.cfg | 24 ++++++++++++++-------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/docs/stereotech/error_list_guide.txt b/docs/stereotech/error_list_guide.txt index ca64d1294743..ef1eadc4212d 100644 --- a/docs/stereotech/error_list_guide.txt +++ b/docs/stereotech/error_list_guide.txt @@ -122,6 +122,7 @@ config: 2057: error setting the value:%s to move the axis, the value is out of range 2058: error moved the axis:%s, the axis not availability 2059: Macro %s called recursively + 2060: The button '%s' does not exist перефирия(mcu): 301: Timeout on wait for '%s' response diff --git a/klippy/extras/wizard/wizard_step_button.py b/klippy/extras/wizard/wizard_step_button.py index 6d253b944c13..7bf925983e4e 100644 --- a/klippy/extras/wizard/wizard_step_button.py +++ b/klippy/extras/wizard/wizard_step_button.py @@ -4,11 +4,15 @@ class WizardStepButton(WizardStep): def __init__(self, config): WizardStep.__init__(self, config) - # create template - self.template_button = self.gcode_macro.load_template( - config, 'button_%s_gcode' % self.name) + # create template for buttons + self.templates = {} + buttons = config.get_prefix_options('button') + for button in buttons: + template_button = self.gcode_macro.load_template( + config, button) + self.templates.update({button: template_button}) # register commands - self.gcode.register_mux_command("WIZARD_STEP_BUTTON", 'BUTTON', + self.gcode.register_mux_command("WIZARD_STEP_BUTTON", 'STEP', self.name, self.cmd_WIZARD_STEP_BUTTON, desc=self.cmd_WIZARD_STEP_BUTTON_help) @@ -18,17 +22,21 @@ def cmd_WIZARD_STEP_BUTTON(self, gcmd): if self.in_script: raise gcmd.error( "2054: Macro %s called recursively" % (self.name,)) - # update status to the wizard wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) - kwparams = self.template_action.create_template_context() + button = gcmd.get('BUTTON') + template_button = self.templates.get(button, None) + if template_button is None: + raise gcmd.error( + "2060: The button '%s' does not exist" % (button,)) + kwparams = template_button.create_template_context() kwparams['wizard'] = wizard_obj.get_status() kwparams['wizard'].update({'wizard_step_name': self.name}) kwparams['params'] = gcmd.get_command_parameters() kwparams['rawparams'] = gcmd.get_raw_command_parameters() self.in_script = True try: - self.template_button.run_gcode_from_command(kwparams) + template_button.run_gcode_from_command(kwparams) finally: self.in_script = False diff --git a/klippy/extras/wizard/wizard_step_slider.py b/klippy/extras/wizard/wizard_step_slider.py index 42b6f327fb21..8deb82fd3507 100644 --- a/klippy/extras/wizard/wizard_step_slider.py +++ b/klippy/extras/wizard/wizard_step_slider.py @@ -18,7 +18,7 @@ def __init__(self, config): def cmd_WIZARD_STEP_SLIDER(self, gcmd): variable = gcmd.get('VARIABLE').lower() - value = gcmd.get_int('VALUE') + value = gcmd.get_float('VALUE') if variable not in self.slider_data: raise gcmd.error("2055: Failure set value:%s to variable:%s in the slider %s" % ( value, variable, self.name)) diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg index b60f70140d77..5e6b983c6e7f 100644 --- a/stereotech_config/wizards/wizards.cfg +++ b/stereotech_config/wizards/wizards.cfg @@ -11,7 +11,8 @@ # wizard_step_button # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 -# WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=STEP_BUTTON_1 +# WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=button_button_1_gcode +# WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=button_button_2_gcode # wizard_step_wizards # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_WIZARDS_1 @@ -25,7 +26,8 @@ # wizard_step_slider # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SLIDER_1 # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SLIDER_1 -# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=STEP_SLIDER_1 VARIABLE=slider_STEP_SLIDER_1_min VALUE=12 +# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=STEP_SLIDER_1 VARIABLE=slider_slider1_min VALUE=12 +# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=STEP_SLIDER_1 VARIABLE=slider_slider2_min VALUE=40 # wizard_step_jog # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 @@ -61,8 +63,10 @@ description: description STEP_BUTTON_1 warning: warning STEP_BUTTON_1 countdown: 20 info: info about STEP_BUTTON_1 -button_STEP_BUTTON_1_gcode: - {action_respond_info('-------------------button_STEP_BUTTON_1_gcode')} +button_button_1_gcode: + {action_respond_info('-------------------button_button_1_gcode')} +button_button_2_gcode: + {action_respond_info('-------------------button_button_2_gcode')} action_gcode: {action_respond_info('-------------------action_gcode STEP_BUTTON_1')} SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} @@ -110,10 +114,14 @@ description: description STEP_SLIDER_1 warning: warning STEP_SLIDER_1 countdown: 20 info: info about STEP_SLIDER_1 -slider_STEP_SLIDER_1_min: 0 -slider_STEP_SLIDER_1_max: 100 -slider_STEP_SLIDER_1_step: 1 -slider_STEP_SLIDER_1_default: 20 +slider_slider1_min: 0 +slider_slider1_max: 100 +slider_slider1_step: 1 +slider_slider1_default: 20 +slider_slider2_min: 4 +slider_slider2_max: 30 +slider_slider2_step: 23 +slider_slider2_default: 20 action_gcode: {action_respond_info('-------------------action_gcode STEP_SELECTOR_1')} SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} From e16d56345d398f7283cd210f216991b0420cfc40 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Thu, 28 Dec 2023 13:44:06 +0000 Subject: [PATCH 13/13] STEAPP-841: added dynamic loading of button templates and slider options --- klippy/extras/wizard/wizard_step_button.py | 11 ++++--- klippy/extras/wizard/wizard_step_slider.py | 36 ++++++++++++++-------- stereotech_config/wizards/wizards.cfg | 18 +++++------ 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/klippy/extras/wizard/wizard_step_button.py b/klippy/extras/wizard/wizard_step_button.py index 7bf925983e4e..6c76416fe19c 100644 --- a/klippy/extras/wizard/wizard_step_button.py +++ b/klippy/extras/wizard/wizard_step_button.py @@ -6,11 +6,12 @@ def __init__(self, config): WizardStep.__init__(self, config) # create template for buttons self.templates = {} - buttons = config.get_prefix_options('button') - for button in buttons: + options_name = config.get_prefix_options('button_') + for option in options_name: template_button = self.gcode_macro.load_template( - config, button) - self.templates.update({button: template_button}) + config, option) + button_name = '_'.join(option.split('_')[1:-1]) + self.templates.update({button_name: template_button}) # register commands self.gcode.register_mux_command("WIZARD_STEP_BUTTON", 'STEP', self.name, self.cmd_WIZARD_STEP_BUTTON, @@ -24,7 +25,7 @@ def cmd_WIZARD_STEP_BUTTON(self, gcmd): "2054: Macro %s called recursively" % (self.name,)) wizard_name = gcmd.get('WIZARD').upper() wizard_obj = self.printer.lookup_object('wizard %s' % wizard_name) - button = gcmd.get('BUTTON') + button = gcmd.get('BUTTON', '').lower() template_button = self.templates.get(button, None) if template_button is None: raise gcmd.error( diff --git a/klippy/extras/wizard/wizard_step_slider.py b/klippy/extras/wizard/wizard_step_slider.py index 8deb82fd3507..d21e365246c1 100644 --- a/klippy/extras/wizard/wizard_step_slider.py +++ b/klippy/extras/wizard/wizard_step_slider.py @@ -1,31 +1,43 @@ from wizard_step import WizardStep +OPTIONS = { + 'min': 0, + 'max': 100, + 'step': 1, + 'default': 20, +} + class WizardStepSlider(WizardStep): def __init__(self, config): WizardStep.__init__(self, config) - # get options from config + # get slider options from config self.slider_data = {} - options = config.get_prefix_options('slider') - for option in options: - self.slider_data.update({option: config.getint(option)}) - # register gcode commands - self.gcode.register_mux_command("WIZARD_STEP_SLIDER", 'SLIDER', + options = config.get_prefix_options('slider_') + sliders = {'_'.join(option.split('_')[1:-1]) for option in options} + for slider in sliders: + self.slider_data.update({slider: {}}) + for key, value in OPTIONS.items(): + option_name = 'slider_%s_%s' % (slider, key) + config_value = config.getfloat(option_name, value) + self.slider_data[slider].update({option_name: config_value}) + if 'default' in option_name: + self.slider_data[slider].update({'current_value': config_value}) + self.gcode.register_mux_command("WIZARD_STEP_SLIDER", 'STEP', self.name, self.cmd_WIZARD_STEP_SLIDER, desc=self.cmd_WIZARD_STEP_SLIDER_help) cmd_WIZARD_STEP_SLIDER_help = "update value to the slider data" def cmd_WIZARD_STEP_SLIDER(self, gcmd): - variable = gcmd.get('VARIABLE').lower() + slider = gcmd.get('SLIDER') value = gcmd.get_float('VALUE') - if variable not in self.slider_data: - raise gcmd.error("2055: Failure set value:%s to variable:%s in the slider %s" % ( - value, variable, self.name)) - self.slider_data.update({variable: value}) + if slider not in self.slider_data: + raise gcmd.error("2055: Failure set value:%s to slider:%s" % (value, slider)) + self.slider_data[slider].update({'current_value': value}) def get_status(self, eventtime): - return self.slider_data + return {slider: value['current_value'] for slider, value in self.slider_data.items()} def load_config_prefix(config): diff --git a/stereotech_config/wizards/wizards.cfg b/stereotech_config/wizards/wizards.cfg index 5e6b983c6e7f..50f03b071f3f 100644 --- a/stereotech_config/wizards/wizards.cfg +++ b/stereotech_config/wizards/wizards.cfg @@ -12,7 +12,7 @@ # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_BUTTON_1 # WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=button_button_1_gcode -# WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=button_button_2_gcode +# WIZARD_STEP_BUTTON WIZARD=CALIBRATE STEP=STEP_BUTTON_1 BUTTON=button_button2_gcode # wizard_step_wizards # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_WIZARDS_1 @@ -26,8 +26,8 @@ # wizard_step_slider # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SLIDER_1 # EXECUTE_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_SLIDER_1 -# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=STEP_SLIDER_1 VARIABLE=slider_slider1_min VALUE=12 -# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=STEP_SLIDER_1 VARIABLE=slider_slider2_min VALUE=40 +# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=slider1 VALUE=12 +# WIZARD_STEP_SLIDER WIZARD=CALIBRATE STEP=STEP_SLIDER_1 SLIDER=slider_2 VALUE=40 # wizard_step_jog # CANCEL_WIZARD_STEP WIZARD=CALIBRATE STEP=STEP_JOG_1 @@ -65,8 +65,8 @@ countdown: 20 info: info about STEP_BUTTON_1 button_button_1_gcode: {action_respond_info('-------------------button_button_1_gcode')} -button_button_2_gcode: - {action_respond_info('-------------------button_button_2_gcode')} +button_button2_gcode: + {action_respond_info('-------------------button_button2_gcode')} action_gcode: {action_respond_info('-------------------action_gcode STEP_BUTTON_1')} SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name} @@ -118,10 +118,10 @@ slider_slider1_min: 0 slider_slider1_max: 100 slider_slider1_step: 1 slider_slider1_default: 20 -slider_slider2_min: 4 -slider_slider2_max: 30 -slider_slider2_step: 23 -slider_slider2_default: 20 +slider_slider_2_min: 4 +slider_slider_2_max: 30 +slider_slider_2_step: 23 +slider_slider_2_default: 20 action_gcode: {action_respond_info('-------------------action_gcode STEP_SELECTOR_1')} SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.wizard_step_name}