From 0b095ddf473cbe22e559b20be4a3dbbc7669045f Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 27 Feb 2019 14:24:17 -0500 Subject: [PATCH] temperature_fan: Wrap code to 80 columns Signed-off-by: Kevin O'Connor --- klippy/extras/temperature_fan.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/klippy/extras/temperature_fan.py b/klippy/extras/temperature_fan.py index b9b1a990..f699e4fb 100644 --- a/klippy/extras/temperature_fan.py +++ b/klippy/extras/temperature_fan.py @@ -27,8 +27,9 @@ class TemperatureFan: self.min_speed = config.getfloat('min_speed', 0.3, above=0., maxval=1.) self.last_temp = 0. self.last_temp_time = 0. - self.target_temp = config.getfloat('target_temp', 40. if self.max_temp > 40. else self.max_temp, - minval=self.min_temp, maxval=self.max_temp) + self.target_temp = config.getfloat( + 'target_temp', 40. if self.max_temp > 40. else self.max_temp, + minval=self.min_temp, maxval=self.max_temp) algos = {'watermark': ControlBangBang, 'pid': ControlPID} algo = config.getchoice('control', algos) self.control = algo(self, config) @@ -63,14 +64,17 @@ class ControlBangBang: self.max_delta = config.getfloat('max_delta', 2.0, above=0.) self.heating = False def temperature_callback(self, read_time, temp): - if self.heating and temp >= self.temperature_fan.target_temp+self.max_delta: + if (self.heating + and temp >= self.temperature_fan.target_temp+self.max_delta): self.heating = False - elif not self.heating and temp <= self.temperature_fan.target_temp-self.max_delta: + elif (not self.heating + and temp <= self.temperature_fan.target_temp-self.max_delta): self.heating = True if self.heating: self.temperature_fan.set_speed(read_time, 0.) else: - self.temperature_fan.set_speed(read_time, self.temperature_fan.max_speed) + self.temperature_fan.set_speed(read_time, + self.temperature_fan.max_speed) ###################################################################### # Proportional Integral Derivative (PID) control algo @@ -86,7 +90,8 @@ class ControlPID: self.Ki = config.getfloat('pid_Ki') / PID_PARAM_BASE self.Kd = config.getfloat('pid_Kd') / PID_PARAM_BASE self.min_deriv_time = config.getfloat('pid_deriv_time', 2., above=0.) - imax = config.getfloat('pid_integral_max', temperature_fan.max_speed, minval=0.) + imax = config.getfloat('pid_integral_max', temperature_fan.max_speed, + minval=0.) self.temp_integ_max = imax / self.Ki self.prev_temp = AMBIENT_TEMP self.prev_temp_time = 0. @@ -108,7 +113,8 @@ class ControlPID: # Calculate output co = self.Kp*temp_err + self.Ki*temp_integ - self.Kd*temp_deriv bounded_co = max(0., min(self.temperature_fan.max_speed, co)) - self.temperature_fan.set_speed(read_time, self.temperature_fan.max_speed - bounded_co) + self.temperature_fan.set_speed( + read_time, self.temperature_fan.max_speed - bounded_co) # Store state for next measurement self.prev_temp = temp self.prev_temp_time = read_time