Skip to content

Instantly share code, notes, and snippets.

@bumbummen99
Last active November 24, 2022 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bumbummen99/e40265bec89519d4aa882bccb1232068 to your computer and use it in GitHub Desktop.
Save bumbummen99/e40265bec89519d4aa882bccb1232068 to your computer and use it in GitHub Desktop.
These are my G-Code script's that i am using in OctoPrint with my Ender 3 Pro running the Marlin firmware.

G-Code Scripts

These are my G-Code script's that i am using in OctoPrint with my Ender 3 Pro running the Marlin firmware.

After pause

; check for paused state
{% if pause_position.x is not none %}
  ; relative XYZE
  G91
  M83

  ; retract filament, move Z slightly upwards
  G1 Z+5 E-5 F4500

  ; absolute XYZE
  M82
  G90

  ; move to a safe rest position, adjust as necessary
  G1 X0 Y0
  
  ; disable all heaters
  {% snippet 'disable_hotends' %}
  {% snippet 'disable_bed' %}
  
  ; disable fan
  M106 S0
{% endif %}

Before resume

; check for paused state
{% if pause_position.x is not none %}
  ; enable fan
  M106 S255
  
  ; heat the nozzle
  {% for tool in range(printer_profile.extruder.count) %}
      {% if pause_temperature[tool] and pause_temperature[tool]['target'] is not none %}
          {% if tool == 0 and printer_profile.extruder.count == 1 %}
              M109 T{{ tool }} S{{ pause_temperature[tool]['target'] }}
          {% else %}
              M109 S{{ pause_temperature[tool]['target'] }}
          {% endif %}
      {% else %}
          {% if tool == 0 and printer_profile.extruder.count == 1 %}
              M104 T{{ tool }} S0
          {% else %}
              M104 S0
          {% endif %}
      {% endif %}
  {% endfor %}

  ; heat the bed 
  {% if printer_profile.heatedBed %}
      {% if pause_temperature['b'] and pause_temperature['b']['target'] is not none %}
          M190 S{{ pause_temperature['b']['target'] }}
      {% else %}
          M140 S0
      {% endif %}
  {% endif %}

  ; relative extruder
  M83

  ; prime nozzle
  G1 E-5 F4500
  G1 E5 F4500
  G1 E5 F4500

  ; absolute E
  M82

  ; absolute XYZ
  G90

  ; reset E
  G92 E{{ pause_position.e }}

  ; move back to pause position XYZ
  G1 X{{ pause_position.x }} Y{{ pause_position.y }} Z{{ pause_position.z }} F4500

  ; reset to feed rate before pause if available
  {% if pause_position.f is not none %}
    G1 F{{ pause_position.f }}
  {% endif %}
{% endif %}

Todo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment