Skip to content
Permalink
Browse files

added "Retraction Z-Hop" setting to timelapse and altered the capture…

… function in z-change mode so not on every z change pictures are captured but only on a real layer change
  • Loading branch information...
Alex9779 committed Dec 16, 2015
1 parent dedadbc commit 6962fad1ae5397927af6a3f3aff7736bb83cc066
@@ -31,6 +31,9 @@ def getTimelapseData():
config["type"] = "zchange"
config["postRoll"] = timelapse.post_roll
config["fps"] = timelapse.fps
config.update({

This comment has been minimized.

Copy link
@foosel

foosel Mar 7, 2016

Why not

config["retractionZHop"] = timelapse.retraction_zhop

like the others? Or moving the others over to

config.update(dict(type="zchange",
                   postRoll=timelapse.post_roll,
                   fps=timelapse.fps,
                   retractionZHop=timelapse.retraction_zhop))

Might be missing something here...

This comment has been minimized.

Copy link
@Alex9779

Alex9779 Mar 7, 2016

Author Owner

Ok I figured out why I did that. Look at the lines below. On an interval time-lapse there is the interval as the setting only for this type. So when I introduced the new setting specific for the z change time-lapse I copied the style from below.

This comment has been minimized.

Copy link
@foosel

foosel Mar 7, 2016

Ok, ignore that then, entirely my-former-self's fault ;)

"retractionZHop": timelapse.retraction_zhop
})
elif timelapse is not None and isinstance(timelapse, octoprint.timelapse.TimedTimelapse):
config["type"] = "timed"
config["postRoll"] = timelapse.post_roll
@@ -113,6 +116,21 @@ def setTimelapseConfig():
else:
return make_response("Invalid value for interval: %d" % interval)

if "retractionZHop" in request.values:
config["options"] = {
"retractionZHop": 0
}

try:
retractionZHop = float(request.values["retractionZHop"])
except ValueError:
return make_response("Invalid value for retraction Z-Hop: %r" % request.values["retractionZHop"])
else:
if retractionZHop > 0:

This comment has been minimized.

Copy link
@Alex9779

Alex9779 Mar 25, 2016

Author Owner

@foosel here is the problem, comparison must be ">= 0", 0 is a valid value...

This comment has been minimized.

Copy link
@foosel

foosel Mar 29, 2016

Hm, but that shouldn't cause issues here, since it's set to 0 initially (line 121) and only changed here if it differs from 0?

This comment has been minimized.

Copy link
@Alex9779

Alex9779 Mar 30, 2016

Author Owner

Initially yes no problem. But if you have a time-lapse config on and want to disable the z hop setting you can save...

config["options"]["retractionZHop"] = retractionZHop
else:
return make_response("Invalid value for retraction Z-Hop: %d" % retractionZHop)

if admin_permission.can() and "save" in request.values and request.values["save"] in valid_boolean_trues:
octoprint.timelapse.configureTimelapse(config, True)
else:

Large diffs are not rendered by default.

