Compare commits

..

No commits in common. "master" and "commandlocktest" have entirely different histories.

5 changed files with 5 additions and 38 deletions

View File

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

View File

@ -12,8 +12,7 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
def __init__(self): def __init__(self):
self.minPWM=0, self.minPWM=0,
self.maxPWM=255, self.maxPWM=255
self.lockfan=False
def on_after_startup(self): def on_after_startup(self):
self.get_settings_updates() self.get_settings_updates()
@ -24,9 +23,7 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
minSpeed=0, minSpeed=0,
maxSpeed=100, maxSpeed=100,
notifyDelay=4000, notifyDelay=4000,
lockfan=False, lockfan=False
lastSentSpeed=0,
defaultLastSpeed=False
) )
def on_settings_save(self, data): def on_settings_save(self, data):
@ -41,10 +38,6 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
s.setInt(["notifyDelay"], data["notifyDelay"]) s.setInt(["notifyDelay"], data["notifyDelay"])
if "lockfan" in data.keys(): if "lockfan" in data.keys():
s.set(["lockfan"], data["lockfan"]) 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() self.get_settings_updates()
#clean up settings if everything's default #clean up settings if everything's default
self.on_settings_cleanup() self.on_settings_cleanup()
@ -109,7 +102,7 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
self._logger.info("fan pwm value " + str(fanPwm) + " is above threshold, decreasing to " + str(self.maxPWM) + " (" + str(self.maxSpeed) + "%)") 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) cmd = "M106 S" + str(self.maxPWM)
return cmd, return cmd,
elif gcode and gcode.startswith(('M106', 'M107')) and self.lockfan: elif self.lockfan and gcode and gcode.startswith(('M106', 'M107')):
self._logger.info("A cooling fan control command was seen, but fanspeedslider is locked. Control command " + str(cmd) + " removed from queue.") self._logger.info("A cooling fan control command was seen, but fanspeedslider is locked. Control command " + str(cmd) + " removed from queue.")
return None, return None,
@ -131,7 +124,6 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
) )
__plugin_name__ = "Fan Speed Control" __plugin_name__ = "Fan Speed Control"
__plugin_pythoncompat__ = ">=2.7,<4"
def __plugin_load__(): def __plugin_load__():
global __plugin_implementation__ global __plugin_implementation__

View File

@ -18,8 +18,6 @@ $(function () {
self.settings.maxFanSpeed = new ko.observable(100); //and this are percents 0 - 100% 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.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.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 self.control.lockTitle = new ko.observable(gettext("Unlocked")); //will set the hover title info for the fan lock button
@ -29,8 +27,7 @@ $(function () {
self.settings.minTitle = ko.observable(gettext("Set this to the lowest value at which your fan will spin.") + self.settings.commonTitle()); 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.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.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) { self.showNotify = function (self, options) {
options.title = "Fan Speed Control"; options.title = "Fan Speed Control";
options.delay = options.delay || self.settings.notifyDelay(); options.delay = options.delay || self.settings.notifyDelay();
@ -76,12 +73,6 @@ $(function () {
self.control.sendFanSpeed = function () { self.control.sendFanSpeed = function () {
self.control.checkSliderValue(); self.control.checkSliderValue();
self.control.sendCustomCommand({ command: "M106 S" + self.control.fanSpeedToPwm() }); 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.control.lockFanInput = function () {
@ -160,7 +151,6 @@ $(function () {
else if (!self.settings.lockfan()) { 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.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) { catch (error) {
console.log(error); console.log(error);
@ -169,7 +159,6 @@ $(function () {
self.onBeforeBinding = function () { self.onBeforeBinding = function () {
self.settings.defaultFanSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.defaultFanSpeed())); self.settings.defaultFanSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.defaultFanSpeed()));
self.settings.lastSentSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.lastSentSpeed()));
self.updateSettings(); self.updateSettings();
//if the default fan speed is above or below max/min then set to either max or min //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()) { if (self.settings.defaultFanSpeed() < self.settings.minFanSpeed()) {
@ -178,9 +167,6 @@ $(function () {
else if (self.settings.defaultFanSpeed() > self.settings.maxFanSpeed()) { else if (self.settings.defaultFanSpeed() > self.settings.maxFanSpeed()) {
self.control.fanSpeed(self.settings.maxFanSpeed()); self.control.fanSpeed(self.settings.maxFanSpeed());
} }
else if (self.settings.defaultLastSpeed()) {
self.control.fanSpeed(self.settings.lastSentSpeed());
}
else { else {
self.control.fanSpeed(self.settings.defaultFanSpeed()); self.control.fanSpeed(self.settings.defaultFanSpeed());
} }

View File

@ -11,15 +11,6 @@
<span class="help-block">{{ _('The default value the slider will be set to when opening OctoPrint\'s UI') }}</span> <span class="help-block">{{ _('The default value the slider will be set to when opening OctoPrint\'s UI') }}</span>
</div> </div>
</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>--> <!--<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"> <div class="control-group">
<label class="control-label">{{ _('Minimum Speed') }}</label> <label class="control-label">{{ _('Minimum Speed') }}</label>

View File

@ -14,7 +14,7 @@ plugin_package = "octoprint_fanspeedslider"
plugin_name = "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 # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.2.1" plugin_version = "0.1.8"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module # module