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:
parent
9ff32751f8
commit
70d3e0803b
@ -29,9 +29,12 @@ $(function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//send gcode to set fan speed
|
self.control.fanSpeedToPwm = ko.pureComputed(function () {
|
||||||
self.control.sendFanSpeed = ko.pureComputed(function () {
|
|
||||||
self.speed = self.control.fanSpeed() * 255 / 100 //don't forget to limit this to 2 decimal places at some point.
|
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") {
|
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.");
|
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());
|
self.control.fanSpeed(self.control.minFanSpeed());
|
||||||
@ -48,9 +51,14 @@ $(function() {
|
|||||||
}
|
}
|
||||||
self.showNotify(self, options);
|
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
|
//ph34r
|
||||||
try {
|
try {
|
||||||
//for some reason touchui uses "jog general" for the fan controls? Oh well, makes my job easier
|
//for some reason touchui uses "jog general" for the fan controls? Oh well, makes my job easier
|
||||||
|
Loading…
Reference in New Issue
Block a user