✨ Add setting for sd cancel command (#4408)

* adds a setting for sd cancel command, #4368
not binding to settingsViewModel as expected, needs adjustment to API?

* add settings API bits for binding issue

* instantiate setting on init.
This commit is contained in:
jneilliii authored and GitHub committed 2022-02-09 18:53:10 +01:00
1 parent e9c33e1f28
commit b21099b5a0
5 files changed
+14 -1

No files matched your search

+3
View File
@@ -206,6 +206,7 @@ def getSettings():
"blockedCommands": s.get(["serial", "blockedCommands"]),
"ignoredCommands": s.get(["serial", "ignoredCommands"]),
"pausingCommands": s.get(["serial", "pausingCommands"]),
"sdCancelCommand": s.get(["serial", "sdCancelCommand"]),
"emergencyCommands": s.get(["serial", "emergencyCommands"]),
"helloCommand": s.get(["serial", "helloCommand"]),
"ignoreErrorsFromFirmware": s.getBoolean(
@@ -812,6 +813,8 @@ def _saveSettings(data):
data["serial"]["pausingCommands"], (list, tuple)
):
s.set(["serial", "pausingCommands"], data["serial"]["pausingCommands"])
if "sdCancelCommand" in data["serial"]:
s.set(["serial", "sdCancelCommand"], data["serial"]["sdCancelCommand"])
if "emergencyCommands" in data["serial"] and isinstance(
data["serial"]["emergencyCommands"], (list, tuple)
):
+1
View File
@@ -139,6 +139,7 @@ default_settings = {
"sdRelativePath": False,
"sdAlwaysAvailable": False,
"sdLowerCase": False,
"sdCancelCommand": "M25",
"maxNotSdPrinting": 2,
"swallowOkAfterResend": True,
"repetierTargetTemp": False,
@@ -212,6 +212,7 @@ $(function () {
self.serial_blockedCommands = ko.observable(undefined);
self.serial_ignoredCommands = ko.observable(undefined);
self.serial_pausingCommands = ko.observable(undefined);
self.serial_sdCancelCommand = ko.observable(undefined);
self.serial_emergencyCommands = ko.observable(undefined);
self.serial_helloCommand = ko.observable(undefined);
self.serial_serialErrorBehaviour = ko.observable("cancel");
@@ -446,6 +446,13 @@
<span class="help-inline">{{ _('Use this to specify commands on which OctoPrint should pause the print job. Just the G or M code, comma separated. Defaults to <code>M0</code>, <code>M1</code> and <code>M25</code>.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-serialSdCancelCommand">{{ _('SD Cancel Command') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-serialSdCancelCommand" data-bind="value: serial_sdCancelCommand">
<span class="help-inline">{{ _('The command to send to printer when cancelling a SD card print. Defaults to <code>M25</code>.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-serialEmergencyCommands">{{ _('Emergency commands') }}</label>
<div class="controls">
+2 -1
View File
@@ -559,6 +559,7 @@ class MachineCom:
self._sdAlwaysAvailable = settings().getBoolean(["serial", "sdAlwaysAvailable"])
self._sdRelativePath = settings().getBoolean(["serial", "sdRelativePath"])
self._sdLowerCase = settings().getBoolean(["serial", "sdLowerCase"])
self._sdCancelCommand = settings().get(["serial", "sdCancelCommand"])
self._blockWhileDwelling = settings().getBoolean(["serial", "blockWhileDwelling"])
self._send_m112_on_error = settings().getBoolean(["serial", "sendM112OnError"])
self._disable_sd_printing_detection = settings().getBoolean(
@@ -1737,7 +1738,7 @@ class MachineCom:
if self.isSdFileSelected():
if not external_sd:
self.sendCommand(
"M25",
self._sdCancelCommand,
part_of_job=True,
tags=tags | cancel_tags,
) # pause print