Mercurial > code > home > repos > homeauto
comparison service/bedroomArduino/bedroomArduino.py @ 922:e4069a2cfcc8
bedroomarduino updates
Ignore-this: eeb3e527e652601b04ddd1d18f0f15f3
darcs-hash:20130922073020-312f9-13483a3790ad5fbbe75ad2345760993f4c5c1b92
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 22 Sep 2013 00:30:20 -0700 |
parents | 1f69e77411ba |
children |
comparison
equal
deleted
inserted
replaced
921:22c29940a67f | 922:e4069a2cfcc8 |
---|---|
67 to the arduino before returning success | 67 to the arduino before returning success |
68 """ | 68 """ |
69 self.settings.arduino.ping() | 69 self.settings.arduino.ping() |
70 | 70 |
71 self.set_header("Content-Type", "application/xhtml+xml") | 71 self.set_header("Content-Type", "application/xhtml+xml") |
72 self.write(open("index.html").read()) | 72 self.write(open("index.xhtml").read()) |
73 | 73 |
74 class SpeakerChoice(PrettyErrorHandler, cyclone.web.RequestHandler): | 74 class SpeakerChoice(PrettyErrorHandler, cyclone.web.RequestHandler): |
75 def put(self): | 75 def put(self): |
76 ret = self.settings.arduino.setSpeakerChoice(int(self.get_argument('pillow'))) | 76 ret = self.settings.arduino.setSpeakerChoice(int(self.get_argument('pillow'))) |
77 self.write(ret) | 77 self.write(ret) |
78 | 78 |
79 class Brite(PrettyErrorHandler, cyclone.web.RequestHandler): | 79 class Brite(PrettyErrorHandler, cyclone.web.RequestHandler): |
80 def get(self, which): | |
81 self.set_header("Content-Type", "text/plain") | |
82 self.write(hexFromRgb(self.settings.brites[int(which)])) | |
83 | |
80 def put(self, which): | 84 def put(self, which): |
81 which = int(which) | 85 which = int(which) |
82 brites = self.settings.brites | 86 brites = self.settings.brites |
83 if which + 1 > len(brites): | 87 if which + 1 > len(brites): |
84 brites.extend([(0,0,0)] * (which + 1 - len(brites))) | 88 brites.extend([(0,0,0)] * (which + 1 - len(brites))) |
164 | 168 |
165 log.setLevel(logging.DEBUG) | 169 log.setLevel(logging.DEBUG) |
166 | 170 |
167 ard = ArduinoBedroom(port=config['arduinoPort']) | 171 ard = ArduinoBedroom(port=config['arduinoPort']) |
168 | 172 |
169 period = 1/config['pollFrequency'] | 173 period = 1 / config['pollFrequency'] |
170 p = Poller(config, ard, period) | 174 p = Poller(config, ard, period) |
171 task.LoopingCall(p.poll).start(period) | 175 task.LoopingCall(p.poll).start(period) |
172 | 176 |
173 reactor.listenTCP(config['servePort'], cyclone.web.Application([ | 177 reactor.listenTCP(config['servePort'], cyclone.web.Application([ |
174 (r"/", Index), | 178 (r"/", Index), |