annotate service/theaterArduino/theaterArduino.py @ 1259:672a3d830e7f

arduinoNode: build updates, stats support, etc Ignore-this: 39386eb7644e3cf522e0f72a874eadba darcs-hash:b6fa9fbda226917dd3b94d8a87556c4cd6d51180
author drewp <drewp@bigasterisk.com>
date Sat, 20 Apr 2019 23:28:29 -0700
parents 0aafd40e4afc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
809
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
1 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
2 arduino example sketches, 'StandardFirmata'.
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
3
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
4 ####easy_install http://github.com/lupeke/python-firmata/tarball/master
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
5
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
6 Now using http://code.google.com/p/pyduino, modified to run at 57600
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
7 baud like my arduino's code does. pyduino is better than the lupeke
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
8 one in that you can read your settings off the output pins
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
10 Note that there are some startup delays and you may not hear about
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11 input changes for a few seconds.
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
12 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
13 from __future__ import division
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
14 import sys, cyclone.web, time, simplejson, os
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
15 from twisted.web.client import getPage
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16 from twisted.internet import reactor, task
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
17
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
18 sys.path.append("/my/proj/homeauto/lib")
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
19 from cycloneerr import PrettyErrorHandler
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
20 from logsetup import log
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
21
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
22 sys.path.append("pyduino-read-only")
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
23 import pyduino
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
24
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
25 def _num(name):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
26 if name.startswith('d'):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
27 return int(name[1:])
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
28 raise ValueError(name)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
29
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
30 class pin(PrettyErrorHandler, cyclone.web.RequestHandler):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
31 def get(self, name):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
32 self.set_header("Content-Type", "text/plain")
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
33 arduino = self.settings.arduino
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
34 arduino.iterate()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
35 self.write(str(int(arduino.digital[_num(name)].read())))
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
36
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
37 def put(self, name):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
38 t1 = time.time()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
39 self.settings.arduino.digital[_num(name)].write(int(self.request.body))
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
40 log.debug("arduino write in %.1f ms" % (1000 * (time.time() - t1)))
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
41
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
42
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
43 class pinMode(PrettyErrorHandler, cyclone.web.RequestHandler):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
44 def get(self, name):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
45 self.set_header("Content-Type", "text/plain")
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
46 mode = self.settings.arduino.digital[_num(name)].get_mode()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
47 self.write({pyduino.DIGITAL_INPUT : "input",
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
48 pyduino.DIGITAL_OUTPUT : "output"}[mode])
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
49
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
50 def put(self, name):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
51 mode = {
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
52 "input" : pyduino.DIGITAL_INPUT,
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
53 "output" : pyduino.DIGITAL_OUTPUT}[self.request.body.strip()]
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
54 self.settings.arduino.digital[_num(name)].set_mode(mode)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
55
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
56 class Pid(PrettyErrorHandler, cyclone.web.RequestHandler):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
57 def get(self):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
58 self.set_header("Content-Type", "text/plain")
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
59 self.write(str(os.getpid()))
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
60
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
61 class index(PrettyErrorHandler, cyclone.web.RequestHandler):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
62 def get(self):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
63 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
64 this is a suitable status check; it does a round-trip to arduino
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
65 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
66 # this would be a good ping() call for pyduino
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
67 self.settings.arduino.sp.write(chr(pyduino.REPORT_VERSION))
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
68 self.settings.arduino.iterate()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
69
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
70 self.set_header("Content-Type", "application/xhtml+xml")
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
71 self.write(open('index.html').read())
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
72
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
73 class Application(cyclone.web.Application):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
74 def __init__(self, arduino):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
75 handlers = [
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
76 (r"/", index),
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
77 (r'/pin/(.*)/mode', pinMode),
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
78 (r'/pin/(.*)', pin),
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
79 (r'/pid', Pid),
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
80 # web refresh could benefit a lot from a json resource that
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
81 # gives all the state
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
82 ]
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
83 settings = {"arduino" : arduino,}
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
84 cyclone.web.Application.__init__(self, handlers, **settings)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
85
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
86 class WatchPins(object):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
87 def __init__(self, arduino, conf):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
88 self.arduino, self.conf = arduino, conf
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
89 self.lastState = {}
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
90 self.pins = conf['watchPins']
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
91 if self.pins == 'allInput':
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
92 self.watchAllInputs()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
93 for pin in self.pins:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
94 arduino.digital_ports[pin >> 3].set_active(1)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
95 arduino.digital[pin].set_mode(pyduino.DIGITAL_INPUT)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
96
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
97 def watchAllInputs(self):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
98 raise NotImplementedError("this needs to be updated whenever the modes change")
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
99 self.pins = [p for p in range(2, 13+1) if
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
100 self.arduino.digital[p].get_mode() ==
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
101 pyduino.DIGITAL_INPUT]
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
102
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
103 def reportPostError(self, fail, pin, value, url):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
104 log.error("failed to send pin %s update (now %s) to %r: %r" % (pin, value, url, fail))
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
105
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
106 def poll(self):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
107 try:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
108 self._poll()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
109 except Exception, e:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
110 log.error("during poll:", exc_info=1)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
111
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
112 def _poll(self):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
113 # this can IndexError for a port number being out of
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
114 # range. I'm not sure how- maybe error data coming in the
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
115 # port?
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
116 arduino.iterate()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
117 for pin in self.pins:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
118 current = arduino.digital[pin].read()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
119 if current != self.lastState.get(pin, None):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
120 d = getPage(
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
121 self.conf['post'],
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
122 method="POST",
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
123 postdata=simplejson.dumps(dict(board=self.conf['boardName'], pin=pin, level=int(current))),
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
124 headers={'Content-Type' : 'application/json'})
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
125 d.addErrback(self.reportPostError, pin, current, self.conf['post'])
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
126
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
127 self.lastState[pin] = current
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
128
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
129 if __name__ == '__main__':
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
130
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
131 config = { # to be read from a file
823
0aafd40e4afc move more ports to use /dev/serial/by-id/
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
132 'arduinoPort': '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900cepU-if00-port0',
809
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
133 'servePort' : 9056,
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
134 'pollFrequency' : 20,
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
135 'post' : 'http://bang:9069/pinChange',
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
136 'boardName' : 'theater', # gets sent with updates
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
137 'watchPins' : [9, 10], # or 'allInput' (not yet working)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
138 # todo: need options to preset inputs/outputs at startup
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
139 }
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
140
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
141 arduino = pyduino.Arduino(config['arduinoPort'])
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
142 wp = WatchPins(arduino, config)
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
143 task.LoopingCall(wp.poll).start(1/config['pollFrequency'])
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
144 reactor.listenTCP(config['servePort'], Application(arduino))
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
145 reactor.run()