From f20f395cdc747a80735daf7d0bcc7049f1374518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Mon, 22 May 2023 21:05:04 +0000 Subject: [PATCH] conditional include for the M190/M109 patch and optional bed heater --- config/hardware/extruder/cw1.cfg | 8 ++++- config/hardware/extruder/cw2.cfg | 8 ++++- config/hardware/extruder/galileo.cfg | 8 ++++- config/hardware/extruder/lgx_heavy.cfg | 8 ++++- config/hardware/extruder/lgx_lite.cfg | 8 ++++- config/hardware/extruder/orbiter2.0.cfg | 8 ++++- config/hardware/heated_bed.cfg | 8 +++++ config/machine.cfg | 1 - .../{heaters_ctrl.cfg => bed_heater_ctrl.cfg} | 17 +-------- macros/helpers/heatsoak.cfg | 36 +++++++++++-------- macros/helpers/hotend_heater_ctrl.cfg | 17 +++++++++ macros/miscs/startup.cfg | 6 ++++ 12 files changed, 96 insertions(+), 37 deletions(-) rename macros/helpers/{heaters_ctrl.cfg => bed_heater_ctrl.cfg} (53%) create mode 100644 macros/helpers/hotend_heater_ctrl.cfg diff --git a/config/hardware/extruder/cw1.cfg b/config/hardware/extruder/cw1.cfg index 1f8ea1cac..2dc143827 100644 --- a/config/hardware/extruder/cw1.cfg +++ b/config/hardware/extruder/cw1.cfg @@ -1,3 +1,8 @@ +[gcode_macro _USER_VARIABLES] +variable_extruder_enabled: True +gcode: + + [extruder] # BMG Gear Ratio # new_rd = previous_rd * mesured_distance / requested_distance @@ -18,5 +23,6 @@ min_extrude_temp: 172 pressure_advance: 0.0475 pressure_advance_smooth_time: 0.040 -# We also include the default wiring from here to avoid duplicating +# We also include the default wiring and low thermal hotend patch [include default_wiring.cfg] +[include ../../../macros/helpers/hotend_heater_ctrl.cfg] \ No newline at end of file diff --git a/config/hardware/extruder/cw2.cfg b/config/hardware/extruder/cw2.cfg index 7ca397154..1488386e7 100644 --- a/config/hardware/extruder/cw2.cfg +++ b/config/hardware/extruder/cw2.cfg @@ -1,3 +1,8 @@ +[gcode_macro _USER_VARIABLES] +variable_extruder_enabled: True +gcode: + + [extruder] # BMG Gear Ratio # new_rd = previous_rd * mesured_distance / requested_distance @@ -18,5 +23,6 @@ min_extrude_temp: 172 pressure_advance: 0.0475 pressure_advance_smooth_time: 0.040 -# We also include the default wiring from here to avoid duplicating +# We also include the default wiring and low thermal hotend patch [include default_wiring.cfg] +[include ../../../macros/helpers/hotend_heater_ctrl.cfg] diff --git a/config/hardware/extruder/galileo.cfg b/config/hardware/extruder/galileo.cfg index 552b5a178..5302ca663 100644 --- a/config/hardware/extruder/galileo.cfg +++ b/config/hardware/extruder/galileo.cfg @@ -1,3 +1,8 @@ +[gcode_macro _USER_VARIABLES] +variable_extruder_enabled: True +gcode: + + [extruder] # Galileo Gear Ratio # new_rd = previous_rd * mesured_distance / requested_distance @@ -18,5 +23,6 @@ min_extrude_temp: 172 pressure_advance: 0.0475 pressure_advance_smooth_time: 0.040 -# We also include the default wiring from here to avoid duplicating +# We also include the default wiring and low thermal hotend patch [include default_wiring.cfg] +[include ../../../macros/helpers/hotend_heater_ctrl.cfg] diff --git a/config/hardware/extruder/lgx_heavy.cfg b/config/hardware/extruder/lgx_heavy.cfg index aab91572b..22a8aa246 100644 --- a/config/hardware/extruder/lgx_heavy.cfg +++ b/config/hardware/extruder/lgx_heavy.cfg @@ -1,3 +1,8 @@ +[gcode_macro _USER_VARIABLES] +variable_extruder_enabled: True +gcode: + + [extruder] # Bontech LGX # new_rd = previous_rd * mesured_distance / requested_distance @@ -18,5 +23,6 @@ min_extrude_temp: 172 pressure_advance: 0.0475 pressure_advance_smooth_time: 0.040 -# We also include the default wiring from here to avoid duplicating +# We also include the default wiring and low thermal hotend patch [include default_wiring.cfg] +[include ../../../macros/helpers/hotend_heater_ctrl.cfg] diff --git a/config/hardware/extruder/lgx_lite.cfg b/config/hardware/extruder/lgx_lite.cfg index 697e72fe4..0784a8344 100644 --- a/config/hardware/extruder/lgx_lite.cfg +++ b/config/hardware/extruder/lgx_lite.cfg @@ -1,3 +1,8 @@ +[gcode_macro _USER_VARIABLES] +variable_extruder_enabled: True +gcode: + + [extruder] # Bontech LGX Lite # new_rd = previous_rd * mesured_distance / requested_distance @@ -18,5 +23,6 @@ min_extrude_temp: 172 pressure_advance: 0.0475 pressure_advance_smooth_time: 0.040 -# We also include the default wiring from here to avoid duplicating +# We also include the default wiring and low thermal hotend patch [include default_wiring.cfg] +[include ../../../macros/helpers/hotend_heater_ctrl.cfg] diff --git a/config/hardware/extruder/orbiter2.0.cfg b/config/hardware/extruder/orbiter2.0.cfg index 785671e16..46985cdc7 100644 --- a/config/hardware/extruder/orbiter2.0.cfg +++ b/config/hardware/extruder/orbiter2.0.cfg @@ -1,3 +1,8 @@ +[gcode_macro _USER_VARIABLES] +variable_extruder_enabled: True +gcode: + + [extruder] # Orbiter 2.0 Gear Ratio # new_rd = previous_rd * mesured_distance / requested_distance @@ -18,5 +23,6 @@ min_extrude_temp: 172 pressure_advance: 0.0475 pressure_advance_smooth_time: 0.040 -# We also include the default wiring from here to avoid duplicating +# We also include the default wiring and low thermal hotend patch [include default_wiring.cfg] +[include ../../../macros/helpers/hotend_heater_ctrl.cfg] diff --git a/config/hardware/heated_bed.cfg b/config/hardware/heated_bed.cfg index 8d5e9c087..4500b9177 100644 --- a/config/hardware/heated_bed.cfg +++ b/config/hardware/heated_bed.cfg @@ -1,3 +1,8 @@ +[gcode_macro _USER_VARIABLES] +variable_heaterbed_enabled: True +gcode: + + [heater_bed] heater_pin: BED_HEATER sensor_type: NTC 100K MGB18-104F39050L32 @@ -5,3 +10,6 @@ sensor_pin: BED_TEMPERATURE max_power: 1 min_temp: 0 max_temp: 120 + +# We also include the "no wait too much for temperature" patch +[include ../../macros/helpers/bed_heater_ctrl.cfg] diff --git a/config/machine.cfg b/config/machine.cfg index 48c7da33e..83ec7ecd0 100644 --- a/config/machine.cfg +++ b/config/machine.cfg @@ -45,7 +45,6 @@ resolution: 0.1 [include ../macros/calibration/calib*.cfg] [include ../macros/helpers/filament_swap.cfg] -[include ../macros/helpers/heaters_ctrl.cfg] [include ../macros/helpers/heatsoak.cfg] [include ../macros/helpers/nozzle_cleaning.cfg] [include ../macros/helpers/temp_check.cfg] diff --git a/macros/helpers/heaters_ctrl.cfg b/macros/helpers/bed_heater_ctrl.cfg similarity index 53% rename from macros/helpers/heaters_ctrl.cfg rename to macros/helpers/bed_heater_ctrl.cfg index 9f93535c4..654477c53 100644 --- a/macros/helpers/heaters_ctrl.cfg +++ b/macros/helpers/bed_heater_ctrl.cfg @@ -1,22 +1,7 @@ -# This file add two specific overrides to fix the PID controller bad behavior +# This file add a specific override to fix the PID controller bad behavior # on low thermal inertia devices such as the BambuLabs hotend. This allows a # shunt of the "waiting time" during temperature settle in case there is some problems -[gcode_macro M109] -rename_existing: M109.1 -gcode: - {% set S = params.S|float %} - - {% set fix_heaters_temperature_settle = printer["gcode_macro _USER_VARIABLES"].fix_heaters_temperature_settle %} - - {% if fix_heaters_temperature_settle %} - M104 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %} - TEMPERATURE_WAIT SENSOR=extruder MINIMUM={S} - {% else %} - M109.1 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %} - {% endif %} - - [gcode_macro M190] rename_existing: M190.1 gcode: diff --git a/macros/helpers/heatsoak.cfg b/macros/helpers/heatsoak.cfg index edaa757c4..c4596e240 100644 --- a/macros/helpers/heatsoak.cfg +++ b/macros/helpers/heatsoak.cfg @@ -43,22 +43,30 @@ gcode: {% set TIME = params.SOAKTIME|default(8)|int %} {% set verbose = printer["gcode_macro _USER_VARIABLES"].verbose %} + {% set heaterbed_enabled = printer["gcode_macro _USER_VARIABLES"].heaterbed_enabled %} - {% if verbose %} - RESPOND MSG="Heating up bed..." - {% endif %} + {% if heaterbed_enabled %} + {% if verbose %} + RESPOND MSG="Heating up bed..." + {% endif %} - M190 S{SETPOINT_TEMP} + M190 S{SETPOINT_TEMP} - {% if TIME > 0 %} - {% for i in range(0, TIME) %} - RESPOND MSG="Heatsoak bed, {TIME-i}mn left..." - G4 P{60000 * 1} - {% endfor %} - {% else %} - RESPOND MSG="No heatsoak needed, continue" - {% endif %} + {% if TIME > 0 %} + {% for i in range(0, TIME) %} + RESPOND MSG="Heatsoak bed, {TIME-i}mn left..." + G4 P{60000 * 1} + {% endfor %} + {% else %} + RESPOND MSG="No heatsoak needed, continue" + {% endif %} - {% if verbose %} - RESPOND MSG="Bed temperature OK" + {% if verbose %} + RESPOND MSG="Bed temperature OK" + {% endif %} + + {% else %} + {% if verbose %} + RESPOND MSG="No bed heater defined: nothing to do, continuing..." + {% endif %} {% endif %} diff --git a/macros/helpers/hotend_heater_ctrl.cfg b/macros/helpers/hotend_heater_ctrl.cfg new file mode 100644 index 000000000..c406a3ea6 --- /dev/null +++ b/macros/helpers/hotend_heater_ctrl.cfg @@ -0,0 +1,17 @@ +# This file add a specific override to fix the PID controller bad behavior +# on low thermal inertia devices such as the BambuLabs hotend. This allows a +# shunt of the "waiting time" during temperature settle in case there is some problems + +[gcode_macro M109] +rename_existing: M109.1 +gcode: + {% set S = params.S|float %} + + {% set fix_heaters_temperature_settle = printer["gcode_macro _USER_VARIABLES"].fix_heaters_temperature_settle %} + + {% if fix_heaters_temperature_settle %} + M104 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %} + TEMPERATURE_WAIT SENSOR=extruder MINIMUM={S} + {% else %} + M109.1 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %} + {% endif %} diff --git a/macros/miscs/startup.cfg b/macros/miscs/startup.cfg index d89dfcce3..61b420538 100644 --- a/macros/miscs/startup.cfg +++ b/macros/miscs/startup.cfg @@ -7,6 +7,12 @@ gcode: # Dump the MCU version to the console for the Klippy log _INIT_MCU_VER + # Check if there is an extruder set + {% set extruder_enabled = printer["gcode_macro _USER_VARIABLES"].extruder_enabled %} + {% if not extruder_enabled %} + { action_raise_error("Klippain need to have an extruder defined to work properly. Check your printer.cfg includes!") } + {% endif %} + # Check the probe configuration and compatibility with current includes _INIT_CHECKPROBECONF