diff --git a/klippy/rmmu.py b/klippy/rmmu.py index 7b555e19..56058da4 100644 --- a/klippy/rmmu.py +++ b/klippy/rmmu.py @@ -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): @@ -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) @@ -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): diff --git a/macros.cfg b/macros.cfg index 95d02ce2..275c525a 100644 --- a/macros.cfg +++ b/macros.cfg @@ -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 %} @@ -596,7 +586,6 @@ gcode: {% endif %} {% endif %} RMMU_LOAD_FILAMENT TOOLHEAD={initial_tool} TEMP=-1 - RMMU_START_PRINT { rawparams } {% endif %} # visual feedback diff --git a/macros/rmmu.cfg b/macros/rmmu.cfg index 10bbee92..7bf3e950 100644 --- a/macros/rmmu.cfg +++ b/macros/rmmu.cfg @@ -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!")} diff --git a/scripts/ratos_rmmu_postprocessor.py b/scripts/ratos_rmmu_postprocessor.py index 2b7f3519..b3b43e73 100644 --- a/scripts/ratos_rmmu_postprocessor.py +++ b/scripts/ratos_rmmu_postprocessor.py @@ -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():