From 6503863333020a27a713d28ebc42cf2225dfca28 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 10 Mar 2014 00:31:05 +0100 Subject: Fixed alpha handling, added noise --- host/matelight.py | 2 +- host/server.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/host/matelight.py b/host/matelight.py index d473cc0..1bafe66 100644 --- a/host/matelight.py +++ b/host/matelight.py @@ -39,6 +39,6 @@ def sendframe(framedata): # just use the first Mate Light available rgba = len(framedata) == DISPLAY_WIDTH*DISPLAY_HEIGHT*4 global dbuf - np.copyto(dbuf, np.frombuffer(framedata, dtype=np.uint8)) + np.copyto(dbuf[:640*(3+rgba)], np.frombuffer(framedata, dtype=np.uint8)) ml.matelight_send_frame(matelights, dbuf.ctypes.data_as(POINTER(c_uint8)), c_size_t(CRATES_X), c_size_t(CRATES_Y), c_float(BRIGHTNESS), rgba) diff --git a/host/server.py b/host/server.py index 3b99b4e..2660f42 100755 --- a/host/server.py +++ b/host/server.py @@ -9,6 +9,7 @@ from collections import namedtuple, deque import itertools import threading import random +import os from ctypes import * @@ -160,7 +161,13 @@ if __name__ == '__main__': elif userver.frame_da(): renderer = userver else: - sendframe(next(defaulttexts)) + static_noise = time() % 300 < 60 + if static_noise: + foo = os.urandom(640) + frame = bytes([v for c in zip(list(foo), list(foo), list(foo)) for v in c ]) + else: + frame = next(defaulttexts) + sendframe(frame) #printframe(next(defaulttexts)) continue for frame in renderer: -- cgit