annotate service/tinyScreen/tiny_screen.py @ 1745:d90cb7c06f15

try to crash if mqtt doesn't connect
author drewp@bigasterisk.com
date Thu, 09 Nov 2023 17:21:59 -0800
parents b87b6e9cedb2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
1 from docopt import docopt
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
2 from patchablegraph import PatchableGraph, CycloneGraphHandler, CycloneGraphEventsHandler
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
3 from rdflib import Namespace, URIRef, Literal, Graph
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
4 from rdflib.parser import StringInputSource
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
5 from twisted.internet import reactor
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
6 import cyclone.web
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
7 import sys, logging, time, textwrap
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
8
384
5cdc6e85265f start tiny_screen
drewp@bigasterisk.com
parents:
diff changeset
9 from luma.core.interface.serial import spi
5cdc6e85265f start tiny_screen
drewp@bigasterisk.com
parents:
diff changeset
10 from luma.oled.device import ssd1331
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
11 from PIL import Image, ImageFont, ImageDraw
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
12 ROOM = Namespace('http://projects.bigasterisk.com/room/')
384
5cdc6e85265f start tiny_screen
drewp@bigasterisk.com
parents:
diff changeset
13
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
14 logging.basicConfig()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
15 log = logging.getLogger()
384
5cdc6e85265f start tiny_screen
drewp@bigasterisk.com
parents:
diff changeset
16
5cdc6e85265f start tiny_screen
drewp@bigasterisk.com
parents:
diff changeset
17 class Screen(object):
5cdc6e85265f start tiny_screen
drewp@bigasterisk.com
parents:
diff changeset
18 def __init__(self, spiDevice=1, rotation=0):
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
19 self._initOutput(spiDevice, rotation)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
20 self.news = ""
393
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
21 self.goalState = None
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
22 self.animateTo(ROOM['boot'])
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
23
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
24 def _stateImage(self, state):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
25 return Image.open('anim/%s.png' % state.rsplit('/')[-1])
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
26
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
27 def _initOutput(self, spiDevice, rotation):
459
a471688fb7b7 build updates. turn off output speed override for now
drewp@bigasterisk.com
parents: 393
diff changeset
28 # CS on pin 26 (GPIO7; spi0 ce1), DC on pin 18 (GPIO24), RST held at VCC.
393
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
29 self._dev = ssd1331(spi(device=spiDevice, port=0,
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
30 # lots of timeouts on the 12288-byte transfer without this
459
a471688fb7b7 build updates. turn off output speed override for now
drewp@bigasterisk.com
parents: 393
diff changeset
31 #transfer_size=64,
a471688fb7b7 build updates. turn off output speed override for now
drewp@bigasterisk.com
parents: 393
diff changeset
32 #bus_speed_hz=16000000,
a471688fb7b7 build updates. turn off output speed override for now
drewp@bigasterisk.com
parents: 393
diff changeset
33 gpio_RST=None,
a471688fb7b7 build updates. turn off output speed override for now
drewp@bigasterisk.com
parents: 393
diff changeset
34 gpio_DC=24,
a471688fb7b7 build updates. turn off output speed override for now
drewp@bigasterisk.com
parents: 393
diff changeset
35 ),
393
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
36 rotation=rotation)
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
37
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
38 def setContrast(self, contrast):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
39 """0..255"""
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
40 self._dev.contrast(contrast)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
41
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
42 def hide(self):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
43 """Switches the display mode OFF, putting the device in low-power sleep mode."""
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
44 self._dev.hide()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
45
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
46 def show(self):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
47 self._dev.show()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
48
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
49 def display(self, img):
393
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
50 self._dev.display(img.convert(self._dev.mode))
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
51
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
52 def animateTo(self, state):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
53 """
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
54 boot
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
55 sleep
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
56 locked
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
57 lockedUnknownKey
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
58 unlockNews
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
59 """
393
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
60 if self.goalState == state:
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
61 return
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
62 self.goalState = state
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
63 self.display(self._stateImage(state))
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
64 if state == ROOM['unlockNews']:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
65 self.renderNews()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
66
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
67 def setNews(self, text):
393
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
68 if self.news == text:
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
69 return
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
70 self.news = text
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
71 if self.goalState == ROOM['unlockNews']:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
72 # wrong during animation
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
73 self.renderNews()
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
74
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
75 def renderNews(self):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
76 bg = self._stateImage(ROOM['unlockNews'])
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
77 draw = ImageDraw.Draw(bg)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
78
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
79 font = ImageFont.truetype("font/Oswald-SemiBold.ttf", 12)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
80 #w, h = font.getsize('txt')
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
81 for i, line in enumerate(
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
82 textwrap.fill(self.news, width=12).splitlines()):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
83 draw.text((24, 0 + 10 * i), line, font=font)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
84 self.display(bg)
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
85
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
86 class ScreenSim(Screen):
393
5fc79536885a fix screen timing corruption, hopefully. add py client
drewp@bigasterisk.com
parents: 388
diff changeset
87 def _initOutput(self):
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
88 self.windowScale = 2
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
89 import pygame
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
90 self.pygame = pygame
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
91 pygame.init()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
92 self.surf = pygame.display.set_mode(
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
93 (96 * self.windowScale, 64 * self.windowScale))
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
94 time.sleep(.05) # something was causing the 1st update not to show
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
95
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
96 def display(self, img):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
97 pgi = self.pygame.image.fromstring(
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
98 img.tobytes(), img.size, img.mode)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
99 self.pygame.transform.scale(pgi, self.surf.get_size(), self.surf)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
100 self.pygame.display.flip()
384
5cdc6e85265f start tiny_screen
drewp@bigasterisk.com
parents:
diff changeset
101
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
102 def rdfGraphBody(body, headers):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
103 g = Graph()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
104 g.parse(StringInputSource(body), format='nt')
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
105 return g
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
106
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
107 class OutputPage(cyclone.web.RequestHandler):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
108 def put(self):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
109 arg = self.request.arguments
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
110 if arg.get('s') and arg.get('p'):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
111 subj = URIRef(arg['s'][-1])
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
112 pred = URIRef(arg['p'][-1])
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
113 turtleLiteral = self.request.body
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
114 try:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
115 obj = Literal(float(turtleLiteral))
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
116 except ValueError:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
117 obj = Literal(turtleLiteral)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
118 stmts = [(subj, pred, obj)]
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
119 else:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
120 nt = self.request.body.replace("\\n", "\n") # wrong, but i can't quote right in curl
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
121 g = rdfGraphBody(nt, self.request.headers)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
122 assert len(g)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
123 stmts = list(g.triples((None, None, None)))
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
124 self._onStatement(stmts)
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
125
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
126 def _onStatement(self, stmts):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
127 """
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
128 (disp :brightness 1.0 . )
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
129 (disp :state :locked . )
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
130 (disp :state :sleep . )
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
131 (disp :state :readKeyUnlock . disp :news "some news text" . )
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
132 """
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
133 disp = ROOM['frontDoorOled']
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
134 for stmt in stmts:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
135 if stmt[:2] == (disp, ROOM['news']):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
136 self.settings.screen.setNews(stmt[2].toPython())
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
137 elif stmt[:2] == (disp, ROOM['state']):
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
138 self.settings.screen.animateTo(stmt[2])
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
139 else:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
140 log.warn("ignoring %s", stmt)
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
141
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
142 if __name__ == '__main__':
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
143 arg = docopt("""
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
144 Usage: tiny_screen.py [options]
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
145
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
146 -v Verbose
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
147 -x Draw to X11 window, not output hardware
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
148 """)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
149 log.setLevel(logging.WARN)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
150 if arg['-v']:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
151 from twisted.python import log as twlog
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
152 twlog.startLogging(sys.stdout)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
153 log.setLevel(logging.DEBUG)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
154
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
155 masterGraph = PatchableGraph()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
156
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
157 if arg['-x']:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
158 screen = ScreenSim()
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
159 else:
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
160 screen = Screen(spiDevice=1)
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
161
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
162 port = 10013
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
163 reactor.listenTCP(port, cyclone.web.Application([
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
164 (r"/()", cyclone.web.StaticFileHandler,
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
165 {"path": ".", "default_filename": "index.html"}),
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 459
diff changeset
166 (r"/graph/tinyScreen", CycloneGraphHandler, {'masterGraph': masterGraph}),
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 459
diff changeset
167 (r"/graph/tinyScreen/events", CycloneGraphEventsHandler,
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
168 {'masterGraph': masterGraph}),
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
169 (r'/output', OutputPage),
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
170 ], screen=screen, masterGraph=masterGraph, debug=arg['-v']),
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
171 interface='::')
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
172 log.warn('serving on %s', port)
723
b87b6e9cedb2 whitespace
drewp@bigasterisk.com
parents: 722
diff changeset
173
388
c146fa2bc7d4 tinyscreen can flip images and render news
drewp@bigasterisk.com
parents: 384
diff changeset
174 reactor.run()