estop plugin
This commit is contained in:
23
octoprint_estop/__init__.py
Normal file
23
octoprint_estop/__init__.py
Normal file
@ -0,0 +1,23 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
class EstopPlugin(octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin):
|
||||
|
||||
def get_assets(self):
|
||||
return dict(
|
||||
js=["js/estop.js"],
|
||||
css=["css/estop.css"]
|
||||
)
|
||||
def get_template_configs(self):
|
||||
return [dict(type="sidebar", name="Emergency STOP!", icon="fa fa-times")]
|
||||
|
||||
__plugin_name__ = "Emergency Stop Button"
|
||||
|
||||
def __plugin_load__():
|
||||
global __plugin_implementation__
|
||||
__plugin_implementation__ = EstopPlugin()
|
||||
|
||||
|
63
octoprint_estop/static/css/estop.css
Normal file
63
octoprint_estop/static/css/estop.css
Normal file
@ -0,0 +1,63 @@
|
||||
.estop_sidebar {
|
||||
width:100%;
|
||||
height:28px;
|
||||
background-image: repeating-linear-gradient(
|
||||
-45deg,
|
||||
#000,
|
||||
#000 4px,
|
||||
#ff0 4px,
|
||||
#ff0 8px
|
||||
);
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.btn-estop {
|
||||
width: 80%;
|
||||
height: 28px;
|
||||
color: #ffffff;
|
||||
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
|
||||
background-color: #eb0000;
|
||||
background-image: -moz-linear-gradient(top, #ff0000, #cc0000);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ff0000), to(#cc0000));
|
||||
background-image: -webkit-linear-gradient(top, #ff0000, #cc0000);
|
||||
background-image: -o-linear-gradient(top, #ff0000, #cc0000);
|
||||
background-image: linear-gradient(to bottom, #ff0000, #cc0000);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #cc0000 #cc0000 #800000;
|
||||
border-width: 0;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff0000', endColorstr='#ffcc0000', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
display: inline-block;
|
||||
padding: 0px;
|
||||
margin-bottom: 0;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
line-height: 20px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.btn-estop:hover {
|
||||
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
|
||||
background-color: #eb0000;
|
||||
background-image: -moz-linear-gradient(top, #dd0000, #cc0000);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#dd0000), to(#cc0000));
|
||||
background-image: -webkit-linear-gradient(top, #dd0000, #cc0000);
|
||||
background-image: -o-linear-gradient(top, #dd0000, #cc0000);
|
||||
background-image: linear-gradient(to bottom, #dd0000, #cc0000);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #cc0000 #cc0000 #800000;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff0000', endColorstr='#ffcc0000', GradientType=0);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
text-decoration: none;
|
||||
|
||||
}
|
||||
.btn-estop:active {
|
||||
text-decoration: overline underline;
|
||||
}
|
||||
.btn-estop:disabled {
|
||||
text-shadow: 0px 0px 0 rgba(0, 0, 0, 0.0);
|
||||
color: #555;
|
||||
opacity: 0.8;
|
||||
cursor: not-allowed;
|
||||
}
|
25
octoprint_estop/static/js/estop.js
Normal file
25
octoprint_estop/static/js/estop.js
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Author: ntoff
|
||||
* License: AGPLv3
|
||||
*/
|
||||
$(function() {
|
||||
function EstopViewModel(parameters) {
|
||||
var self = this;
|
||||
//see if we're logged in and the printer is operational (for en/disable of button)
|
||||
self.loginState = parameters[0];
|
||||
self.terminal = parameters[1];
|
||||
|
||||
self.sendEstopCommand = function () {
|
||||
OctoPrint.control.sendGcode("M112"); //should this ever be a variable? M112 universal?
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: EstopViewModel,
|
||||
dependencies: [
|
||||
"loginStateViewModel",
|
||||
"terminalViewModel",
|
||||
],
|
||||
elements: ["#sidebar_plugin_estop"]
|
||||
});
|
||||
});
|
4
octoprint_estop/templates/estop_sidebar.jinja2
Normal file
4
octoprint_estop/templates/estop_sidebar.jinja2
Normal file
@ -0,0 +1,4 @@
|
||||
<div class="estop_sidebar">
|
||||
<button type="button" id="emergemcy_stop" title="send M112 estop gcode command" class="btn-estop" data-bind="enable: terminal.isOperational() && loginState.isAdmin(), click: function() { sendEstopCommand() }"><i class="fa fa-times" size="+2"></i>{{ _(' EMERGENCY STOP ') }}<i class="fa fa-times" size="+2"></i></button>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user