comparison lib/devices_shared.py @ 431:be76e9677a99

animated rgb puts more data back into graph Ignore-this: d3ba1aa218aa1782aa715d5cd013bb9
author drewp@bigasterisk.com
date Sun, 07 Apr 2019 03:58:05 -0700
parents 980d4cf8857d
children
comparison
equal deleted inserted replaced
430:053fd552b675 431:be76e9677a99
65 self.current = numpy.zeros((numLeds, 3), dtype=numpy.uint8) 65 self.current = numpy.zeros((numLeds, 3), dtype=numpy.uint8)
66 66
67 self.x = AnimChannel(0) 67 self.x = AnimChannel(0)
68 self.y = AnimChannel(0) 68 self.y = AnimChannel(0)
69 self.height = AnimChannel(numLeds) 69 self.height = AnimChannel(numLeds)
70 self.src = ""
70 71
71 def animateTo(self, x, y, height, src, rate=30, interpolate=ROOM['slide']): 72 def animateTo(self, x, y, height, src, rate=30, interpolate=ROOM['slide']):
72 log.info('anim to %s x=%s y=%s h=%s', src, x, y, height) 73 log.info('anim to %s x=%s y=%s h=%s', src, x, y, height)
73 self.x.animTo(x, rate) 74 self.x.animTo(x, rate)
74 self.y.animTo(y, rate) # need separate y rate? 75 self.y.animTo(y, rate) # need separate y rate?
85 except IOError as e: 86 except IOError as e:
86 log.warn('getPixelColumn %r', e) 87 log.warn('getPixelColumn %r', e)
87 log.debug('current = %r', self.current) 88 log.debug('current = %r', self.current)
88 89
89 def currentStatements(self): 90 def currentStatements(self):
90 return [] 91 return [
92 (self.uri, RDF.type, ROOM['ScanGroup']),
93 (self.uri, ROOM['xValue'], Literal(self.x.get())),
94 (self.uri, ROOM['yValue'], Literal(self.y.get())),
95 (self.uri, ROOM['heightValue'], Literal(self.height.get())),
96 (self.uri, ROOM['src'], Literal(self.src)),
97 ]
91 98
92 def colorForIndex(self, i): 99 def colorForIndex(self, i):
93 return list(self.current[i,:]) 100 return list(self.current[i,:])
94 101
95 args = {ROOM['src']: ('src', str), 102 args = {ROOM['src']: ('src', str),
130 137
131 def hostStatements(self): 138 def hostStatements(self):
132 return ( 139 return (
133 [(self.uri, ROOM['pixelGroup'], grp) for grp in self.groups.keys()] + 140 [(self.uri, ROOM['pixelGroup'], grp) for grp in self.groups.keys()] +
134 sum([v[2].currentStatements() 141 sum([v[2].currentStatements()
135 for v in self.groups.itervalues()], [])) 142 for v in self.groups.itervalues()], []) +
143 [] # current
144 )
136 145
137 def getColorOrder(self, graph, uri): 146 def getColorOrder(self, graph, uri):
138 colorOrder = graph.value(uri, ROOM['colorOrder'], 147 colorOrder = graph.value(uri, ROOM['colorOrder'],
139 default=ROOM['ledColorOrder/RGB']) 148 default=ROOM['ledColorOrder/RGB'])
140 head, tail = str(colorOrder).rsplit('/', 1) 149 head, tail = str(colorOrder).rsplit('/', 1)
146 def step(self): 155 def step(self):
147 # if animating... 156 # if animating...
148 self.updateOutput() 157 self.updateOutput()
149 158
150 def onStatements(self, statements, _groups=True): 159 def onStatements(self, statements, _groups=True):
151
152 needSetup = False 160 needSetup = False
153 animateCalls = {} # group uri : kw for animateTo 161 animateCalls = {} # group uri : kw for animateTo
154 for s, p, o in statements: 162 for s, p, o in statements:
155 if s not in self.groups: 163 if s not in self.groups:
156 # missing the case that you just added a new group 164 # missing the case that you just added a new group