Newer
Older
jeltz-klipper-config / config / overrides.cfg
[force_move]
enable_force_move: True

[exclude_object]

# [idle_timeout]
# gcode:
#     ACTION_RESPON
#     SAVE_VARIABLE VARIABLE=heater_state VALUE='"Cold"'
#     TURN_OFF_HEATERS
#     UPDATE_DELAYED_GCODE ID=FULL_IDLE DURATION=3600
# timeout: 600
# #   Idle time (in seconds) to wait before running the above G-Code
# #   commands. The default is 600 seconds.

# [delayed_gcode FULL_IDLE]
# gcode:
#  {% if printer.idle_timeout.state == "Idle" %}
#    TURN_OFF_HEATERS
#    M84
#    SAVE_VARIABLE VARIABLE=heater_state VALUE='"Cold"'
#    SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=calibrate VALUE='"none"'
#  {% endif %}

# replace homing
[gcode_macro G28]
rename_existing: G9928
gcode:
  {% set calibrate = printer["gcode_macro VARIABLES"].calibrate %}

  G9928 {rawparams}
  {% if not rawparams or (rawparams and 'Z' in rawparams) %}
    PROBE
    SET_Z_FROM_PROBE
  {% endif %}

  {% if calibrate == "none" %}
    SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=calibrate VALUE='"home"'
  {% endif %}

[gcode_macro QUAD_GANTRY_LEVEL]
rename_existing: QUAD_GANTRY_LEVEL1
gcode:
  {% set calibrate = printer["gcode_macro VARIABLES"].calibrate %}
  
  {% if calibrate == "none" %}
    G28
  {% endif %}
  
  QUAD_GANTRY_LEVEL1 {rawparams}

  {% if calibrate == "home" or calibrate == "none" %}
    SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=calibrate VALUE='"QGL"'
  {% endif %}

[gcode_macro BED_MESH_CALIBRATE]
rename_existing: BED_MESH_CALIBRATE1
gcode:
  {% set calibrate = printer["gcode_macro VARIABLES"].calibrate %}
  
  {% if calibrate == "none" %}
    G28
    QUAD_GANTRY_LEVEL
  {% elif calibrate == "home" %}
    QUAD_GANTRY_LEVEL
  {% endif %}
  
  BED_MESH_CALIBRATE1 {rawparams}

  SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=calibrate VALUE='"full"'

# replace pause
[gcode_macro M600]
gcode:
    PAUSE

# replace extruder with temperature wait
[gcode_macro M109]
rename_existing: M99109
gcode:
    {% set svv = printer.save_variables.variables %}
    
    # only execute if slicer mode
    {% if svv.heater_mode == "slicer" %}
  
      #Parameters
      {% set s = params.S|float %}
  
      M104 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %}  ; Set hotend temp
      {% if s != 0 %}
          TEMPERATURE_WAIT SENSOR=extruder MINIMUM={s} MAXIMUM={s+1}   ; Wait for hotend temp (within 1 degree)
      {% endif %}
    {% endif %}

# replace bed with temperature wait
[gcode_macro M190]
rename_existing: M99190
gcode:
    {% set svv = printer.save_variables.variables %}

    # only execute if slicer mode
    {% if svv.heater_mode == "slicer" %}
      #Parameters
      {% set s = params.S|float %}
  
      M140 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %}   ; Set bed temp
      {% if s != 0 %}
          TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={s} MAXIMUM={s+1}  ; Wait for bed temp (within 1 degree)
      {% endif %}
    {% endif %}

# append extruder temperature with extra logic
[gcode_macro M104]
rename_existing: M99104
gcode:
  {% set svv = printer.save_variables.variables %}

  {% if svv.heater_mode == "slicer" %}
  # if printer in slicer mode, run command
    {% if params.TARGET != 0 %}
      SAVE_VARIABLE VARIABLE=extruder_state VALUE='"hot"'
    {% else %}
      SAVE_VARIABLE VARIABLE=extruder_state VALUE='"cold"'
    {% endif %}
    SAVE_VARIABLE VARIABLE=extruder_temperature VALUE={params.TARGET|string}
    M99104 {rawparams}
  # else silently drop the command
  {% endif %}
  
