Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=====================================================
- # MANUAL SET CAPTURE TARGET
- #=====================================================
- [gcode_macro GPHOTO_SET_TARGET]
- gcode:
- RUN_SHELL_COMMAND CMD=gphoto2_set_config
- #=====================================================
- # ENABLE TIMELAPSE
- #=====================================================
- [gcode_macro ENABLE_TIMELAPSE]
- description: enables or disables timelapse functionality by using a variable.
- variable_enabled: 0
- gcode:
- {% set new_state= params.VALUE|default(1)|int %}
- SET_GCODE_VARIABLE MACRO=ENABLE_TIMELAPSE VARIABLE=enabled VALUE={new_state}
- #=====================================================
- # TAKE SNAPSHOT COMMAND
- #=====================================================
- [gcode_macro TAKE_SNAPSHOT]
- description: Saves current location, moves toolhead to rear of bed, and takes a snapshot before returning.
- gcode:
- {% if printer["gcode_macro ENABLE_TIMELAPSE"].enabled is 1 %}
- {% set delayMS = 2000 %} ; Delay after moving and before taking the snapshot, deals with buffering so we don't get the print head in motion
- {% set snapshotPositionX = printer.toolhead.axis_maximum.x / 2 %} ; Middle of bed
- {% set snapshotPositionY = printer.toolhead.axis_maximum.y - 5 %} ; rear of bed w/ some buffer
- {% set currentX = printer.gcode_move.gcode_position.x %}
- {% set currentY = printer.gcode_move.gcode_position.y %}
- {% set currentZ = printer.gcode_move.gcode_position.z %} ; could be used for z-hop which we are not doing in this macro, so it's best to run this in AFTER_LAYER_CHANGE
- SAVE_GCODE_STATE NAME=take_snapshot_state ; save current state
- {% if printer.extruder.can_extrude|lower == 'true' %}
- G10 ; retract
- {% endif %}
- G90 ; absolute positioning
- G0 X{snapshotPositionX} Y{snapshotPositionY} F25000.0 ;Move to snapshot position
- G4 P{delayMS} ; Dwell for delayMS seconds
- RUN_SHELL_COMMAND CMD=gphoto2_trigger_snapshot
- G0 X{currentX} Y{currentY} F25000.0 ;Return to original position
- {% if printer.extruder.can_extrude|lower == 'true' %}
- G11 ; unretract
- {% endif %}
- RESTORE_GCODE_STATE NAME=take_snapshot_state ; restore saved state
- {% endif %}
- #=====================================================
- # MANUAL SNAPSHOT TEST
- #=====================================================
- [gcode_macro GPHOTO_SNAPSHOT_TEST]
- gcode:
- RUN_SHELL_COMMAND CMD=gphoto2_trigger_snapshot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement