Skip to content

Commit

Permalink
The last update broke snapshots somehow. Reverting.
Browse files Browse the repository at this point in the history
  • Loading branch information
FormerLurker committed Mar 27, 2018
1 parent d47029e commit d28fe47
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions octoprint_octolapse/timelapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,13 @@ def _take_timelapse_snapshot(self, trigger, triggering_command):
timelapse_snapshot_payload["snapshot_gcode"] = snapshot_gcode
assert (isinstance(snapshot_gcode, SnapshotGcode))

self.Settings.current_debug_profile().log_snapshot_gcode("Sending snapshot start gcode and snapshot commands.")

if snapshot_gcode.StartGcode is not None and len(snapshot_gcode.StartGcode) > 0:
gcodes_to_send = snapshot_gcode.StartGcode + snapshot_gcode.SnapshotCommands
else:
gcodes_to_send = snapshot_gcode.SnapshotCommands
self.Settings.current_debug_profile().log_snapshot_gcode(
"Sending snapshot start gcode and snapshot commands.")
# park the printhead in the snapshot position and wait for the movement to complete
snapshot_position = self.get_position_async(start_gcode=gcodes_to_send)
snapshot_position = self.get_position_async(
start_gcode=snapshot_gcode.StartGcode + snapshot_gcode.SnapshotCommands

)
timelapse_snapshot_payload["snapshot_position"] = snapshot_position
# record the snapshot start time
snapshot_start_time = time.time()
Expand All @@ -282,15 +280,34 @@ def _take_timelapse_snapshot(self, trigger, triggering_command):

self.Settings.current_debug_profile().log_snapshot_gcode("Sending snapshot return gcode.")
# return the printhead to the start position
if snapshot_gcode.EndGcode is not None and len(snapshot_gcode.EndGcode) > 0:
gcodes_to_send = snapshot_gcode.EndGcode + snapshot_gcode.ReturnCommands
else:
gcodes_to_send = snapshot_gcode.ReturnCommands
return_position = self.get_position_async(
start_gcode=snapshot_gcode.ReturnCommands
)

# Note that sending the EndGccode via the end_gcode parameter allows us to execute additional
# gcode and still know when the ReturnCommands were completed. Hopefully this will reduce delays.
timelapse_snapshot_payload["return_position"] = return_position

self.Settings.current_debug_profile().log_snapshot_gcode("Sending snapshot end gcode.")
# send the end gcode
end_position = self.get_position_async(
start_gcode=snapshot_gcode.EndGcode
)

# calculate the return movement time
return_time = time.time() - return_start_time

self.OctoprintPrinter.commands(gcodes_to_send)
# Note that sending the EndGccode via the end_gcode parameter allows us to execute additional
# gcode and still know when the ReturnCommands were completed. Hopefully this will reduce delays.
timelapse_snapshot_payload["end_position"] = end_position

timelapse_snapshot_payload["current_snapshot_time"] = 0
timelapse_snapshot_payload["total_snapshot_time"] = 0
# calculate the total snapshot time
# Note that we use 2 * return_time as opposed to snapshot_travel_time + return_time.
# This is so we can avoid sending an M400 until after we've lifted and hopped
current_snapshot_time = snapshot_time + 2 * return_time
self.SecondsAddedByOctolapse += current_snapshot_time
timelapse_snapshot_payload["current_snapshot_time"] = current_snapshot_time
timelapse_snapshot_payload["total_snapshot_time"] = self.SecondsAddedByOctolapse

# we've completed the procedure, set success
timelapse_snapshot_payload["success"] = True
Expand Down

0 comments on commit d28fe47

Please sign in to comment.