separate stuff into their own functions

move percent to pwm function and checking the slider value is within range into their own functions
This commit is contained in:
ntoff 2017-11-12 06:33:51 +10:00
parent 9ff32751f8
commit 70d3e0803b

View File

@ -29,9 +29,12 @@ $(function() {
}
};
//send gcode to set fan speed
self.control.sendFanSpeed = ko.pureComputed(function () {
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;
});
self.control.checkSliderValue = ko.pureComputed(function () {
if (self.control.fanSpeed() < self.control.minFanSpeed() && self.control.fanSpeed() != "0") {
console.log("Fan Speed Control Plugin: " + self.control.fanSpeed() + "% is less than the minimum speed (" + self.control.minFanSpeed() + "%), increasing.");
self.control.fanSpeed(self.control.minFanSpeed());
@ -48,9 +51,14 @@ $(function() {
}
self.showNotify(self, options);
}
self.control.sendCustomCommand({ command: "M106 S" + self.speed });
});
//send gcode to set fan speed
self.control.sendFanSpeed = function () {
self.control.checkSliderValue();
self.control.sendCustomCommand({ command: "M106 S" + self.control.fanSpeedToPwm() });
};
//ph34r
try {
//for some reason touchui uses "jog general" for the fan controls? Oh well, makes my job easier