i cant figure where i went wrong
M106.cfg code
[gcode_macro M106]
rename_existing: G990106
gcode:
{% if params.S is defined %}
{% if params.S|int == 255 %}
{% set realspeed = 1 %}
{% else %}
{% if params.S|int == 0%}
SET_FAN_SPEED FAN=LHfan Speed= SPEED=0
SET_FAN_SPEED FAN=RHfan Speed= SPEED=0
{% else %}
{% set realspeed = 0.003921params.S|int %}
{% endif %}
{% endif %}
SET_FAN_SPEED FAN=LHfan Speed= SPEED={realspeed}
SET_FAN_SPEED FAN=RHfan Speed= SPEED={realspeed}
{% else %}
SET_FAN_SPEED FAN=LHfan Speed= SPEED=1
SET_FAN_SPEED FAN=RHfan Speed= SPEED=1
{% endif %}
Send: status
Recv: // File contains parsing errors: /home/pi/macros/M106.cfg
Recv: // [line 4]: ‘{% if params.S is defined %}\n’
Recv: // [line 17]: ‘{% else %}\n’
Recv: // [line 20]: ‘{% endif %}\n’
Recv: //
Recv: // Once the underlying issue is corrected, use the “RESTART”
HtRabbit:
rename_existing: G990106
Are those 990
correct?
Also, you have to indent:
[gcode_macro M106]
rename_existing: G106
gcode:
{% if params.S is defined %}
{% if params.S|int == 255 %}
{% set realspeed = 1 %}
{% else %}
{% if params.S|int == 0%}
SET_FAN_SPEED FAN=LHfan Speed= SPEED=0
SET_FAN_SPEED FAN=RHfan Speed= SPEED=0
{% else %}
{% set realspeed = 0.003921params.S|int %}
{% endif %}
{% endif %}
SET_FAN_SPEED FAN=LHfan Speed= SPEED={realspeed}
SET_FAN_SPEED FAN=RHfan Speed= SPEED={realspeed}
{% else %}
SET_FAN_SPEED FAN=LHfan Speed= SPEED=1
SET_FAN_SPEED FAN=RHfan Speed= SPEED=1
{% endif %}
https://www.klipper3d.org/Command_Templates.html
Maybe you also should use spaces instead of tabs.
M106 does not exist in klipper so i dont need the rename.
so i remove the rename and tabs and indent properly.
[gcode_macro M106]
gcode:
{% if params.S is defined %}
{% if params.S|int == 255 %}
{% set rs = 1 %}
{% else %}
{% if params.S|int == 0%}
SET_FAN_SPEED FAN=LHfan Speed= SPEED=0
SET_FAN_SPEED FAN=RHfan Speed= SPEED=0
{% else %}
{% set rs = 0.003921params.S|int %}
{% endif %}
{% endif %}
SET_FAN_SPEED FAN=LHfan Speed= SPEED={rs}
SET_FAN_SPEED FAN=RHfan Speed= SPEED={rs}
{% else %}
SET_FAN_SPEED FAN=LHfan Speed= SPEED=1
SET_FAN_SPEED FAN=RHfan Speed= SPEED=1
{% endif %}
however after all that i get the following in the terminal window
Send: status
Recv: // Error loading template 'gcode_macro M106:gcode': TemplateSyntaxError: expected token 'end of statement block', got 'params'
Recv: //
Recv: //
Recv: // Once the underlying issue is corrected, use the "RESTART"
Recv: // command to reload the config and restart the host software.
Recv: // Printer is halted
Recv: // Klipper state: Not ready
the above should read
{% set rs = 0.003921*params.S|int %}
i guess multiplication is not assumed. the error code is pretty vague though.but the formula error causes the whole IF…ELSE…ENDIF statment to fail
thank-you for the help
1 Like