Startup
This commit is contained in:
40
script/scale.py
Normal file
40
script/scale.py
Normal file
@@ -0,0 +1,40 @@
|
||||
class Image(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
|
||||
def doRead(self):
|
||||
time.sleep(0.001)
|
||||
self.val = to_array(self.calc(), 'd')
|
||||
return self.val
|
||||
|
||||
def getWidth(self):
|
||||
return len(self.take(-1)[0])
|
||||
|
||||
def getHeight(self):
|
||||
return len(self.take(-1))
|
||||
|
||||
class SinusoidImage(Image):
|
||||
def calc(self):
|
||||
(width, height) = (200, 100)
|
||||
ret = []
|
||||
x = random.random();
|
||||
base = []
|
||||
for i in range (width):
|
||||
base.append( math.sin(x))
|
||||
x = x + 0.05
|
||||
for i in range (height):
|
||||
noise = (random.random() - 0.5)/5.0
|
||||
ret.append([x+noise for x in base])
|
||||
return ret
|
||||
|
||||
def calc(self):
|
||||
(width, height) = (200, 100)
|
||||
ret = []
|
||||
for i in range (height):
|
||||
ret.append([0] * width)
|
||||
return ret
|
||||
|
||||
add_device(SinusoidImage("im1"), True)
|
||||
p=show_panel(im1)
|
||||
p.setAsyncUpdates(True)
|
||||
im1.polling=200
|
||||
|
||||
add_device(RegisterMatrixSource("src1", im1), True)
|
||||
p=show_panel(src1)
|
||||
Reference in New Issue
Block a user