diff --git a/octoprint_fanspeedslider/__init__.py b/octoprint_fanspeedslider/__init__.py index 2b6be64..4f836ee 100644 --- a/octoprint_fanspeedslider/__init__.py +++ b/octoprint_fanspeedslider/__init__.py @@ -43,8 +43,9 @@ class FanSliderPlugin(octoprint.plugin.StartupPlugin, def rewrite_m106(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs): if gcode and gcode.startswith('M106'): getcontext().prec = 5 #sets precision for "Decimal" not sure if this'll cause conflicts, ideas? - self.minPWM = Decimal( Decimal(self.minSpeed) * Decimal(255) / Decimal(100) ) - self.maxPWM = Decimal( Decimal(self.maxSpeed) * Decimal(255) / Decimal(100) ) + self.minPWM = Decimal( Decimal(self.minSpeed) * Decimal(255) / Decimal(100) ) #convoluted mess, could this be reduced to a function + self.maxPWM = Decimal( Decimal(self.maxSpeed) * Decimal(255) / Decimal(100) ) #so basically the same thing isn't written twice? + #Also move it out of here so it doesn't get calculated every single time the speed is rewritten fanPwm = re.search("S(\d+.\d+)", cmd) if fanPwm and fanPwm.group(1): fanPwm = fanPwm.group(1) diff --git a/octoprint_fanspeedslider/static/js/fanslider.js b/octoprint_fanspeedslider/static/js/fanslider.js index 1a431f1..a72f340 100644 --- a/octoprint_fanspeedslider/static/js/fanslider.js +++ b/octoprint_fanspeedslider/static/js/fanslider.js @@ -16,7 +16,7 @@ $(function() { //convert percentage into PWM fanPWM = ko.pureComputed(function () { - self.speed = fanSpeed() * 255 / 100 + self.speed = fanSpeed() * 255 / 100 //don't forget to limit this to 2 decimal places at some point. return self.speed; });