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
This commit is contained in:
parent
dedadbc9ac
commit
6962fad1ae
6 changed files with 63 additions and 6 deletions
|
|
@ -31,6 +31,9 @@ def getTimelapseData():
|
|||
config["type"] = "zchange"
|
||||
config["postRoll"] = timelapse.post_roll
|
||||
config["fps"] = timelapse.fps
|
||||
config.update({
|
||||
"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:
|
||||
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:
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -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:
|
||||
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,10 +407,15 @@ class Timelapse(object):
|
|||
|
||||
|
||||
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)
|
||||
|
|
@ -415,7 +423,10 @@ class ZTimelapse(Timelapse):
|
|||
|
||||
def config_data(self):
|
||||
return {
|
||||
"type": "zchange"
|
||||
"type": "zchange",
|
||||
"options": {
|
||||
"retractionZHop": self._retraction_zhop
|
||||
}
|
||||
}
|
||||
|
||||
def process_post_roll(self):
|
||||
|
|
@ -432,7 +443,10 @@ class ZTimelapse(Timelapse):
|
|||
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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue