Skip to content

Commit

Permalink
Merge pull request #233 from stereotech/STEAPP-872
Browse files Browse the repository at this point in the history
STEAPP-872: added the wizards
  • Loading branch information
frylock34 authored Feb 13, 2024
2 parents dc6d7f2 + 3656dc1 commit 94beb54
Show file tree
Hide file tree
Showing 48 changed files with 2,437 additions and 458 deletions.
33 changes: 31 additions & 2 deletions HTE530-5-4-22.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,37 @@ path: /home/ste/uploads
[include stereotech_config/calibrate/probe_v1.cfg]
[include stereotech_config/calibrate/probe_v2.cfg]

# wizards
[include stereotech_config/wizards/common.cfg]

[include stereotech_config/wizards/change_material.cfg]
[include stereotech_config/wizards/change_material_filament.cfg]
[include stereotech_config/wizards/change_material_fiber.cfg]

[include stereotech_config/wizards/change_module.cfg]

[include stereotech_config/wizards/5d_calibration.cfg]
[include stereotech_config/wizards/5d_calibration_auto.cfg]
[include stereotech_config/wizards/5d_calibration_manual.cfg]
[include stereotech_config/wizards/5d_calibration_manual_old.cfg]


[include stereotech_config/wizards/adjust_basement.cfg]
[include stereotech_config/wizards/adjust_basement_auto.cfg]
[include stereotech_config/wizards/adjust_basement_manual.cfg]
[include stereotech_config/wizards/zero_point_calibration.cfg]

[include stereotech_config/wizards/bed_level.cfg]
[include stereotech_config/wizards/bed_level_manual.cfg]
[include stereotech_config/wizards/bed_level_auto.cfg]

[include stereotech_config/wizards/nozzle_offset_5d.cfg]
[include stereotech_config/wizards/nozzles_height_align_5d.cfg]
[include stereotech_config/wizards/nozzle_offset_fiber.cfg]
[include stereotech_config/wizards/nozzle_offset_hybrid.cfg]



[include stereotech_config/5xx/main_extruder_2.cfg]
[include stereotech_config/5xx/second_extruder.cfg]
[include stereotech_config/common/nozzle_offset.cfg]
Expand All @@ -42,8 +73,6 @@ 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
Expand Down
13 changes: 10 additions & 3 deletions klippy/extras/wizard/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def __init__(self, config):
"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.image = config.get('image', '')
self.type = config.get('type', 'any')
self.steps = config.getlists('steps', [])
self.current_step = self.steps[0]
self.next_step = self.steps[1] if len(self.steps) > 2 else self.steps[0]
# load objects
self.printer = printer = config.get_printer()
self.gcode = printer.lookup_object('gcode')
Expand All @@ -53,7 +54,8 @@ def get_status(self, eventtime=None):
'variables': self.variables,
'name': self.name,
'steps': self.steps,
'type': self.type}
'type': self.type,
'next_step': self.next_step}

cmd_SET_WIZARD_VARIABLE_help = "Set the value of a wizard variable to wizard"

Expand All @@ -64,6 +66,7 @@ def cmd_SET_WIZARD_VARIABLE(self, gcmd):
raise gcmd.error(
"2051: Unknown wizard variable '%s'" % (variable,))
try:
pass
literal = ast.literal_eval(value)
json.dumps(literal, separators=(',', ':'))
except (SyntaxError, TypeError, ValueError) as e:
Expand All @@ -86,13 +89,17 @@ def cmd_SET_WIZARD_STEP(self, gcmd):
if step not in self.steps:
raise gcmd.error("2053: Unknown step: '%s'" % step)
self.current_step = step
if self.current_step != self.steps[-1]:
current_step_idx = self.steps.index(self.current_step)
self.next_step = self.steps[current_step_idx + 1]

cmd_RESET_WIZARD_help = "Reset state the wizard"

def cmd_RESET_WIZARD(self, gcmd):
self.error = ''
self.enabled = False
self.current_step = self.steps[0]
self.next_step = self.steps[1] if len(self.steps) > 2 else self.steps[0]
self.variables = dict(self._variables_bk)


