51 Commits
0.1.2 ... 0.1.9

Author SHA1 Message Date
9a7602b622 version increase 0.1.9 2018-12-07 04:22:43 +10:00
28edc70855 Add option to remember last fan speed
Add the option to remember the last speed value and set the slider on load/refresh
2018-12-07 03:29:09 +10:00
5dc813fb7b add init min and max pwm 2018-11-17 11:41:55 +10:00
2a779c9489 bump version to 0.1.8 2018-04-25 14:36:24 +10:00
b5693e2e34 fix regex not matching properly for low digit count values of S
see issue #9
2018-04-25 14:35:06 +10:00
55b2a05531 merge 0.1.7
update version
2017-12-02 08:03:18 +10:00
750f49e173 Merge branch 'master' into devel 2017-12-02 08:01:16 +10:00
8e547c6def add repo info 2017-12-02 07:01:47 +10:00
bba91bba88 remove dev thing from version 2017-11-18 08:24:16 +10:00
1c6e0d442e changes to the settings page
added helpful popup hints and removed the somewhat obvious line of text about limiting the fans output.
2017-11-18 08:00:16 +10:00
22ce5c7ec7 increase the div width in settings to 90% 2017-11-18 07:55:30 +10:00
ab2fa40b32 remove unnecessary css
plugin should now rely on touchUI's own css so removed my dodgy fix
2017-11-18 07:22:26 +10:00
47a3537490 move input box under touchUI + fix non functional button
move the input box over underneath the feedrate / flowrate to keep them all in the same spot and fix the stupid button not working in firefox (NFI why it didn't work, the code is literally the same it's just in a new spot. GG)
2017-11-18 07:21:29 +10:00
98d35249b0 new dev version 2017-11-18 06:55:07 +10:00
83249281cf update version 2017-11-18 06:39:33 +10:00
8f710befbe Merge pull request #5 from ntoff/devel
Devel -> master
2017-11-18 06:38:59 +10:00
d2f1ed57ad add settings cleanup function
Clean up and remove empty config if everything is set to default values
2017-11-18 06:31:22 +10:00
f13fda67e2 modify settings saving to save integers 2017-11-18 05:59:54 +10:00
59ef6652eb remove use strict
testing's over, remove "use strict"
2017-11-18 05:02:44 +10:00
c7c2f52149 add some comments
clarify fan speeds are 0-100% not 0-255 pwm values
2017-11-18 05:01:52 +10:00
943fca8581 control -> settings + tweak info timeout
for some reason I was  saving settings in the control viewmodel, changed to the settings viewmodel and increased the default time the notices are visible by 1 second
2017-11-18 04:36:40 +10:00
b359461d80 fix issue with touch ui max slider value being wrong and fix padding
if touchui was active the max value was 255, also added a bit of extra width so the button doesn't resize (at least when the button text is in english)
2017-11-18 04:18:37 +10:00
addd0ffa4b check for notifications and don't display if one is active
check for high / low speed out of range popups and only display one, block popping up of multiple notifications for the same event
2017-11-12 16:26:38 +10:00
70d3e0803b separate stuff into their own functions
move percent to pwm function and checking the slider value is within range into their own functions
2017-11-12 06:33:51 +10:00
9ff32751f8 dev version 2017-11-12 05:53:52 +10:00
3049d0fedf fix default fan speed slider position
oops, forgot the last bit of the if else statement
2017-11-12 05:19:12 +10:00
21e4627da2 missing span on touchui button + less global
hopefully nothing global "use strict" seems to not complain :D
2017-11-12 04:46:00 +10:00
a47ead4db3 tweak settings loader
parseint to make sure we're loading numbers and tweak the slider to adapt to the min/max value on UI load if the default value is outside the allowed range
2017-11-12 03:38:25 +10:00
f7faf42a87 remove unnecessary added classes
get rid of the extra classes added to make finding the buttons easier, turns out they aren't needed
2017-11-12 02:20:17 +10:00
2d7f2f443a update readme with new autohide setting 2017-11-12 01:20:17 +10:00
deb15025d8 min/max requirement notification text fix
speed decrease notification used "meet minimum requirement" which might be misleading, changed to "meet maximum requirement"
2017-11-12 01:11:36 +10:00
175722a015 fix javascript console logging of fan speed notification
log was being output after the slider was set causing it to display the wrong value
2017-11-12 01:08:27 +10:00
f4bb25718a add some notifications about fan speed being altered
Added a popup notification (can be disabled) and some console log text if the fan speed is altered. Also made the slider snap to the min/max value if it is out of range to give visual feedback that the plugin is doing something to the fan speed.
2017-11-12 01:02:29 +10:00
7bdd260617 use other view model push method
http://docs.octoprint.org/en/master/plugins/viewmodels.html#registering-custom-viewmodels says the other way is depreciated
2017-11-11 21:41:07 +10:00
0e71971e66 add percentage to logger message
add a more "human readable" percentage value to the logged fan speed (if modified)
2017-11-11 21:31:05 +10:00
99364df94e wrap it in a try catch
Hopefully when something in my plugin breaks (that's when, not if) it won't take down all of octoprint's UI.
2017-11-06 17:23:25 +10:00
56f73ad6ab increment version to 0.1.5 2017-10-12 00:59:42 +10:00
9fe9e04016 fix button while printing (touchUI)
missed that one :(
2017-10-11 23:18:34 +10:00
0772aaae3a new version again
so I guess github doesn't support a b c releases?
2017-09-25 06:48:54 +10:00
112852d619 new version 2017-09-25 06:42:48 +10:00
0462a7552e fix buttons disabled during printing
closes #3
2017-09-25 06:42:02 +10:00
43499cbe9c Update README.md
oops, forgot to edit for the limiter
2017-09-25 06:29:19 +10:00
ce10fc7e3b Merge pull request #2 from ntoff/limiter
Limiter
2017-09-25 06:24:37 +10:00
6699679ca2 update version 2017-09-25 06:22:27 +10:00
988512f522 rename default fan speed variable to be more clear 2017-09-06 17:52:23 +10:00
b03a045b24 self fanpwn 2017-09-05 22:57:53 +10:00
6124bba2e7 try rounding 2017-09-05 11:13:39 +10:00
554d78efb7 make same code into a function 2017-09-05 10:57:55 +10:00
525a08c20e update settings page help text 2017-09-05 10:56:39 +10:00
2cc132213f added some comments 2017-09-05 09:37:05 +10:00
30ee76bf7e add a limiter 2017-09-05 03:52:55 +10:00
8 changed files with 340 additions and 85 deletions

View File

@ -8,7 +8,17 @@ Add a slider to control the speed of a parts cooling fan.
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 default value setting does __NOT__ limit the output of the fan, if you set the default value to 10% and set the fan to 100% it will still come on at 100%. To limit the min/max speed of your fan during a print, please see your slicer's documentation and settings.
## Settings
* 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.
* 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.*

38
extras/fanslider.md Normal file
View File

@ -0,0 +1,38 @@
---
layout: plugin
id: fanslider
title: Fan Speed Control
description: Control your parts cooling fan
author: ntoff
license: AGPLv3
date: 2017-12-02
homepage: https://github.com/ntoff/OctoPrint-FanSpeedSlider
source: https://github.com/ntoff/OctoPrint-FanSpeedSlider
archive: https://github.com/ntoff/OctoPrint-FanSpeedSlider/archive/master.zip
tags:
- UI
- Controls
screenshots:
- url: /assets/img/plugins/fanslider/slider.JPG
alt: slider
caption: slider
- url: /assets/img/plugins/fanslider/settings.png
alt: settings
caption: settings
featuredimage: /assets/img/plugins/fanslider/slider.JPG
compatibility:
octoprint:
- 1.3.5
---
Adds a slider to the controls page for setting the speed of your parts cooling fan, and a settings page that allows limiting the fan's output power.

BIN
image/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -1,15 +1,75 @@
# coding=utf-8
from __future__ import absolute_import
from decimal import *
import re
import octoprint.plugin
class FanSliderPlugin(octoprint.plugin.StartupPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin):
def __init__(self):
self.minPWM=0,
self.maxPWM=255
def on_after_startup(self):
self.get_settings_updates()
def get_settings_defaults(self):
return dict(fanSpeed=100)
return dict(
defaultFanSpeed=100,
minSpeed=0,
maxSpeed=100,
notifyDelay=4000,
lastSentSpeed=0,
defaultLastSpeed=False
)
def on_settings_save(self, data):
s = self._settings
if "defaultFanSpeed" in data.keys():
s.setInt(["defaultFanSpeed"], data["defaultFanSpeed"])
if "minSpeed" in data.keys():
s.setInt(["minSpeed"], data["minSpeed"])
if "maxSpeed" in data.keys():
s.setInt(["maxSpeed"], data["maxSpeed"])
if "notifyDelay" in data.keys():
s.setInt(["notifyDelay"], data["notifyDelay"])
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()
s.save()
#function stolen...err borrowed :D from types.py @ 1663
def on_settings_cleanup(self):
import octoprint.util
from octoprint.settings import NoSuchSettingsPath
try:
config = self._settings.get_all_data(merged=False, incl_defaults=False, error_on_path=True)
except NoSuchSettingsPath:
return
if config is None:
self._settings.clean_all_data()
return
if self.config_version_key in config and config[self.config_version_key] is None:
del config[self.config_version_key]
defaults = self.get_settings_defaults()
diff = octoprint.util.dict_minimal_mergediff(defaults, config)
if not diff:
self._settings.clean_all_data()
else:
self._settings.set([], diff)
def get_assets(self):
return dict(
@ -20,12 +80,35 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
def get_template_configs(self):
return [
dict(type="settings", custom_bindings=False)
]
]
def get_settings_updates(self):
self.defaultFanSpeed = self._settings.getInt(["defaultFanSpeed"])
self.minSpeed = self._settings.getInt(["minSpeed"])
self.maxSpeed = self._settings.getInt(["maxSpeed"])
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 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)
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,
def get_update_information(self):
return dict(
fanspeedslider=dict(
displayName="Fan Speed Slider",
displayName="Fan Speed Control",
displayVersion=self._plugin_version,
# version check: github repository
@ -38,8 +121,15 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
pip="https://github.com/ntoff/OctoPrint-FanSpeedSlider/archive/{target_version}.zip"
)
)
__plugin_name__ = "Fan Speed Slider"
__plugin_implementation__ = FanSliderPlugin()
__plugin_hooks__ = {
__plugin_name__ = "Fan Speed Control"
def __plugin_load__():
global __plugin_implementation__
__plugin_implementation__ = __plugin_implementation__ = FanSliderPlugin()
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.comm.protocol.gcode.queuing": __plugin_implementation__.rewrite_m106,
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
}

View File

@ -1,20 +1,3 @@
#touch body #control #control-fan-slider {
padding: 30px 0 15px 15px;
width: 50%;
}
#touch body #control #control-fan-slider button, #touch body #control #control-fan-slider input {
padding: 10px 20px;
margin: 0 0 20px;
width: 100%;
min-height: 40px;
height: auto;
-ms-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
div#settings_plugin_fanspeedslider div {
width: 80%;
width: 90%;
}

