of the N temps readings every duty cycle, 2s by default, strip the top 25 percent and bottom 25 percent from those readings, use the rest to get the average temp over the cycle.
This commit is contained in:
parent
165a8b16dd
commit
874557fd1e
14
lib/oven.py
14
lib/oven.py
@ -158,9 +158,21 @@ class TempSensorReal(TempSensor):
|
||||
self.bad_count += 1
|
||||
|
||||
if len(temps):
|
||||
self.temperature = sum(temps) / len(temps)
|
||||
self.temperature = self.get_avg_temp(temps)
|
||||
time.sleep(self.sleeptime)
|
||||
|
||||
def get_avg_temp(self, temps, chop=25):
|
||||
'''
|
||||
strip off chop percent from the beginning and end of the sorted temps
|
||||
then return the average of what is left
|
||||
'''
|
||||
chop = chop / 100
|
||||
temps = sorted(temps)
|
||||
total = len(temps)
|
||||
items = int(total*chop)
|
||||
temps = temps[items:total-items]
|
||||
return sum(temps) / len(temps)
|
||||
|
||||
class Oven(threading.Thread):
|
||||
'''parent oven class. this has all the common code
|
||||
for either a real or simulated oven'''
|
||||
|
||||
Loading…
Reference in New Issue
Block a user