14 Commits
0.1.6 ... 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
8 changed files with 92 additions and 34 deletions

View File

@ -12,6 +12,8 @@ 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.

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

@ -9,6 +9,10 @@ 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()
@ -18,7 +22,9 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
defaultFanSpeed=100,
minSpeed=0,
maxSpeed=100,
notifyDelay=4000
notifyDelay=4000,
lastSentSpeed=0,
defaultLastSpeed=False
)
def on_settings_save(self, data):
@ -31,6 +37,10 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
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()
@ -83,7 +93,7 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
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)
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:

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

@ -17,6 +17,15 @@ $(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.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;
@ -62,6 +71,12 @@ $(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();
}
};
//ph34r
@ -88,14 +103,10 @@ $(function () {
<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-extrusion").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: 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>\
</div>\
</div>\
");
$("#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) {
@ -107,6 +118,7 @@ $(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.defaultLastSpeed(self.settings.settings.plugins.fanspeedslider.defaultLastSpeed());
}
catch (error) {
console.log(error);
@ -115,6 +127,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()) {
@ -123,6 +136,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());
}

View File

@ -5,18 +5,27 @@
<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="attr: {title: 'This is the value the slider will default to when the UI is loaded / refreshed.' }, value: settings.plugins.fanspeedslider.defaultFanSpeed">
<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-block">{{ _('The default value the slider will be set to when opening OctoPrint\'s UI') }}</span>
</div>
</div>
<p>{{ _('The settings below can be used to limit the fan\'s output without having to re-slice and re-upload your gcode.') }}</p>
<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="value: settings.plugins.fanspeedslider.minSpeed">
<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>
@ -26,7 +35,7 @@
<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="value: settings.plugins.fanspeedslider.maxSpeed">
<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>
@ -38,7 +47,7 @@
<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: 'The plugin will notify a user when the fan speed is automatically adjusted, this only applies to speeds set via the button in the UI. \n\nFan speeds sent via the terminal (and therefore any print job) won\'t trigger notification spam.' }, value: settings.plugins.fanspeedslider.notifyDelay">
<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>

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