Advertisement
rootiest

Untitled

Jul 5th, 2022
1,132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.23 KB | None | 0 0
  1. [gcode_macro TIMELAPSE_TAKE_FRAME]
  2. description: Take Timelapse shoot
  3. variable_enable: False
  4. variable_takingframe: False
  5. variable_park: {'enable': False,
  6.                 'pos'   : 'center',
  7.                 'time'  : 0.1,
  8.                 'custom': {'x': 0, 'y': 0, 'dz': 0},
  9.                 'coord' : {'x': 0, 'y': 0, 'dz': 0}}
  10. variable_extruder: {'fw_retract': False,
  11.                     'retract': 1.0,
  12.                     'extrude': 1.0}
  13. variable_speed: {'travel': 100,
  14.                  'retract': 15,
  15.                  'extrude': 15}
  16. variable_verbose: True
  17. variable_restore: {'absolute': {'coordinates': True, 'extrude': True}, 'speed': 1500, 'e':0, 'factor': {'speed': 1.0, 'extrude': 1.0}}
  18. variable_macro: {'pause': 'PAUSE', 'resume': 'RESUME'}
  19. variable_is_paused: False
  20. gcode:
  21.  {% set hyperlapse = True if params.HYPERLAPSE and params.HYPERLAPSE|lower =='true' else False %}
  22.   {% if enable %}
  23.     {% if (hyperlapse and printer['gcode_macro HYPERLAPSE'].run) or
  24.           (not hyperlapse and not printer['gcode_macro HYPERLAPSE'].run) %}
  25.       {% if park.enable %}
  26.         {% set pos = {'x': park.coord.x, 'y': park.coord.y,
  27.                       'z': [printer.gcode_move.gcode_position.z + park.coord.dz, printer.toolhead.axis_maximum.z]|min} %}
  28.         {% set restore = {'absolute': {'coordinates': printer.gcode_move.absolute_coordinates,
  29.                                        'extrude'    : printer.gcode_move.absolute_extrude},
  30.                           'speed'   : printer.gcode_move.speed,
  31.                           'e'       : printer.gcode_move.gcode_position.e,
  32.                           'factor'  : {'speed'  : printer.gcode_move.speed_factor,
  33.                                        'extrude': printer.gcode_move.extrude_factor}} %}
  34.         SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=restore VALUE="{restore}"
  35.         {% if not printer[printer.toolhead.extruder].can_extrude %}
  36.           {% if verbose %}{action_respond_info("Timelapse: Warning, minimum extruder temperature not reached!")}{% endif %}
  37.         {% else %}
  38.           {% if extruder.fw_retract %}
  39.             G10
  40.           {% else %}
  41.             M83     ; insure relative extrusion
  42.             G0 E-{extruder.retract} F{speed.retract * 60}
  43.           {% endif %}
  44.         {% endif %}
  45.         SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=is_paused VALUE=True
  46.         {macro.pause}            ; execute the klipper PAUSE command
  47.         SET_GCODE_OFFSET X=0 Y=0 ; this will insure that the head parks always at the same position in a multi setup
  48.         G90                      ; insure absolute move
  49.         {% if "xyz" not in printer.toolhead.homed_axes %}
  50.           {% if verbose %}{action_respond_info("Timelapse: Warning, axis not homed yet!")}{% endif %}
  51.         {% else %}
  52.           G0 X{pos.x} Y{pos.y} Z{pos.z} F{speed.travel * 60}
  53.         {% endif %}
  54.         SET_GCODE_VARIABLE MACRO=TIMELAPSE_TAKE_FRAME VARIABLE=takingframe VALUE=True
  55.         UPDATE_DELAYED_GCODE ID=_WAIT_TIMELAPSE_TAKE_FRAME DURATION=0.5
  56.         M400
  57.       {% endif %}
  58.       _TIMELAPSE_NEW_FRAME HYPERLAPSE={hyperlapse}
  59.     {% endif %}    
  60.   {% else %}
  61.     {% if verbose %}{action_respond_info("Timelapse: disabled, take frame ignored")}{% endif %}
  62.   {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement