-
-
Notifications
You must be signed in to change notification settings - Fork 56
feat(macros): new commands to make temporary on-the-fly changes to heatsoak configuration easier #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tg73
merged 2 commits into
Rat-OS:v2.1.x-development
from
tg73:topic/heatsoaking-sugar-2
Mar 3, 2026
Merged
feat(macros): new commands to make temporary on-the-fly changes to heatsoak configuration easier #126
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # WARNING: DO NOT EDIT THIS FILE | ||
| # To override settings from this file, you can copy and paste the relevant | ||
| # sections into your printer.cfg and change it there. | ||
|
|
||
| ##### | ||
| # CONFIGURATION VARIABLES | ||
| ##### | ||
|
|
||
| [gcode_macro RatOS] | ||
| variable_bed_heat_soak_time: 0 # Fixed heat soak time for the bed in seconds (0 = no soak) | ||
| # NB: Does not apply when a beacon probe is present and beacon adaptive heatsoaking is enabled. | ||
| variable_hotend_heat_soak_time: 0 # Fixed heat soak time for the hotends in seconds (0 = no soak) | ||
| # NB: Does not apply when a beacon probe is present and beacon adaptive heatsoaking is enabled. | ||
|
|
||
| ##### | ||
| # MACROS | ||
| ##### | ||
|
|
||
| [gcode_macro RESET_HEATSOAK_SETTINGS] | ||
| description: Resets all heatsoak-related settings to startup defaults | ||
| gcode: | ||
| HEATSOAK_SETTINGS ACTION=reset | ||
|
|
||
| [gcode_macro USE_ADAPTIVE_HEATSOAK] | ||
| description: Temporarily enables adaptive bed heatsoaking (if a beacon probe is present), will reset to printer.cfg settings | ||
| when Klipper is restarted. Optionally specify QUALITY (1-5) and maximum FIRST_LAYER_DURATION (in minutes). | ||
| Startup settings will be used by default. | ||
| gcode: | ||
| {% if printer.fastconfig.settings.beacon is not defined %} | ||
| { action_raise_error("Adaptive heatsoaking is only available when a beacon probe is configured.") } | ||
| {% endif %} | ||
| {% set settings = printer.fastconfig.settings["gcode_macro ratos"] %} | ||
| {% if settings is not defined %} | ||
| { action_raise_error("No settings found for [gcode_macro RatOS]") } | ||
| {% endif %} | ||
| {% if params.QUALITY is defined %} | ||
| {% set quality = params.QUALITY|int %} | ||
| {% if quality < 1 or quality > 5 %} | ||
| { action_raise_error("QUALITY must be between 1 (rough) and 5 (maximum). Use 3 (normal) if unsure.") } | ||
| {% endif %} | ||
| {% else %} | ||
| {% set quality = settings.variable_beacon_adaptive_heat_soak_layer_quality|default(3)|int %} | ||
| {% endif %} | ||
| {% if params.FIRST_LAYER_DURATION is defined %} | ||
| {% set first_layer_duration_mins = params.FIRST_LAYER_DURATION|float %} | ||
| {% if first_layer_duration_mins <= 0 %} | ||
| { action_raise_error("FIRST_LAYER_DURATION must be a positive number specifying the maximum first layer duration in minutes.") } | ||
| {% endif %} | ||
| {% set first_layer_duration_secs = (first_layer_duration_mins * 60.0)|int %} | ||
| {% else %} | ||
| {% set first_layer_duration_secs = settings.variable_beacon_adaptive_heat_soak_maximum_first_layer_duration|default(1800)|int %} | ||
| {% set first_layer_duration_mins = (first_layer_duration_secs / 60.0)|round(2) %} | ||
| {% endif %} | ||
| HEATSOAK_SETTINGS QUIET=1 beacon_adaptive_heat_soak=True beacon_adaptive_heat_soak_layer_quality={quality} beacon_adaptive_heat_soak_maximum_first_layer_duration={first_layer_duration_secs} | ||
| RATOS_ECHO MSG="Will use adaptive bed heatsoak with quality {quality} and maximum first layer duration of {"%.2g"|format(first_layer_duration_mins)} minutes." | ||
|
|
||
| [gcode_macro USE_FIXED_HEATSOAK] | ||
| description: Temporarily enables fixed bed heatsoaking, will reset to printer.cfg settings when Klipper is restarted. | ||
| Optionally specify DURATION (in minutes). Startup settings will be used by default. | ||
| gcode: | ||
| {% set settings = printer.fastconfig.settings["gcode_macro ratos"] %} | ||
| {% if settings is not defined %} | ||
| { action_raise_error("No settings found for [gcode_macro RatOS]") } | ||
| {% endif %} | ||
| {% if params.DURATION is defined %} | ||
| {% set duration_mins = params.DURATION|float %} | ||
| {% if duration_mins < 0 %} | ||
| { action_raise_error("DURATION must be a non-negative number specifying the heatsoak duration in minutes.") } | ||
| {% endif %} | ||
| {% set duration_secs = (duration_mins * 60.0)|int %} | ||
| {% else %} | ||
| {% set duration_secs = settings.variable_bed_heat_soak_time|default(0)|int %} | ||
| {% set duration_mins = (duration_secs / 60.0)|round(2) %} | ||
| {% endif %} | ||
| {% set has_beacon = printer.fastconfig.settings.beacon is defined %} | ||
| {% if has_beacon %} | ||
| HEATSOAK_SETTINGS QUIET=1 beacon_adaptive_heat_soak=False bed_heat_soak_time={duration_secs} | ||
| {% else %} | ||
| HEATSOAK_SETTINGS QUIET=1 bed_heat_soak_time={duration_secs} | ||
| {% endif %} | ||
| {% if duration_mins < 1e-3 %} | ||
| RATOS_ECHO MSG="Will use no bed heatsoak." | ||
| {% else %} | ||
| RATOS_ECHO MSG="Will use fixed-duration bed heatsoak of {"%.2g"|format(duration_mins)} minutes." | ||
| {% endif %} | ||
|
|
||
| [gcode_macro USE_NO_HEATSOAK] | ||
| description: Temporarily disables bed heatsoaking, will reset to printer.cfg settings when Klipper is restarted. | ||
| gcode: | ||
| USE_FIXED_HEATSOAK DURATION=0 | ||
|
|
||
| [gcode_macro HEATSOAK_SETTINGS] | ||
| description: Shows or adjusts heatsoak settings | ||
| - With no arguments: shows current heatsoak settings | ||
| - With arguments: sets the specified settings. Use the full setting name without the variable_ prefix, e.g. bed_heat_soak_time=300 or beacon_adaptive_heat_soak_layer_quality=4. See printer.cfg for available settings. | ||
| gcode: | ||
| # Avoid unwanted param detection by mainsail: uses of params2 won't be noticed. | ||
| {% set params2 = params %} | ||
| {% set has_beacon = printer.fastconfig.settings.beacon is defined %} | ||
| {% if has_beacon %} | ||
| {% set vars = ( | ||
| "beacon_adaptive_heat_soak", | ||
| "beacon_adaptive_heat_soak_max_wait", | ||
| "beacon_adaptive_heat_soak_extra_wait_after_completion", | ||
| "beacon_adaptive_heat_soak_layer_quality", | ||
| "beacon_adaptive_heat_soak_maximum_first_layer_duration", | ||
| "bed_heat_soak_time", | ||
| "hotend_heat_soak_time", | ||
| ) %} | ||
| {% else %} | ||
| {% set vars = ( | ||
| "bed_heat_soak_time", | ||
| "hotend_heat_soak_time", | ||
| ) %} | ||
| {% endif %} | ||
| {% set action = "show" if params|length == 0 else params2.ACTION %} | ||
| {% if action is defined and params|length > 1 %} | ||
| { action_raise_error("ACTION cannot be specified with other parameters.") } | ||
| {% elif action is not defined %} | ||
| {% set quiet = params2.QUIET|default(0)|int == 1 %} | ||
| {% for k, v in params2.items() %} | ||
| {% set k = k|lower %} | ||
| {% if k in vars %} | ||
| {% if not quiet %} | ||
| CONSOLE_ECHO MSG="Setting {k} to {v}" | ||
| {% endif %} | ||
| SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={k} VALUE={v} | ||
| {% elif k != "quiet" %} | ||
| { action_raise_error("Parameter '%s' is not recognised. Note that adaptive heatsoaking settings can only be set when a beacon probe is configured." % k) } | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% elif action == "reset" %} | ||
| _RESET_GCODE_VARIABLES MACRO=RatOS VARIABLES={vars|join(',')} SKIP_UNDEFINED_VARIABLES=1 | ||
| CONSOLE_ECHO MSG="Heatsoak settings have been reset to their original values." | ||
| {% elif action == "show" %} | ||
| CONSOLE_ECHO MSG="Current heatsoak settings:" | ||
| _SHOW_GCODE_VARIABLES MACRO=RatOS VARIABLES={vars|join(',')} SKIP_UNDEFINED_VARIABLES=1 | ||
| {% else %} | ||
| { action_raise_error("Action '%s' is not recognised" % action) } | ||
| {% endif %} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.