View File

@ -2,64 +2,159 @@
* Author: ntoff
* License: AGPLv3
*/
$(function() {
$(function () {
function FanSliderPluginViewModel(parameters) {
//'use strict';
var self = this;
self.printerstate = parameters[0];
self.loginstate = parameters[1];
self.control = parameters[2];
self.settings = parameters[3];
self.settings = parameters[0];
self.control = parameters[1];
self.loginState = parameters[2];
//default to 100% fan speed
fanSpeed = ko.observable(undefined);
//convert percentage into PWM
fanPWM = ko.pureComputed(function () {
return Math.round(fanSpeed() * 255 / 100);
self.settings.defaultFanSpeed = new ko.observable(100); //this,
self.control.fanSpeed = new ko.observable(100); //this,
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.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.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";
if (options.delay != "0") {
new PNotify(options);
}
};
self.control.fanSpeedToPwm = ko.pureComputed(function () {
self.speed = self.control.fanSpeed() * 255 / 100 //don't forget to limit this to 2 decimal places at some point.
return self.speed;
});
//send gcode to set fan speed
sendFanSpeed = function () {
self.control.sendCustomCommand({ command: "M106 S" + fanPWM() });
};
//extra classes
$("#control > div.jog-panel").eq(0).addClass("controls");
$("#control > div.jog-panel").eq(1).addClass("tools");
$("#control > div.jog-panel").eq(2).addClass("general");
//If !TouchUI then remove standard buttons + add slider + new buttons
if ($("#touch body").length ==0 ) {
//add ID to buttons
$("#control > div.general").find("button").eq(0).attr("id", "motors-off");
$("#control > div.general").find("button").eq(1).attr("id", "fan-on");
$("#control > div.general").find("button").eq(2).attr("id", "fan-off");
//remove original fan on/off buttons
$("#fan-on").remove();
$("#fan-off").remove();
//add new fan controls
$("#control > div.jog-panel.general").find("button").eq(0).before("\
<input type=\"number\" style=\"width: 90px\" data-bind=\"slider: {min: 00, max: 100, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { sendFanSpeed() }\">" + gettext("Fan on") + ":<span data-bind=\"text: fanSpeed() + '%'\"></span></button>\
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendCustomCommand({ type: 'command', commands: ['M106 S0'] }) }\">" + gettext("Fan off") + "</button>\
");
} else { //if TouchUI is active we only add the speed input + fan on button in a new section.
console.log("Fan Speed Slider: NOTICE! TouchUI is active, adding simplified control.");
$("#control > div.jog-panel.general").after("\
<div id=\"control-fan-slider\" class=\"jog-panel filament\" data-bind=\"visible: loginState.isUser\">\
<div>\
<input type=\"number\" style=\"width: 150px\" data-bind=\"slider: {min: 00, max: 255, step: 1, value: fanSpeed, tooltip: 'hide'}\">\
<button class=\"btn btn-block control-box\" data-bind=\"enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { sendFanSpeed() }\">" + gettext("Fan Speed(%)") + "</button>\
</div>\
</div>\
");
}
//retrieve settings
self.onBeforeBinding = function() {
fanSpeed(self.settings.settings.plugins.fanspeedslider.fanSpeed());
}
}
OCTOPRINT_VIEWMODELS.push([
FanSliderPluginViewModel,
["printerStateViewModel", "loginStateViewModel", "controlViewModel", "settingsViewModel"]
]);
self.control.checkSliderValue = ko.pureComputed(function () {
if (self.control.fanSpeed() < self.settings.minFanSpeed() && self.control.fanSpeed() != "0") {
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 = {
text: gettext('Fan speed increased to meet minimum speed requirement.'),
addclass: 'fan_speed_notice_low',
}
if ($(".fan_speed_notice_low").length <1) {
self.showNotify(self, options);
}
}
else if (self.control.fanSpeed() > self.settings.maxFanSpeed()) {
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 = {
text: gettext('Fan speed decreased to meet maximum speed requirement.'),
addclass: 'fan_speed_notice_high',
}
if ($(".fan_speed_notice_high").length <1) {
self.showNotify(self, options);
}
}
});
//send gcode to set fan speed
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();
}
};
//ph34r
try {
//for some reason touchui uses "jog general" for the fan controls? Oh well, makes my job easier
$("#control-jog-general").find("button").eq(0).attr("id", "motors-off");
$("#control-jog-general").find("button").eq(1).attr("id", "fan-on");
$("#control-jog-general").find("button").eq(2).attr("id", "fan-off");
//If not TouchUI then remove standard buttons + add slider + new buttons
if ($("#touch body").length == 0) {
//remove original fan on/off buttons
$("#fan-on").remove();
$("#fan-off").remove();
//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>\
");
} else {
//replace touch UI's fan on button with one that sends whatever speed is set in this plugin
$("#fan-on").remove();
$("#control-jog-general").find("button").eq(0).after("\
<button class=\"btn btn-block control-box\" id=\"fan-on\" data-bind=\"enable: isOperational() && loginState.isUser(), click: function() { $root.sendFanSpeed() }\">" + gettext("Fan on") + "</button>\
");
//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>\
");
}
}
catch (error) {
console.log(error);
}
self.updateSettings = function () {
try {
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.defaultLastSpeed(self.settings.settings.plugins.fanspeedslider.defaultLastSpeed());
}
catch (error) {
console.log(error);
}
}
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()) {
self.control.fanSpeed(self.settings.minFanSpeed());
}
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());
}
}
//update settings in case user changes them, otherwise a refresh of the UI is required
self.onSettingsHidden = function () {
self.updateSettings();
}
}
OCTOPRINT_VIEWMODELS.push({
construct: FanSliderPluginViewModel,
additionalNames: [],
dependencies: ["settingsViewModel", "controlViewModel", "loginStateViewModel"],
optional: [],
elements: []
});
});

