Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

prevent beersicle. #6

  • Loading branch information...
commit f4f1a88dc64d136f0f294d653d5d328faed01e4f 1 parent c875a3a
Eric Stein authored

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. +11 2 chillmon
13 chillmon
@@ -21,11 +21,14 @@ def mean(l, default=0) :
21 21 except :
22 22 return default
23 23
  24 +def beersafe(v) :
  25 + return min(110.0, max(38.0, v))
  26 +
24 27 class PID(object) :
25 28 def __init__(self, temp_probe, target) :
26 29 self.temp_probe = temp_probe
27 30 self.samples = []
28   - self.target = target
  31 + self.target = beersafe(target)
29 32 GPIO.setup(CHILLPIN, GPIO.OUT)
30 33
31 34 self.pid_ts = None
@@ -189,7 +192,13 @@ fIError
189 192 if cmd == 'set' :
190 193 k = v['k']
191 194 val = pidvarmap.typemap[k](v['v'])
192   - setattr(self.pid, k, val)
  195 + try :
  196 + if k == 'target' :
  197 + val = beersafe(val)
  198 + setattr(self.pid, k, val)
  199 + except Exception, e :
  200 + print 'set error', e
  201 + pass
193 202 else :
194 203 print 'ERR: unknown command %s' % cmd
195 204 except KeyError, ke :

0 comments on commit f4f1a88

Please sign in to comment.
Something went wrong with that request. Please try again.