Skip to content

Commit

Permalink
better START_PRINT workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgeKeck committed Apr 16, 2024
1 parent 9fbdb75 commit e339c71
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 35 deletions.
11 changes: 7 additions & 4 deletions klippy/rmmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ def cmd_RMMU_START_PRINT(self, param):
self.start_print_param = param

self.filament_changes = 0
if self.is_sensor_triggered(self.toolhead_filament_sensor_t0):
raise self.printer.command_error("Filament detected in toolhead! Please unload the filament and restart the print.")

self.test_filaments(param)
self.toolhead_filament_sensor_t0.runout_helper.sensor_enabled = False
self.gcode.run_script_from_command('START_PRINT ' + str(param.get_raw_command_parameters().strip()))

desc_RMMU_TEST_FILAMENTS = "Tests if filaments, that are needed for the print, are available or not."
def cmd_RMMU_TEST_FILAMENTS(self, param):
Expand Down Expand Up @@ -927,8 +932,7 @@ def test_filaments(self, param):
toolhead = self.get_remapped_toolhead(i)
if not self.test_filament(toolhead):
self.select_filament(-1)
self.gcode.run_script_from_command('_RMMU_ON_START_PRINT_FILAMENT_TEST_FAILED TOOLHEAD=' + str(toolhead))
return
raise self.printer.command_error("Can not start print because Filament T" + str(toolhead) + " is not available!")

# release idler
self.select_filament(-1)
Expand All @@ -947,8 +951,7 @@ def test_filaments(self, param):
if spool == i:
counter += 1
if counter > 1:
self.gcode.run_script_from_command('_RMMU_ON_START_PRINT_SPOOL_JOIN_TEST_FAILED')
return
raise self.printer.command_error("Can not start print because joined spools are part of the print!")
self.ratos_echo("Spool join validated!")

def test_filament(self, filament):
Expand Down
11 changes: 0 additions & 11 deletions macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,6 @@ gcode:
# reset is_printing_gcode state
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False

# rmmu sanity check
{% if printer["rmmu"] is defined %}
RMMU_RESET
SET_FILAMENT_SENSOR SENSOR=toolhead_filament_sensor_t0 ENABLE=1
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{ action_raise_error("Filament detected! Please unload the filament and restart the print.") }
{% endif %}
RMMU_TEST_FILAMENTS { rawparams }
{% endif %}

# update Frontend
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
Expand Down Expand Up @@ -596,7 +586,6 @@ gcode:
{% endif %}
{% endif %}
RMMU_LOAD_FILAMENT TOOLHEAD={initial_tool} TEMP=-1
RMMU_START_PRINT { rawparams }
{% endif %}

# visual feedback
Expand Down
19 changes: 0 additions & 19 deletions macros/rmmu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,3 @@ gcode:
{% else %}
{ action_raise_error("Toolhead T%s error!" % toolhead)}
{% endif %}


[gcode_macro _RMMU_ON_START_PRINT_FILAMENT_TEST_FAILED]
gcode:
# parameter
{% set toolhead = params.TOOLHEAD|default(-1)|int %}

DEBUG_ECHO PREFIX="_RMMU_ON_FILAMENT_TEST_FAILED" MSG="TOOLHEAD={toolhead}"

MOVE_FILAMENT TOOLHEAD={toolhead} MOVE=-100 SPEED=150

{ action_raise_error("Can not start print because Filament T%s is not available!" % toolhead)}


[gcode_macro _RMMU_ON_START_PRINT_SPOOL_JOIN_TEST_FAILED]
gcode:
DEBUG_ECHO PREFIX="_RMMU_ON_START_PRINT_SPOOL_JOIN_TEST_FAILED" MSG=""

{ action_raise_error("Can not start print because joined spools are part of the print!")}
2 changes: 1 addition & 1 deletion scripts/ratos_rmmu_postprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def process_file(args, sourcefile):

# get the start_print line number and fix color variable format
if start_print_line == 0:
if lines[line].rstrip().startswith("START_PRINT"):
if lines[line].rstrip().startswith("START_PRINT") or lines[line].rstrip().startswith("RMMU_START_PRINT"):
start_print_line = line
# fix color variable format
if "#" in lines[start_print_line].rstrip():
Expand Down

0 comments on commit e339c71

Please sign in to comment.