View File

@ -1,17 +1,56 @@
<h4>{{ _('Fan Speed Slider') }}</h4>
<div>
<p>{{ _('Set the default value for the fan speed slider.') }}</p>
</div>
<h3>{{ _('Fan Speed Control') }}</h3>
<div>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label">{{ _('Default Value') }}</label>
<div class="controls">
<div class="input-append">
<input type="number" min="0" max="100" class="input-mini" data-bind="value: settings.plugins.fanspeedslider.fanSpeed">
<input type="number" min="0" max="100" class="input-mini" data-bind="attr: { title: defaultTitle }, value: settings.plugins.fanspeedslider.defaultFanSpeed">
<span class="add-on">%</span>
</div>
<span class="help-inline">{{ _('This value does <i><b>not</b></i> affect the maximum or minimum speed of the fan. To limit the power the fan will use during a print, see your slicer\'s min / max fan speed setting.') }}</span>
<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>
<div class="controls">
<div class="input-append">
<input type="number" min="0" max="100" class="input-mini" data-bind="attr: { title: minTitle }, value: settings.plugins.fanspeedslider.minSpeed">
<span class="add-on">%</span>
</div>
<span class="help-block">{{ _('Any value sent which is below this value will be increased to meet this speed. Useful if your fan doesn\'t work below a certain threshold.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Maximum Speed') }}</label>
<div class="controls">
<div class="input-append">
<input type="number" min="0" max="100" class="input-mini" data-bind="attr: { title: maxTitle }, value: settings.plugins.fanspeedslider.maxSpeed">
<span class="add-on">%</span>
</div>
<span class="help-block">{{ _('Any value sent which is above this value will be decreased to meet this speed. Useful if your fan is too strong on full speed.') }}</span>
</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>
<h3>{{ _('Notification Auto Hide Delay') }}</h3>
<div class="control-group">
<label class="control-label">{{ _('Notification Autohide Delay') }}</label>
<div class="controls">
<div class="input-append">
<input type="number" min="0" class="input-mini" data-bind="attr: {title: noticeTitle }, value: settings.plugins.fanspeedslider.notifyDelay">
<span class="add-on">ms</span>
</div>
<span class="help-block">{{ _('Delay (in milliseconds) before notifications are auto-hidden. Set to 0 to disable notifications.') }}</span>
</div>
</div>
</form>

View File

@ -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.2"
plugin_version = "0.1.9"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module