# append bed temperature with extra logic
[gcode_macro M140]
rename_existing: M99140
gcode:
  {% set svv = printer.save_variables.variables %}

  {% if svv.heater_mode == "slicer" %}
  # if printer in slicer mode, run command
    {% if params.TARGET != 0 %}
      SAVE_VARIABLE VARIABLE=bed_state VALUE='"hot"'
    {% else %}
      SAVE_VARIABLE VARIABLE=bed_state VALUE='"cold"'
    {% endif %}
    SAVE_VARIABLE VARIABLE=bed_temperature VALUE={params.TARGET|string}
    M99140 {rawparams}
  # else silently drop the command
  {% endif %}

# append set_heater_temperature with extra logic
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing: SET_HEATER_TEMPERATURE2
gcode:
  {% set svv = printer.save_variables.variables %}

  {% if params.MODE == "auto" %}
    # auto meaning it has been called by some variation of the auto filament changer macro
    # sanity check this against the printer state
    {% if svv.heater_mode == "auto" %}
    # if heater mode matches run the command
      SET_HEATER_TEMPERATURE1 {rawparams}
    # else silently block the command
    {% endif %}
    
  {% elif params.MODE == "override" %}
    # just do the thing
    SET_HEATER_TEMPERATURE1 {rawparams}
  
  {% else %}
  # no mode param -> called from mainsail, is a MANUAL command.
    {% if svv.heater_mode == "manual" %}
        SET_HEATER_TEMPERATURE1 {rawparams}
    {% else %}
    # else complain and tell the user they're and idiot
    {action_respond_info("Manual control locked. Printer in: %s" %(svv.heater_state))}
    {% endif %}
  {% endif %}

[gcode_macro SET_HEATER_TEMPERATURE1]
gcode:
  SET_HEATER_TEMPERATURE2 {rawparams}
  # UPDATE SAVED VALUES
  # why is this in caps
  # i don't know
  {% if params.HEATER == "heater_bed" %}
    {% if params.TARGET != 0 %}
      SAVE_VARIABLE VARIABLE=bed_state VALUE='"hot"'
    {% else %}
      SAVE_VARIABLE VARIABLE=bed_state VALUE='"cold"'
    {% endif %}
    SAVE_VARIABLE VARIABLE=bed_temperature VALUE={params.TARGET|float}    

  {% elif params.HEATER == "extruder"%}
    {% if params.TARGET != 0 %}
      SAVE_VARIABLE VARIABLE=extruder_state VALUE='"hot"'
    {% else %}
      SAVE_VARIABLE VARIABLE=extruder_state VALUE='"cold"'
    {% endif %}
    SAVE_VARIABLE VARIABLE=extruder_temperature VALUE={params.TARGET|float}
    
  {% else %}
      {action_raise_error("This isn't supposed to happen")}
  {% endif %}

[gcode_macro SET_HEATER_TEMPERATURE_AND_WAIT]
gcode:
  {% set svv = printer.save_variables.variables %}
  
  {% if params.MODE == "auto" %}
    # auto meaning it has been called by some variation of the auto filament changer macro
    # sanity check this against the printer state
    {% if svv.heater_mode == "auto" %}
    # if heater mode matches run the command
      SET_HEATER_TEMPERATURE_AND_WAIT1 {rawparams}
    # else silently block the command
    {% endif %}
    
  {% elif params.MODE == "override" %}
    # just do the thing
    SET_HEATER_TEMPERATURE_AND_WAIT1 {rawparams}
  
  {% else %}
  # no mode param -> called from mainsail, is a MANUAL command.
    {% if svv.heater_mode == "manual" %}
        SET_HEATER_TEMPERATURE_AND_WAIT1 {rawparams}
    {% else %}
    # else complain and tell the user they're and idiot
    {action_respond_info("Manual control locked. Printer in: %s" %(svv.heater_state))}
    {% endif %}
  {% endif %}

[gcode_macro SET_HEATER_TEMPERATURE_AND_WAIT1]
gcode:
  SET_HEATER_TEMPERATURE1 HEATER={params.HEATER} TARGET={params.TARGET|float}
  
  {% if (params.TARGET|int != 0) %}
    TEMPERATURE_WAIT SENSOR={params.HEATER} MINIMUM={params.TARGET|float - 1} MAXIMUM={params.TARGET|float + 2}
  {% endif %}