Expand Down
4 changes: 2 additions & 2 deletions klippy/extras/wizard/wizard_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def __init__(self, config):
self.gcode_macro = printer.load_object(config, 'gcode_macro')
self.gcode = printer.lookup_object('gcode')
# get options from config
self.cmd_desc = config.get("description", "G-Code wizard")
self.image = config.get('image', 'image_path')
self.cmd_desc = config.get("description", '')
self.image = config.get('image', '')
self.landscape = config.getboolean('landscape', False)
self.description = config.get('description', '')
self.warning = config.get('warning', '')
Expand Down
5 changes: 3 additions & 2 deletions klippy/extras/wizard/wizard_step_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
class WizardStepSelector(WizardStep):
def __init__(self, config):
WizardStep.__init__(self, config)
self.selected = ''
# get options
self.items = config.getlists('items', [])
self.items = config.getlists('items')
# set attributes
self.selected = self.items[0]
# create template
self.template = self.gcode_macro.load_template(config, 'select_gcode')
# register commands
Expand Down
9 changes: 5 additions & 4 deletions klippy/extras/wizard/wizard_step_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ def __init__(self, config):
self.types = config.getlist('types', [])
json_path = config.get('tree_file_path', '')
# read json file
filename = self.printer.get_start_args()['config_file']
if 'printer.cfg' not in filename.split('/')[-1]:
config_path = self.printer.get_start_args()['config_file'].split('/')
if 'printer.cfg' not in config_path:
config_dir_name = 'stereotech_config'
abs_json_path = os.path.join(os.path.abspath('.'), config_dir_name, json_path)
klipper_path = '/'.join(config_path[:-1])
abs_json_path = os.path.join(klipper_path, config_dir_name, json_path)
if os.path.isfile(abs_json_path):
try:
with open(abs_json_path, 'r') as f:
self.tree = json.load(f)
except Exception as e:
raise config.error("0026: do not parse .json file, error %s" % e)
else:
raise config.error("0026: file with data not exist")
raise config.error("0026: file with data not exist: %s" % abs_json_path)
# register commands
self.gcode.register_mux_command("WIZARD_STEP_TREE", 'STEP',
self.name, self.cmd_WIZARD_STEP_TREE,
Expand Down
1 change: 1 addition & 0 deletions stereotech_config/common/model_fiber_nozzle_offset.gcode
Original file line number Diff line number Diff line change
Expand Up @@ -3933,3 +3933,4 @@ M73 P100
M82 ;absolute extrusion mode
M104 S0
;End of Gcode
WIZARD_STEP_LOADING_STATE WIZARD=NOZZLE_OFFSET_FIBER STEP=NOZZLE_OFFSET_FIBER3 ENABLE=0
1 change: 1 addition & 0 deletions stereotech_config/common/model_hybrid_nozzle_offset.gcode
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,4 @@ M73 P100
M82 ;absolute extrusion mode
M104 S0
;End of Gcode
WIZARD_STEP_LOADING_STATE WIZARD=NOZZLE_OFFSET_HYBRID STEP=NOZZLE_OFFSET_HYBRID4 ENABLE=0
12 changes: 12 additions & 0 deletions stereotech_config/wizards/5d_calibration.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[wizard CALIBRATE_5D]
image: wizards/5d_calibration_auto/auto_five_axis_level_main.jpg
type: 5d
steps: CALIBRATE_5D_0

[wizard_step_wizards CALIBRATE_5D_0]
description: Choose the required manager
wizards: CALIBRATE_5D_AUTO, CALIBRATE_5D_MANUAL
action_gcode:
# pass
cancel_gcode:
# pass
106 changes: 106 additions & 0 deletions stereotech_config/wizards/5d_calibration_auto.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
[wizard CALIBRATE_5D_AUTO]
image: wizards/5d_calibration_auto/auto_five_axis_level_main.jpg
type: 5d
steps: CALIBRATE_5D_AUTO0, CLEAR_NOZZLE0, CLEAR_NOZZLE1, CALIBRATE_5D_AUTO1, CALIBRATE_5D_AUTO2, CALIBRATE_5D_AUTO3, CALIBRATE_5D_AUTO4, CALIBRATE_5D_AUTO5, CALIBRATE_5D_AUTO6, CALIBRATE_5D_AUTO7, CALIBRATE_5D_AUTO8

[wizard_step_button CALIBRATE_5D_AUTO0]
image: wizards/5d_calibration_auto/auto_five_axis_level_main.jpg
description: Wizards.5DCalibrationAuto.Description
warning: Wizards.Common.MakeSureFreeOfPlastic
action_gcode:
SET_WIZARD_ENABLE WIZARD={wizard.name} ENABLE=1 ERROR=''
MOVE_SERVICE_POSITION
SET_WIZARD_STEP WIZARD={wizard.name} STEP=CALIBRATE_5D_AUTO1
button_clear_noozle_gcode:
{% set extruder = printer.toolhead.extruder|default('extruder') %}
SET_WIZARD_ENABLE WIZARD={wizard.name} ENABLE=1 ERROR=''
CHANGE_STEP_AND_WAIT_HEATING WIZARD={wizard.name} STEP={wizard.next_step} TEMP=200 EXTRUDER={extruder}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step CALIBRATE_5D_AUTO1]
image: wizards/5d_calibration_auto/auto_five_axis_level_02.jpg
description: Wizards.Common.PlaceTool
warning: Wizards.Common.GapBetweenTemplateModule
action_gcode:
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step CALIBRATE_5D_AUTO2]
image: wizards/5d_calibration_auto/auto_five_axis_level_03.jpg
description: Wizards.Common.ConnectSensor
warning: Wizards.Common.WarningScrew
action_gcode:
CHANGE_STEP_AND_WAIT_PROBE WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step CALIBRATE_5D_AUTO3]
image: wizards/5d_calibration_auto/auto_five_axis_level_04.jpg
description: Wizards.Common.ConnectAndCheck
placeholder: wizard-step-probe
action_gcode:
{% set cmd = 'CALIBRATE_MODULE_FIVE_D' %}
CHANGE_STEP_AND_WAIT_RUN_CMD WIZARD={wizard.name} STEP={wizard.next_step} CMD={cmd}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step CALIBRATE_5D_AUTO4]
image: wizards/5d_calibration_auto/auto_five_axis_level_05.jpg
description: Wizards.5DCalibrationAuto.Wait
countdown: 420
placeholder: waitProgress true
action_gcode:
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step_jog CALIBRATE_5D_AUTO5]
image: wizards/5d_calibration_auto/auto_five_axis_level_06.jpg
description: Wizards.5DCalibrationAuto.MoveToSurface
axes: z
steps: 0.01, 0.05, 0.1, 1
default_step: 1
jog_gcode:
JOG_DO_MOVE {rawparams} STEP_NAME={wizard.wizard_step_name}
action_gcode:
ADJUST_PROBE_OFFSET_Z ADJUST_CALIBRATION=1 ADJUST_WCS=1
SET_WCS_FROM_AUTO_WCS
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step_button CALIBRATE_5D_AUTO6]
image: wizards/5d_calibration_auto/auto_five_axis_level_03.jpg
description: Wizards.5DCalibrationAuto.XYCorrectionDescription
action_gcode:
SET_WIZARD_STEP WIZARD={wizard.name} STEP=CALIBRATE_5D_AUTO8
button_xy_correction_gcode:
MOVE_TO_AUTO_WCS XY=1
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step_jog CALIBRATE_5D_AUTO7]
image: wizards/5d_calibration_auto/auto_five_axis_level_07.jpg
description: Wizards.5DCalibrationAuto.MoveToHole
axes: x, y, z
steps: 0.01, 0.05, 0.1, 1
default_step: 1
jog_gcode:
JOG_DO_MOVE {rawparams} STEP_NAME={wizard.wizard_step_name}
action_gcode:
ADJUST_PROBE_OFFSET_XY ADJUST_CALIBRATION=1 ADJUST_WCS=1
SET_WCS_FROM_AUTO_WCS
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step CALIBRATE_5D_AUTO8]
image: wizards/5d_calibration_auto/auto_five_axis_level_03.jpg
description: Wizards.5DCalibrationAuto.Finish
action_gcode:
RESET_WIZARD WIZARD={wizard.name} ABORT=0
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}
90 changes: 90 additions & 0 deletions stereotech_config/wizards/5d_calibration_manual.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[wizard CALIBRATE_5D_MANUAL]
image: wizards/5d_calibration_auto/auto_five_axis_level_06.jpg
type: 5d
steps: CALIBRATE_5D_MANUAL0, CLEAR_NOZZLE0, CLEAR_NOZZLE1, CALIBRATE_5D_MANUAL1, CALIBRATE_5D_MANUAL2, CALIBRATE_5D_MANUAL3, CALIBRATE_5D_MANUAL4, CALIBRATE_5D_MANUAL5, CALIBRATE_5D_MANUAL_COMPLETED

