# HG changeset patch # User drewp@bigasterisk.com # Date 1322967787 28800 # Node ID d6c2b9b87f7b7ab57b7c704893446737c0bad6cb # Parent 3a429f6cc9dc484f360f35063ff783b0c8d81ba1 yard light toggle button Ignore-this: c003731daf656c377440278527522d75 diff -r 3a429f6cc9dc -r d6c2b9b87f7b service/frontDoorArduino/frontDoorArduino.py --- a/service/frontDoorArduino/frontDoorArduino.py Sat Dec 03 19:01:18 2011 -0800 +++ b/service/frontDoorArduino/frontDoorArduino.py Sat Dec 03 19:03:07 2011 -0800 @@ -6,6 +6,9 @@ |-------------------| 22:05 85F in, 71F out +pin 11 senses the door +pin 12 activates the front yard lights ('out yard') + """ from __future__ import division @@ -29,10 +32,9 @@ self.ser = LoggingSerial(port=port) self.ser.flush() - self.ser.write("\xff\x00\x00") - self.ser.write("\xff\x03\x00") - self.currentText = "" - self.currentBrightness = 0 + self.setLcd("") + self.setLcdBrightness(0) + self.setYardLight(0) def ping(self): self.getDoor() @@ -42,6 +44,13 @@ ret = self.ser.readJson() return ret['door'] + def setYardLight(self, level): + self.currentYardLight = bool(level) + self.ser.write("\xff\x04" + chr(bool(self.currentYardLight))) + + def getYardLight(self): + return self.currentYardLight + def getLcd(self): return self.currentText @@ -101,6 +110,21 @@ self.write("ok") post = put + +class YardLight(PrettyErrorHandler, cyclone.web.RequestHandler): + def get(self): + self.set_header("Content-Type", "application/json") + self.write(json.dumps({ + "yardLight" : self.settings.board.getYardLight()})) + + def put(self): + """text true or false or 0 or 1""" + self.settings.board.setYardLight( + self.request.body.strip() in ['true', '1']) + self.write("ok") + post = put + + class Door(PrettyErrorHandler, cyclone.web.RequestHandler): def get(self): self.set_header("Content-Type", "text/plain") @@ -120,6 +144,7 @@ (r'/door', Door), (r'/temperature', Temperature), (r'/lcd/backlight', Backlight), + (r'/yardLight', YardLight), ] settings = {"board" : board} cyclone.web.Application.__init__(self, handlers, **settings) @@ -169,7 +194,7 @@ # todo: need options to preset inputs/outputs at startup } - log.startLogging(sys.stdout) + #log.startLogging(sys.stdout) board = Board(port=config['arduinoPort']) diff -r 3a429f6cc9dc -r d6c2b9b87f7b service/frontDoorArduino/index.html --- a/service/frontDoorArduino/index.html Sat Dec 03 19:01:18 2011 -0800 +++ b/service/frontDoorArduino/index.html Sat Dec 03 19:03:07 2011 -0800 @@ -15,8 +15,8 @@ background: none repeat scroll 0 0 #E1E1DF; border: 1px solid #595555; float: left; - margin: 20px; - padding: 20px; + margin: 5px; + padding: 10px; } /* ]]> */ @@ -48,6 +48,13 @@ +
+

yard light

+
Current: + +
+
+