Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
5634e7e2a0 | |||
|
b810440070 | ||
|
fb697050cb | ||
|
98ff9616f6 | ||
|
acf3fcce64 | ||
|
a6d224be14 | ||
|
9a7602b622 | ||
|
28edc70855 | ||
|
02211eb475 | ||
|
84dcad7b08 | ||
|
78dd50ffb1 | ||
|
212f6a7cf8 | ||
|
5dc813fb7b | ||
|
2a779c9489 | ||
|
b5693e2e34 | ||
|
55b2a05531 |
@ -12,10 +12,14 @@ Slide the slider, click the button. There really isn't much else to do :)
|
||||
|
||||
* The default value of the slider is user configurable, this is the value that the slider will be set to upon loading OctoPrint's UI, and any time you refresh the page.
|
||||
|
||||
* The remember last speed checkbox will tell the plugin to save the fan speed as it gets sent to the printer, and set the slider to that value on load / refresh (overrides the default value setting).
|
||||
|
||||
* The minimum fan speed setting will limit how slow the fan runs, this is useful since some fans don't work below a certain speed.
|
||||
|
||||
* The maximum fan speed setting will limit how fast the fan runs, this is useful if your fan is too strong, or you wish to limit the speed post-slice without having to re-slice your file.
|
||||
|
||||
* "Disable M106 / M107" will disable the controls and reject all M106/M107 commands before they're sent to the printer. This setting has a corresponding padlock button beside the off button, both the padlock button and this setting in the settings page do exactly the same thing. This setting is here only as a convenience.
|
||||
|
||||
* Notification autohide delay controls how long any notifications will remain on the screen for. If the user manually sets a speed outside of the set range, a notification will be displayed informing the user the fan speed has been modified. Print jobs shouldn't trigger these notifications, and so popup spam shouldn't occur, however if a user wishes not to receive notifications when setting fan speeds outside of the set range, this value can be set to 0 (zero) to disable notifications. (this setting won't / shouldn't affect OctoPrint's global notifications, it only applies to info popups generated by this plugin).
|
||||
|
||||
*Note: Slider does __not__ follow the speed of the fan. If the fan speed is set via gcode or an LCD panel on the printer, the slider will not respond to the change. It is a __setting__, not an indicator, and functions the same way the feedrate and flowrate sliders do.*
|
||||
|
BIN
image/slider.JPG
BIN
image/slider.JPG
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
@ -9,6 +9,11 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.AssetPlugin):
|
||||
|
||||
def __init__(self):
|
||||
self.minPWM=0,
|
||||
self.maxPWM=255,
|
||||
self.lockfan=False
|
||||
|
||||
def on_after_startup(self):
|
||||
self.get_settings_updates()
|
||||
@ -18,7 +23,10 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
|
||||
defaultFanSpeed=100,
|
||||
minSpeed=0,
|
||||
maxSpeed=100,
|
||||
notifyDelay=4000
|
||||
notifyDelay=4000,
|
||||
lockfan=False,
|
||||
lastSentSpeed=0,
|
||||
defaultLastSpeed=False
|
||||
)
|
||||
|
||||
def on_settings_save(self, data):
|
||||
@ -31,6 +39,12 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
|
||||
s.setInt(["maxSpeed"], data["maxSpeed"])
|
||||
if "notifyDelay" in data.keys():
|
||||
s.setInt(["notifyDelay"], data["notifyDelay"])
|
||||
if "lockfan" in data.keys():
|
||||
s.set(["lockfan"], data["lockfan"])
|
||||
if "lastSentSpeed" in data.keys():
|
||||
s.setInt(["lastSentSpeed"], data["lastSentSpeed"])
|
||||
if "defaultLastSpeed" in data.keys():
|
||||
s.set(["defaultLastSpeed"], data["defaultLastSpeed"])
|
||||
self.get_settings_updates()
|
||||
#clean up settings if everything's default
|
||||
self.on_settings_cleanup()
|
||||
@ -76,24 +90,28 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
|
||||
self.defaultFanSpeed = self._settings.getInt(["defaultFanSpeed"])
|
||||
self.minSpeed = self._settings.getInt(["minSpeed"])
|
||||
self.maxSpeed = self._settings.getInt(["maxSpeed"])
|
||||
|
||||
self.lockfan = self._settings.get(["lockfan"])
|
||||
|
||||
getcontext().prec=5 #sets precision for "Decimal" not sure if this'll cause conflicts, ideas?
|
||||
self.minPWM = round( Decimal(self.minSpeed) * Decimal(2.55), 2 )
|
||||
self.maxPWM = round( Decimal(self.maxSpeed) * Decimal(2.55), 2 )
|
||||
|
||||
def rewrite_m106(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
|
||||
if gcode and gcode.startswith('M106'):
|
||||
fanPwm = re.search("S(\d+.\d+)", cmd)
|
||||
if gcode and gcode.startswith('M106') and not self.lockfan:
|
||||
fanPwm = re.search("S(\d+\.?\d*)", cmd)
|
||||
if fanPwm and fanPwm.group(1):
|
||||
fanPwm = fanPwm.group(1)
|
||||
if Decimal(fanPwm) < self.minPWM and Decimal(fanPwm) != 0:
|
||||
self._logger.info("fan pwm value " + str(fanPwm) + " is below threshold, increasing to " + str(self.minPWM) + " (" + str(self.minSpeed) + "%)")
|
||||
cmd = "M106 S" + str(self.minPWM)
|
||||
cmd = "M106 S" + str(self.minPWM)
|
||||
return cmd,
|
||||
elif Decimal(fanPwm) > self.maxPWM:
|
||||
self._logger.info("fan pwm value " + str(fanPwm) + " is above threshold, decreasing to " + str(self.maxPWM) + " (" + str(self.maxSpeed) + "%)")
|
||||
cmd = "M106 S" + str(self.maxPWM)
|
||||
return cmd,
|
||||
elif gcode and gcode.startswith(('M106', 'M107')) and self.lockfan:
|
||||
self._logger.info("A cooling fan control command was seen, but fanspeedslider is locked. Control command " + str(cmd) + " removed from queue.")
|
||||
return None,
|
||||
|
||||
def get_update_information(self):
|
||||
return dict(
|
||||
@ -113,6 +131,7 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
|
||||
)
|
||||
|
||||
__plugin_name__ = "Fan Speed Control"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
|
||||
def __plugin_load__():
|
||||
global __plugin_implementation__
|
||||
|
@ -17,18 +17,24 @@ $(function () {
|
||||
self.settings.minFanSpeed = new ko.observable(0); //this,
|
||||
self.settings.maxFanSpeed = new ko.observable(100); //and this are percents 0 - 100%
|
||||
self.settings.notifyDelay = new ko.observable(4000); //time in milliseconds
|
||||
self.settings.lockfan = new ko.observable(false); //ignore fan inputs from gcode and lock the fan buttons
|
||||
self.settings.defaultLastSpeed = new ko.observable(false); //options page option to set the slider to the last sent fan speed value on load/refresh
|
||||
self.settings.lastSentSpeed = new ko.observable(null); //the last speed value that was sent to the printer
|
||||
|
||||
self.control.lockTitle = new ko.observable(gettext("Unlocked")); //will set the hover title info for the fan lock button
|
||||
|
||||
//Not sure why I put these here, I swear I had a plan when I did it, something about dynamic text? I dunno, should move it back to the settings page
|
||||
self.settings.commonTitle = ko.observable(gettext("\n\nThis allows limiting the cooling fan without having to re-slice your model.\n\nLimited to prints controlled by OctoPrint."));
|
||||
self.settings.defaultTitle = ko.observable(gettext("This is the value the slider will default to when the UI is loaded / refreshed."));
|
||||
self.settings.minTitle = ko.observable(gettext("Set this to the lowest value at which your fan will spin.") + self.settings.commonTitle());
|
||||
self.settings.maxTitle = ko.observable(gettext("Set this <100% if your cooling fan is too strong on full.") + self.settings.commonTitle());
|
||||
self.settings.noticeTitle = ko.observable(gettext("Notifications only apply when setting the speed via the slider + button in the UI. Set to 0 (zero) to disable notifications."));
|
||||
|
||||
self.settings.lastspeedTitle = ko.observable(gettext("Instead of defaulting to the speed set by \"Default Value\", the slider will be set to the last sent speed on load / refresh. \n\n Note: It takes into account the min/max value setting and overrides the \"Default Value\" setting."));
|
||||
|
||||
self.showNotify = function (self, options) {
|
||||
options.hide = true;
|
||||
options.title = "Fan Speed Control";
|
||||
options.delay = self.settings.notifyDelay();
|
||||
options.type = "info";
|
||||
options.delay = options.delay || self.settings.notifyDelay();
|
||||
options.type = options.type || "info";
|
||||
if (options.delay != "0") {
|
||||
new PNotify(options);
|
||||
}
|
||||
@ -44,6 +50,7 @@ $(function () {
|
||||
console.log("Fan Speed Control Plugin: " + self.control.fanSpeed() + "% is less than the minimum speed (" + self.settings.minFanSpeed() + "%), increasing.");
|
||||
self.control.fanSpeed(self.settings.minFanSpeed());
|
||||
var options = {
|
||||
hide: true,
|
||||
text: gettext('Fan speed increased to meet minimum speed requirement.'),
|
||||
addclass: 'fan_speed_notice_low',
|
||||
}
|
||||
@ -55,6 +62,7 @@ $(function () {
|
||||
console.log("Fan Speed Control Plugin: " + self.control.fanSpeed() + "% is more than the maximum speed (" + self.settings.maxFanSpeed() + "%), decreasing.");
|
||||
self.control.fanSpeed(self.settings.maxFanSpeed());
|
||||
var options = {
|
||||
hide: true,
|
||||
text: gettext('Fan speed decreased to meet maximum speed requirement.'),
|
||||
addclass: 'fan_speed_notice_high',
|
||||
}
|
||||
@ -68,8 +76,35 @@ $(function () {
|
||||
self.control.sendFanSpeed = function () {
|
||||
self.control.checkSliderValue();
|
||||
self.control.sendCustomCommand({ command: "M106 S" + self.control.fanSpeedToPwm() });
|
||||
|
||||
if (self.settings.defaultLastSpeed()) {
|
||||
self.settings.settings.plugins.fanspeedslider.lastSentSpeed(self.control.fanSpeed());
|
||||
self.settings.saveData();
|
||||
self.updateSettings();
|
||||
}
|
||||
};
|
||||
|
||||
self.control.lockFanInput = function () {
|
||||
self.settings.settings.plugins.fanspeedslider.lockfan(!self.settings.settings.plugins.fanspeedslider.lockfan());
|
||||
self.settings.saveData();
|
||||
self.updateSettings();
|
||||
|
||||
var options = {
|
||||
type: "info",
|
||||
hide: true,
|
||||
delay: 1000*60,
|
||||
text: gettext('CAUTION!! Fan speed commands are now being ignored! \n This includes commands sent via gcode and the terminal!'),
|
||||
addclass: 'fan_speed_notice_fanlocked',
|
||||
}
|
||||
if (self.settings.lockfan() && $(".fan_speed_notice_fanlocked").length <1) {
|
||||
self.showNotify(self, options);
|
||||
}
|
||||
}
|
||||
//disables the on/off buttons if the lock is enabled
|
||||
self.control.islocked = ko.pureComputed(function () {
|
||||
return self.settings.settings.plugins.fanspeedslider.lockfan();
|
||||
});
|
||||
|
||||
//ph34r
|
||||
try {
|
||||
//for some reason touchui uses "jog general" for the fan controls? Oh well, makes my job easier
|
||||
@ -84,8 +119,13 @@ $(function () {
|
||||
//add new fan controls
|
||||
$("#control-jog-general").find("button").eq(0).before("\
|
||||
<input type=\"number\" style=\"width: 95px\" data-bind=\"slider: {min: 00, max: 100, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
|
||||
<button class=\"btn btn-block control-box\" id=\"fan-on\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.sendFanSpeed() }\">" + gettext("Fan speed") + ":<span data-bind=\"text: fanSpeed() + '%'\"></span></button>\
|
||||
<button class=\"btn btn-block control-box\" id=\"fan-off\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.sendCustomCommand({ type: 'command', commands: ['M106 S0'] }) }\">" + gettext("Fan off") + "</button>\
|
||||
<button class=\"btn btn-block control-box\" id=\"fan-on\" data-bind=\"enable: isOperational() && loginState.isUser() && !islocked(), click: function() { $root.sendFanSpeed() }\">" + gettext("Fan speed") + ":<span data-bind=\"text: fanSpeed() + '%'\"></span></button>\
|
||||
<div class=\"btn-group\">\
|
||||
<button class=\"btn \" id=\"fan-off\" data-bind=\"enable: isOperational() && loginState.isUser() && !islocked(), click: function() { $root.sendCustomCommand({ type: 'command', commands: ['M106 S0'] }) }\">" + gettext("Fan off") + "</button>\
|
||||
<button class=\"btn \" id=\"fan-lock\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.lockFanInput() }, attr: { title: lockTitle } \">\
|
||||
<i class=\"fa fa-unlock\" data-bind=\"css: {'fa-lock': islocked(), 'fa-unlock': !islocked()}\"></i>\
|
||||
</button>\
|
||||
</div>\
|
||||
");
|
||||
} else {
|
||||
//replace touch UI's fan on button with one that sends whatever speed is set in this plugin
|
||||
@ -96,8 +136,11 @@ $(function () {
|
||||
//also add spin box + button below in its own section, button is redundant but convenient
|
||||
$("#control-jog-feedrate").append("\
|
||||
<input type=\"number\" style=\"width: 150px\" data-bind=\"slider: {min: 00, max: 100, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
|
||||
<button class=\"btn btn-block\" style=\"width: 169px\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.sendFanSpeed() }\">" + gettext("Fan speed:") + "<span data-bind=\"text: fanSpeed() + '%'\"></span></button>\
|
||||
");
|
||||
<button class=\"btn btn-block\" style=\"width: 169px\" data-bind=\"enable: isOperational() && loginState.isUser() && !islocked(), click: function() { $root.sendFanSpeed() }\">" + gettext("Fan speed:") + "<span data-bind=\"text: fanSpeed() + '%'\"></span></button>\
|
||||
<button class=\"btn \" id=\"fan-lock\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.lockFanInput() }, attr: { title: lockTitle } \">\
|
||||
Fan Control Lock: <i class=\"fa fa-unlock\" data-bind=\"css: {'fa-lock': islocked(), 'fa-unlock': !islocked()}\"></i>\
|
||||
</button>\
|
||||
");
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
@ -109,6 +152,15 @@ $(function () {
|
||||
self.settings.minFanSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.minSpeed()));
|
||||
self.settings.maxFanSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.maxSpeed()));
|
||||
self.settings.notifyDelay(parseInt(self.settings.settings.plugins.fanspeedslider.notifyDelay()));
|
||||
self.settings.lockfan(self.settings.settings.plugins.fanspeedslider.lockfan());
|
||||
|
||||
if (self.settings.lockfan()) {
|
||||
self.control.lockTitle( gettext("Lock or unlock the cooling fan controls. When locked, no cooling fan commands will be sent to the printer. \n\n Fan controls are locked."));
|
||||
}
|
||||
else if (!self.settings.lockfan()) {
|
||||
self.control.lockTitle( gettext("Lock or unlock the cooling fan controls. When locked, no cooling fan commands will be sent to the printer. \n\n Fan controls are unlocked"))
|
||||
}
|
||||
self.settings.defaultLastSpeed(self.settings.settings.plugins.fanspeedslider.defaultLastSpeed());
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
@ -117,6 +169,7 @@ $(function () {
|
||||
|
||||
self.onBeforeBinding = function () {
|
||||
self.settings.defaultFanSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.defaultFanSpeed()));
|
||||
self.settings.lastSentSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.lastSentSpeed()));
|
||||
self.updateSettings();
|
||||
//if the default fan speed is above or below max/min then set to either max or min
|
||||
if (self.settings.defaultFanSpeed() < self.settings.minFanSpeed()) {
|
||||
@ -125,6 +178,9 @@ $(function () {
|
||||
else if (self.settings.defaultFanSpeed() > self.settings.maxFanSpeed()) {
|
||||
self.control.fanSpeed(self.settings.maxFanSpeed());
|
||||
}
|
||||
else if (self.settings.defaultLastSpeed()) {
|
||||
self.control.fanSpeed(self.settings.lastSentSpeed());
|
||||
}
|
||||
else {
|
||||
self.control.fanSpeed(self.settings.defaultFanSpeed());
|
||||
}
|
||||
|
@ -11,6 +11,15 @@
|
||||
<span class="help-block">{{ _('The default value the slider will be set to when opening OctoPrint\'s UI') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Remember Last Speed') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="checkbox" class="input-mini" data-bind="attr: { title: lastspeedTitle }, checked: settings.plugins.fanspeedslider.defaultLastSpeed">
|
||||
</div>
|
||||
<span class="help-block">{{ _('Instead of the default speed value, the slider will use the last sent speed as the default value') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!--<strong>{{ _('The settings below can be used to limit the fan\'s output without having to re-slice and re-upload your gcode.') }}</strong>-->
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Minimum Speed') }}</label>
|
||||
@ -33,6 +42,16 @@
|
||||
</div>
|
||||
</div>
|
||||
<p><i>{{ _('NOTE: The min/max setting has no effect when you are printing from an SD card that is attached directly to the printer as the gcode does not pass through OctoPrint.') }}</i></p>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Disable M106 / M107') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="checkbox" class="input-mini" data-bind="attr: { title: maxTitle }, checked: settings.plugins.fanspeedslider.lockfan">
|
||||
</div>
|
||||
<span class="help-block">{{ _('Disables cooling fan commands from reaching the printer. Use with caution. (This performs the same function as the padlock button in the fan section of the controls page)') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Notification Auto Hide Delay') }}</h3>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Notification Autohide Delay') }}</label>
|
||||
|
2
setup.py
2
setup.py
@ -14,7 +14,7 @@ plugin_package = "octoprint_fanspeedslider"
|
||||
plugin_name = "OctoPrint-FanSpeedSlider"
|
||||
|
||||
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
|
||||
plugin_version = "0.1.7"
|
||||
plugin_version = "0.2.1"
|
||||
|
||||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||
# module
|
||||
|
Loading…
Reference in New Issue
Block a user