Update icon + add command setting
Update icon to new FA icon to be compatible with octoprint 1.3.5's move to an update font awesome Add a setting to allow changing of the command in situations where the user may wish to issue some other command other than M112
This commit is contained in:
parent
33b2352afb
commit
4f37707acb
@ -3,8 +3,18 @@ from __future__ import absolute_import
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
class EstopPlugin(octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin):
|
||||
class EstopPlugin(octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.SettingsPlugin):
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(estopCommand = "M112")
|
||||
|
||||
def on_after_startup(self):
|
||||
self.estopCommand = self._settings.get(["estopCommand"])
|
||||
if (self.estopCommand != "M112"):
|
||||
self._logger.warn("WARNING! EMERGENCY STOP COMMAND HAS BEEN CHANGED FROM DEFAULT \"M112\" TO \"" + self.estopCommand + "\"")
|
||||
|
||||
def get_assets(self):
|
||||
return dict(
|
||||
@ -13,7 +23,8 @@ class EstopPlugin(octoprint.plugin.AssetPlugin,
|
||||
)
|
||||
def get_template_configs(self):
|
||||
return [
|
||||
dict(type="sidebar", name="Emergency STOP!", icon="fa icon-print", template="estop_sidebar.jinja2", styles=["display: none"], data_bind="visible: loginState.isUser")
|
||||
dict(type="sidebar", name="Emergency STOP!", icon="fa fa-print", template="estop_sidebar.jinja2", styles=["display: none"], data_bind="visible: loginState.isUser"),
|
||||
dict(type="settings", name="E-Stop Settings", template="estop_settings.jinja2", custom_bindings=False)
|
||||
]
|
||||
|
||||
def get_update_information(self):
|
||||
|
@ -8,6 +8,9 @@ $(function() {
|
||||
|
||||
self.loginState = parameters[0];
|
||||
self.printerState = parameters[1];
|
||||
self.settings = parameters[2];
|
||||
|
||||
self.estopCommand = ko.observable("M112");
|
||||
|
||||
self.enableEstop = ko.pureComputed(function() {
|
||||
return self.printerState.isOperational() && self.loginState.isUser();
|
||||
@ -25,9 +28,18 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
self.buttonTitle = ko.pureComputed(function() {
|
||||
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
|
||||
return gettext("Sends " + self.estopCommand() + " to the printer IMMEDIATELY");
|
||||
});
|
||||
|
||||
self.onBeforeBinding = function () {
|
||||
//self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
|
||||
}
|
||||
self.sendEstopCommand = function () {
|
||||
if (self.enableEstop()) {
|
||||
OctoPrint.control.sendGcode("M112");
|
||||
self.estopCommand(self.settings.settings.plugins.estop.estopCommand());
|
||||
OctoPrint.control.sendGcode(self.estopCommand());
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -37,7 +49,7 @@ $(function() {
|
||||
dependencies: [
|
||||
"loginStateViewModel",
|
||||
"printerStateViewModel",
|
||||
],
|
||||
"settingsViewModel"],
|
||||
elements: ["#sidebar_plugin_estop_wrapper"]
|
||||
});
|
||||
});
|
||||
|
13
octoprint_estop/templates/estop_settings.jinja2
Normal file
13
octoprint_estop/templates/estop_settings.jinja2
Normal file
@ -0,0 +1,13 @@
|
||||
<h3>{{ _('E-Stop Settings') }}</h3>
|
||||
<div>
|
||||
<p>Here you can change the command issued to your printer when you press the emergency stop button.</p>
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Emergency STOP! Command') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block" data-bind="value: settings.plugins.estop.estopCommand">
|
||||
<span class="help-block">Usually this is M112. Only change if you know what you're doing.</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
@ -1,4 +1,4 @@
|
||||
<div id="sidebar_estop_background" class="estop_sidebar" data-bind="css: estopState">
|
||||
<button type="button" id="emergemcy_stop" title="send M112 estop gcode command" class="btn-estop" data-bind="text: buttonText, enable: enableEstop, click: function() { sendEstopCommand() }"></button>
|
||||
<button type="button" id="emergemcy_stop" class="btn-estop" data-bind="attr: { title: buttonTitle }, text: buttonText, enable: enableEstop, click: function() { sendEstopCommand() }"></button>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user