diff --git a/.vscode/launch.json b/.vscode/launch.json index 871286be441b..2ce7f2d8a36a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -28,7 +28,9 @@ "${workspaceFolder}/HTE530-5-4-22.cfg", "-v", "-a", - "/tmp/klipper_uds" + "/tmp/klipper_uds", + // "-l", + // "/tmp/dev_klipper_log.log" ] } ] diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py index 52ee745d46a7..063daf505f6c 100644 --- a/klippy/extras/gcode_macro.py +++ b/klippy/extras/gcode_macro.py @@ -101,6 +101,9 @@ def _action_stop_for_power_off(self, msg="action_stop_for_power_off"): def _action_respond_info(self, msg): self.printer.lookup_object('gcode').respond_info(msg) return "" + def _action_respond_warning(self, msg): + self.printer.lookup_object('gcode').respond_warning(msg) + return "" def _action_raise_error(self, msg): raise self.printer.command_error(msg) def _action_call_remote_method(self, method, **kwargs): @@ -115,6 +118,7 @@ def create_template_context(self, eventtime=None): 'printer': GetStatusWrapper(self.printer, eventtime), 'action_emergency_stop': self._action_emergency_stop, 'action_respond_info': self._action_respond_info, + 'action_respond_warning': self._action_respond_warning, 'action_raise_error': self._action_raise_error, 'action_call_remote_method': self._action_call_remote_method, 'action_stop_for_power_off': self._action_stop_for_power_off diff --git a/klippy/gcode.py b/klippy/gcode.py index 0355bbc866ea..8082e8c85847 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -229,6 +229,10 @@ def respond_info(self, msg, log=True): logging.info(msg) lines = [l.strip() for l in msg.strip().split('\n')] self.respond_raw("// " + "\n// ".join(lines)) + def respond_warning(self, msg): + logging.warning(msg) + lines = msg.strip().split('\n') + self.respond_info("\n".join(lines), log=False) def _respond_error(self, msg): logging.warning(msg) lines = msg.strip().split('\n') diff --git a/stereotech_config/filament_control.cfg b/stereotech_config/filament_control.cfg index 27620eceae6e..6c347bb003d0 100644 --- a/stereotech_config/filament_control.cfg +++ b/stereotech_config/filament_control.cfg @@ -7,7 +7,7 @@ pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} M117 trigered_filament_sensor0 - {action_respond_info('The filament has run out or there is a problem with its supply at the Extruder0.')} + {action_respond_warning('The filament has run out or there is a problem with its supply at the Extruder0.')} PAUSE TURN_OFF_EXTRUDERS=0 E=0 M400 SET_STATE_TRY_EXTRUDE_FILAMENT SENSOR='extruder_sensor' ENABLE=1 @@ -31,7 +31,7 @@ gcode: M400 EXTRUDE_WITH_COOLING_AND_HEATING SENSOR={sensor} {% else %} - {action_respond_info('Extruder not heat enough!')} + {action_respond_warning('Extruder not heat enough!')} {% endif %} [gcode_macro FILAMENT_ERROR] @@ -53,12 +53,12 @@ gcode: {% set sensor = params.SENSOR %} {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} {% if filament_detected %} - {action_respond_info('Extruding attempt completed successfully, resuming printing.')} + {action_respond_warning('Extruding attempt completed successfully, resuming printing.')} M117 resume_after_trigered_sensor RESUME {% else %} - M117 all_attempt_extrude_failed - {action_respond_info('All extruding attempt completed failed.')} + M117 failed_try_do_extrude + {action_respond_warning('All extruding attempt completed failed.')} {% if sensor == 'extruder_sensor' %} SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=0 {% elif sensor == 'extruder1_sensor' %} @@ -72,10 +72,10 @@ gcode: ; checking the printer state is pause, maybe user resumed printing {% if printer.pause_resume.is_paused %} {% if printer["gcode_macro CONTINUE_PRINT_WITH_EXTRUDER"].enabled|int > 0 %} - {action_respond_info('Function "continue printing with another extruder" is enabled')} + {action_respond_warning('Function "continue printing with another extruder" is enabled')} CONTINUE_PRINT_WITH_EXTRUDER {% else %} - {action_respond_info('Function "continue printing with another extruder" is disabled. Turn off all extruder')} + {action_respond_warning('Function "continue printing with another extruder" is disabled. Turn off all extruder')} TURN_OFF_EXTRUDERS {% endif %} {% endif %} @@ -88,7 +88,7 @@ gcode: {% if printer.pause_resume.is_paused and printer["filament_motion_sensor extruder1_sensor"] %} {% set triggered_extruder = printer["gcode_macro CONTINUE_PRINT_WITH_EXTRUDER"].triggered_extruder|int %} {% if triggered_extruder == 0 %} - {action_respond_info('Printing continued with extruder 2.')} + {action_reaction_respond_warningspond_info('Printing continued with extruder 2.')} M117 resume_print_another_extruder SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=current_extruder VALUE=1 SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder1_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} @@ -96,12 +96,12 @@ gcode: SET_GCODE_VARIABLE MACRO=SET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_set VALUE=1 RESUME {% elif triggered_extruder == 1 %} - {action_respond_info('Continue printing with extruder0 fails because this function is not available.')} - {action_respond_info('Turn off all extruder')} + {action_respond_warning('Continue printing with extruder0 fails because this function is not available.')} + {action_respond_warning('Turn off all extruder')} TURN_OFF_EXTRUDERS SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=-1 {% else %} - {action_respond_info('Turn off all extruder')} + {action_respond_warning('Turn off all extruder')} TURN_OFF_EXTRUDERS {% endif %} {% endif %} @@ -110,14 +110,14 @@ gcode: variable_needed_reset: 0 gcode: {% if printer["gcode_macro RESET_CONTINUE_PRINT_WITH_EXTRUDER"].needed_reset > 0 %} - {action_respond_info('Reset offset.')} + {action_respond_warning('Reset offset.')} SET_GCODE_OFFSET X_ADJUST=25.0 MOVE=1 ENABLE_CONSTRAIN ENABLE=0 SET_GCODE_VARIABLE MACRO=SET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_set VALUE=1 SET_GCODE_VARIABLE MACRO=RESET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_reset VALUE=0 {% endif %} {% if params.RESET_VARIABLES|default(0) > 0 %} - {action_respond_info('Reset variable.')} + {action_respond_warning('Reset variable.')} SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=enabled VALUE=0 SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=-1 SET_GCODE_VARIABLE MACRO=SET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_set VALUE=0 @@ -128,7 +128,7 @@ gcode: variable_needed_set: 0 gcode: {% if printer["gcode_macro SET_CONTINUE_PRINT_WITH_EXTRUDER"].needed_set|int > 0 %} - {action_respond_info('An offset is set to continue printing on another extruder.')} + {action_respond_warning('An offset is set to continue printing on another extruder.')} SET_GCODE_OFFSET X_ADJUST=-25.0 MOVE=1 ;if an offset is added, movement beyond coord_min is possible, you need to enable the coordinate limit for movement in the tolhead module ENABLE_CONSTRAIN ENABLE=1 @@ -140,7 +140,7 @@ gcode: description: Trying to extrude the filament. gcode: {% for attempt in range(printer["gcode_macro TRY_DO_EXTRUDE"].retries_count|int) %} - {action_respond_info('Attempt to extrude the filament.')} + {action_respond_warning('Attempt to extrude the filament.')} G91 G0 E25 F600 G90 @@ -152,16 +152,16 @@ gcode: {% set sensor = params.SENSOR %} {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} {% if not filament_detected %} - {action_respond_info('Attempt to extrude the filament is failed.')} + {action_respond_warning('Attempt to extrude the filament is failed.')} {% if sensor == 'extruder_sensor' %} - {action_respond_info('Cooling and heat extruder0.')} + {action_respond_warning('Cooling and heat extruder0.')} {% set temp_extruder = printer["gcode_macro PAUSE"].extruder_temp|int %} M117 cooling_extruder M109 T0 S50 M117 heat_extruder M109 T0 S{temp_extruder} {% elif sensor == 'extruder1_sensor' %} - {action_respond_info('Cooling and heat extruder1.')} + {action_respond_warning('Cooling and heat extruder1.')} {% set temp_extruder = printer["gcode_macro PAUSE"].extruder1_temp|int %} M117 cooling_extruder M109 T1 S50 diff --git a/stereotech_config/filament_control_2.cfg b/stereotech_config/filament_control_2.cfg index 55cea976db96..a22eef948cdd 100644 --- a/stereotech_config/filament_control_2.cfg +++ b/stereotech_config/filament_control_2.cfg @@ -7,7 +7,7 @@ pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} M117 trigered_filament_sensor0 - {action_respond_info('The filament has run out or there is a problem with its supply at the Extruder0.')} + {action_respond_warning('The filament has run out or there is a problem with its supply at the Extruder0.')} RECOVER_EXTRUSION SENSOR='extruder_sensor' {% else %} FILAMENT_ERROR EXTRUDER=extruder @@ -44,6 +44,7 @@ gcode: SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 {% else %} {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_offset and printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_count %} + {action_respond_warning('Recover extrusion by offset %s' % printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made)} RECOVER_EXTRUSION_BY_OFFSET {% else %} {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_offset %} @@ -64,10 +65,12 @@ gcode: RECOVER_EXTRUSION_BY_SECOND_EXTRUDER {% else %} {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_second_extruder and sensor == 'extruder_sensor' %} + {action_respond_warning('Switch to second extruder and resume printing.')} RECOVER_EXTRUSION_BY_SECOND_EXTRUDER RESET=1 SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 {% endif %} #Set timeout and wait for user + {action_respond_warning('All attempt to extrude failed.')} M117 all_attempt_extrude_failed UPDATE_DELAYED_GCODE ID=TURN_OFF_EXTRUDERS_DELAYED DURATION=300 SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=1 @@ -119,6 +122,7 @@ gcode: {% if printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].use_cooldown and printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made >= printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].check_count %} {% set extruder_temp = printer["gcode_macro PAUSE"].extruder_temp if extruder == 'extruder' else printer["gcode_macro PAUSE"].extruder1_temp %} M117 cooling_extruder + {action_respond_warning('Recover extrusion after cooling and heating.')} M106 S255 M109 S50 M107 @@ -133,6 +137,7 @@ gcode: SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=use_cooldown VALUE=0 CHECK_FILAMENT_MOTION_SENSOR SENSOR={sensor} {% else %} + {action_respond_warning('Recover extrusion do extrude attempt %s' % printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made)} M117 try_do_extrude_{printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made + 1} M400 G4 P3000 @@ -150,7 +155,7 @@ gcode: {% set sensor = params.SENSOR %} {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} {% if filament_detected %} - {action_respond_info('Extruding attempt completed successfully, resuming printing.')} + {action_respond_warning('Extruding attempt completed successfully, resuming printing.')} M117 resume_after_trigered_sensor RESUME {% else %} diff --git a/stereotech_config/filament_control_second.cfg b/stereotech_config/filament_control_second.cfg index 1d10d7245244..7673caeb148f 100644 --- a/stereotech_config/filament_control_second.cfg +++ b/stereotech_config/filament_control_second.cfg @@ -7,7 +7,7 @@ pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} M117 trigered_filament_sensor1 - {action_respond_info('The filament has run out or there is a problem with its supply at the Extruder2.')} + {action_respond_warning('The filament has run out or there is a problem with its supply at the Extruder2.')} PAUSE TURN_OFF_EXTRUDERS=0 E=0 M400 SET_STATE_TRY_EXTRUDE_FILAMENT SENSOR='extruder1_sensor' ENABLE=1 diff --git a/stereotech_config/filament_control_second_2.cfg b/stereotech_config/filament_control_second_2.cfg index 02c06d683567..845f2a3db1b6 100644 --- a/stereotech_config/filament_control_second_2.cfg +++ b/stereotech_config/filament_control_second_2.cfg @@ -7,7 +7,7 @@ pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} M117 trigered_filament_sensor1 - {action_respond_info('The filament has run out or there is a problem with its supply at the Extruder2.')} + {action_respond_warning('The filament has run out or there is a problem with its supply at the Extruder2.')} RECOVER_EXTRUSION SENSOR='extruder1_sensor' {% else %} FILAMENT_ERROR EXTRUDER=extruder1 diff --git a/stereotech_config/homing.cfg b/stereotech_config/homing.cfg index cecee641eb66..cf8e83c653e0 100644 --- a/stereotech_config/homing.cfg +++ b/stereotech_config/homing.cfg @@ -97,12 +97,12 @@ gcode: CUT_FIBER G1 E-{e} F1200 {% else %} - {action_respond_info("Extruder not hot enough")} + {action_respond_warning("Extruder not hot enough")} {% endif %} {% if "xyz" in printer.toolhead.homed_axes %} G1 Z{z_safe} F3600 G90 G1 X{x} Y{y} F3600 {% else %} - {action_respond_info("Printer not homed")} + {action_respond_warning("Printer not homed")} {% endif %} diff --git a/stereotech_config/print_macros.cfg b/stereotech_config/print_macros.cfg index bcd6abd7f416..9a126863e29b 100644 --- a/stereotech_config/print_macros.cfg +++ b/stereotech_config/print_macros.cfg @@ -62,14 +62,14 @@ gcode: CUT_FIBER G1 E-{e} F1200 {% else %} - {action_respond_info("Extruder not hot enough")} + {action_respond_warning("Extruder not hot enough")} {% endif %} {% if "xyz" in printer.toolhead.homed_axes %} G1 Z{z_safe} F3600 G90 G1 X{x} Y{y} F3600 {% else %} - {action_respond_info("Printer not homed")} + {action_respond_warning("Printer not homed")} {% endif %} M106 S0 @@ -88,7 +88,7 @@ gcode: G1 E{e} F1800 PRIME_FIBER {% else %} - {action_respond_info("Extruder not hot enough")} + {action_respond_warning("Extruder not hot enough")} {% endif %} G90 SET_IDLE_TIMEOUT TIMEOUT=600 diff --git a/stereotech_config/v6/filament_control.cfg b/stereotech_config/v6/filament_control.cfg index 1458f6f843f2..49b32785664e 100644 --- a/stereotech_config/v6/filament_control.cfg +++ b/stereotech_config/v6/filament_control.cfg @@ -6,7 +6,7 @@ switch_pin: filament_control_1 pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} - {action_respond_info('The filament has run out or there is a problem with its supply at the Extruder 1.')} + {action_respond_warning('The filament has run out or there is a problem with its supply at the Extruder 1.')} # PAUSE TURN_OFF_EXTRUDERS=0 E=0 {% else %} FILAMENT_ERROR EXTRUDER=extruder diff --git a/stereotech_config/v6/filament_control_second.cfg b/stereotech_config/v6/filament_control_second.cfg index d27767a3e741..dd00e9759c37 100644 --- a/stereotech_config/v6/filament_control_second.cfg +++ b/stereotech_config/v6/filament_control_second.cfg @@ -6,7 +6,7 @@ switch_pin: filament_control_2 pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} - {action_respond_info('The filament has run out or there is a problem with its supply at the Extruder 2.')} + {action_respond_warning('The filament has run out or there is a problem with its supply at the Extruder 2.')} # PAUSE TURN_OFF_EXTRUDERS=0 E=0 {% else %} FILAMENT_ERROR EXTRUDER=extruder1