From 2cc132213f4471faead65fd76e282f29a3712e34 Mon Sep 17 00:00:00 2001 From: ntoff Date: Tue, 5 Sep 2017 09:37:05 +1000 Subject: [PATCH] added some comments --- octoprint_fanspeedslider/__init__.py | 5 +++-- octoprint_fanspeedslider/static/js/fanslider.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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; });