VzBoT3D / VzBoT-Vz330

The VzBot 3D-printer
1.02k stars 163 forks source link

Cleaner version of the fan macros #69

Closed Jyrka98 closed 6 months ago

simonvez commented 6 months ago

Hi friend. Thanks for the suggestion. Did you test it yourself ? I just did and doesnt seem to work. It only starts the part cooling fan (cpap) only no matter what P param is there

Jyrka98 commented 6 months ago

I don't have a VzBot, but yes, I tested it myself since it is not specific to it. (If you're wondering why I made this pull request, it's because I watched your video and saw an opportunity for improvement)

simonvez commented 6 months ago

Thanks for your help. I tested and it was not working. Not sure why. But someone else also messaged me with another option and after making changes to it.. it worked fine and has less line of codes. Here it is:

Replacement-Macro to control the Fan with M106 P2 and M107 for BambuStudio

Macro inspired by klipper-github issue https://github.com/Klipper3d/klipper/issues/2174

[gcode_macro M106] rename_existing: G106 gcode: {% set P = params.P | default(0) | int %} {% set S = params.S | default(255) | int %} {% if P == 0 %} G106 S{S} {% else %} {% set fan = "RSCS" if P == 2 else "Exhaust_fan" %} SET_FAN_SPEED FAN={fan} SPEED={S / 255} {% endif %}

[gcode_macro M107] rename_existing: G107 gcode: {% set fan = params.P|default(1)|int %} {% if fan == 2 %} SET_FAN_SPEED FAN=RSCS SPEED=0 {% elif fan == 3 %} SET_FAN_SPEED FAN=Exhaust_fan SPEED=0
{% else %} SET_FAN_SPEED FAN=RSCS SPEED=0
SET_FAN_SPEED FAN=Exhaust_fan SPEED=0
G107 {% endif %}