[wizard_step_button CALIBRATE_5D_MANUAL0]
image: wizards/5d_calibration_auto/auto_five_axis_level_06.jpg
description: Wizards.5DCalibrationManual.Description
warning: Wizards.Common.MakeSureFreeOfPlastic
action_gcode:
SET_WIZARD_ENABLE WIZARD={wizard.name} ENABLE=1 ERROR=''
MOVE_SERVICE_POSITION
SET_WIZARD_STEP WIZARD={wizard.name} STEP=CALIBRATE_5D_MANUAL1
button_clear_noozle_gcode:
{% set extruder = printer.toolhead.extruder|default('extruder') %}
SET_WIZARD_ENABLE WIZARD={wizard.name} ENABLE=1 ERROR=''
CHANGE_STEP_AND_WAIT_HEATING WIZARD={wizard.name} STEP={wizard.next_step} TEMP=200 EXTRUDER={extruder}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step CALIBRATE_5D_MANUAL1]
image: wizards/5d_calibration_auto/auto_five_axis_level_02.jpg
description: Wizards.Common.PlaceTool
action_gcode:
MOVE_CALIBRATION_POINT POINT=0
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step_jog CALIBRATE_5D_MANUAL2]
image: wizards/5d_calibration_manual/5d_calibration6.jpg
description: Wizards.Common.MoveNozzle
axes: x, y, z
steps: 0.05, 0.1, 1.0, 10.0
default_step: 1
jog_gcode:
JOG_DO_MOVE {rawparams} STEP_NAME={wizard.wizard_step_name}
action_gcode:
SET_A_AXIS_OFFSET_POINT POINT=0
MOVE_CALIBRATION_POINT POINT=3
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step_jog CALIBRATE_5D_MANUAL3]
image: wizards/5d_calibration_manual/5d_calibration9.jpg
description: Wizards.Common.MoveNozzle
axes: x, y, z
steps: 0.05, 0.1, 1.0, 10.0
default_step: 1
jog_gcode:
JOG_DO_MOVE {rawparams} STEP_NAME={wizard.wizard_step_name}
action_gcode:
SET_A_AXIS_OFFSET_POINT POINT=1
CALC_A_AXIS_OFFSET
MOVE_WCS_ZERO WCS=1
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step_jog CALIBRATE_5D_MANUAL4]
image: wizards/5d_calibration_manual/5d_calibration6.jpg
description: Wizards.Common.MoveNozzle
axes: x, y, z
steps: 0.05, 0.1, 1.0, 10.0
default_step: 1
jog_gcode:
JOG_DO_MOVE {rawparams} STEP_NAME={wizard.wizard_step_name}
action_gcode:
SET_WCS_OFFSET WCS=1 X=0 Y=0 Z=0
SET_WCS_OFFSET WCS=3 X=0 Y=0 Z=0
MOVE_WCS_ZERO WCS=2
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}

[wizard_step_jog CALIBRATE_5D_MANUAL5]
image: wizards/5d_calibration_manual/5d_calibration10.jpg
description: Wizards.Common.MoveNozzle
axes: x, y, z
steps: 0.05, 0.1, 1.0, 10.0
default_step: 1
jog_gcode:
JOG_DO_MOVE {rawparams} STEP_NAME={wizard.wizard_step_name}
action_gcode:
SET_WCS_OFFSET WCS=2 X=0 Y=0 Z=10
SET_WCS_OFFSET WCS=4 X=0 Y=0 Z=10
SET_WIZARD_STEP WIZARD={wizard.name} STEP={wizard.next_step}
cancel_gcode:
RESET_WIZARD WIZARD={wizard.name}
Loading

0 comments on commit 94beb54

Please sign in to comment.