Replies: 2 comments 1 reply
-
There's no need to add that, as the value is already clamped just a few lines after the check. I suppose I could just remove the check entirely and let the values get silently clamped. The native Klipper gcode already clamps the maximum (although it will throw a hard error on any value below the minimum). |
Beta Was this translation helpful? Give feedback.
-
It could be a good idea to maybe just clamp it and print a warning to ther terminal, that a user is aware of what happened for devugging purposes. If a user implements their own gcode processing and a custom fan or implementation uses larger values, for example 0-512, for some reason, then they'll know what is happening. Further, a condition could be added to allow for these greater values to be clamped or not for more custom builds. Especially with custom PWM builds. |
Beta Was this translation helpful? Give feedback.
-
To avoid printing with an error, I suggest adding the code to fans.cfg.
{% if S > 255 %}
{% set S = 255 %}
{% endif %}
{% if S < 0 %}
{% set S = 0 %}
{% endif %}
I had this situation. prusa3d/PrusaSlicer#10820
[gcode_macro m106]
description: Wraps M106 to implement scaling overrides.
rename_existing: M106.6245197
gcode:
{% set S = params.S|default(255)|int %}
{% if S > 255 %}
{% set S = 255 %}
{% endif %}
{% if S < 0 %}
{% set S = 0 %}
{% endif %}
{% set scale = printer["gcode_macro set_fan_scaling"] %}
SET_GCODE_VARIABLE MACRO=set_fan_scaling VARIABLE=real_speed VALUE="{S}"
M106.6245197 S{((((S + scale.boost) * scale.scale) | round | int,
scale.minimum) | max, scale.maximum) | min}
Beta Was this translation helpful? Give feedback.
All reactions