@@ -7,11 +7,13 @@ $(function() {
self.defaultFps = 25;
self.defaultPostRoll = 0;
self.defaultInterval = 10;
self.defaultRetractionZHop = 0;

self.timelapseType = ko.observable(undefined);
self.timelapseTimedInterval = ko.observable(self.defaultInterval);
self.timelapsePostRoll = ko.observable(self.defaultPostRoll);
self.timelapseFps = ko.observable(self.defaultFps);
self.timelapseRetractionZHop = ko.observable(self.defaultRetractionZHop);

self.persist = ko.observable(false);
self.isDirty = ko.observable(false);
@@ -50,6 +52,9 @@ $(function() {
self.timelapseFps.subscribe(function(newValue) {
self.isDirty(true);
});
self.timelapseRetractionZHop.subscribe(function(newValue) {
self.isDirty(true);
});

// initialize list helper
self.listHelper = new ItemListHelper(
@@ -106,6 +111,14 @@ $(function() {
self.timelapseTimedInterval(self.defaultInterval);
}

if (config.type == "zchange") {
if (config.retractionZHop != undefined && config.retractionZHop > 0) {
self.timelapseRetractionZHop(config.retractionZHop);
}
} else {
self.timelapseRetractionZHop(self.defaultRetractionZHop);
}

if (config.postRoll != undefined && config.postRoll >= 0) {
self.timelapsePostRoll(config.postRoll);
} else {
@@ -161,6 +174,10 @@ $(function() {
payload["interval"] = self.timelapseTimedInterval();
}

if (self.timelapseType() == "zchange") {
payload["retractionZHop"] = self.timelapseRetractionZHop();
}

$.ajax({
url: API_BASEURL + "timelapse",
type: "POST",
@@ -373,7 +373,7 @@ table {
}

#temp_newTemp, #temp_newBedTemp, #speed_innerWall, #speed_outerWall, #speed_fill, #speed_support,
#webcam_timelapse_interval, #webcam_timelapse_postRoll, #webcam_timelapse_fps {
#webcam_timelapse_interval, #webcam_timelapse_postRoll, #webcam_timelapse_fps, #webcam_timelapse_retractionZHop {
text-align: right;
}

@@ -33,6 +33,14 @@
</div>
</div>

<div id="webcam_timelapse_retractionsettings" data-bind="visible: timelapseType() == 'zchange'">
<label for="webcam_timelapse_retractionZHop">{{ _('Retraction Z-Hop (in mm)') }}</label>
<div class="input-append">
<input type="text" class="input-mini" id="webcam_timelapse_retractionZHop" data-bind="value: timelapseRetractionZHop, valueUpdate: 'afterkeydown', enable: isOperational() && !isPrinting() && loginState.isUser()">
<span class="add-on">{{ _('mm') }}</span>
</div>
</div>

<div data-bind="visible: loginState.isAdmin">
<label class="checkbox">
<input type="checkbox" data-bind="checked: persist"> {{ _('Save as default') }}
@@ -86,7 +86,10 @@ def configureTimelapse(config=None, persist=False):
if type is None or "off" == type:
current = None
elif "zchange" == type:
current = ZTimelapse(post_roll=postRoll, fps=fps)
retractionZHop = 0
if "options" in config and "retractionZHop" in config["options"] and config["options"]["retractionZHop"] > 0:

This comment has been minimized.

Copy link
@foosel

foosel Mar 7, 2016

Looks like there's a small indentation error here (leading space)

retractionZHop = config["options"]["retractionZHop"]
current = ZTimelapse(post_roll=postRoll, retraction_zhop=retractionZHop, fps=fps)
elif "timed" == type:
interval = 10
if "options" in config and "interval" in config["options"] and config["options"]["interval"] > 0:
@@ -404,18 +407,26 @@ def clean_capture_dir(self):


class ZTimelapse(Timelapse):
def __init__(self, post_roll=0, fps=25):
def __init__(self, post_roll=0, retraction_zhop=0, fps=25):
Timelapse.__init__(self, post_roll=post_roll, fps=fps)
self._retraction_zhop = retraction_zhop
self._logger.debug("ZTimelapse initialized")

@property
def retraction_zhop(self):
return self._retraction_zhop

def event_subscriptions(self):
return [
(Events.Z_CHANGE, self._on_z_change)
]

def config_data(self):
return {
"type": "zchange"
"type": "zchange",
"options": {
"retractionZHop": self._retraction_zhop
}
}

def process_post_roll(self):
@@ -432,7 +443,10 @@ def process_post_roll(self):
Timelapse.process_post_roll(self)

def _on_z_change(self, event, payload):
self.captureImage()
diff = round(payload["new"] - payload["old"], 3)
zhop = round(self._retraction_zhop, 3)
if diff > 0 and diff != zhop:
self.captureImage()


class TimedTimelapse(Timelapse):

0 comments on commit 6962fad

Please sign in to comment.
You can’t perform that action at this time.