Merge from master
This commit is contained in:
commit
a6d224be14
@ -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.
|
||||
|
@ -24,6 +24,8 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
|
||||
maxSpeed=100,
|
||||
notifyDelay=4000,
|
||||
lockfan=False
|
||||
lastSentSpeed=0,
|
||||
defaultLastSpeed=False
|
||||
)
|
||||
|
||||
def on_settings_save(self, data):
|
||||
@ -38,6 +40,10 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin,
|
||||
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()
|
||||
|
@ -18,6 +18,8 @@ $(function () {
|
||||
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
|
||||
|
||||
@ -27,7 +29,8 @@ $(function () {
|
||||
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.title = "Fan Speed Control";
|
||||
options.delay = options.delay || self.settings.notifyDelay();
|
||||
@ -73,6 +76,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();
|
||||
}
|
||||
};
|
||||
|
||||
self.control.lockFanInput = function () {
|
||||
@ -151,6 +160,7 @@ $(function () {
|
||||
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);
|
||||
@ -159,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()) {
|
||||
@ -167,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>
|
||||
|
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.8"
|
||||
plugin_version = "0.1.9"
|
||||
|
||||
# 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