aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <jaseg@jaseg.net>2014-03-09 02:00:32 +0100
committerjaseg <jaseg@jaseg.net>2014-03-09 02:00:32 +0100
commitddb77d4209926d53e08366e2c61922827b6093cb (patch)
tree111c3115360232a8e11738c78988c4628af63304
parentc61ed1266895d21ef033cc82b3197c1be14c5b72 (diff)
downloadmatelight-ddb77d4209926d53e08366e2c61922827b6093cb.tar.gz
matelight-ddb77d4209926d53e08366e2c61922827b6093cb.tar.bz2
matelight-ddb77d4209926d53e08366e2c61922827b6093cb.zip
Test about using numpy to alloccate buffer
-rwxr-xr-xhost/server.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/host/server.py b/host/server.py
index cdf2b1d..3d27dc1 100755
--- a/host/server.py
+++ b/host/server.py
@@ -41,12 +41,13 @@ def compute_text_bounds(text):
return textw.value, texth.value
def render_text(text, offset):
- cbuf = create_string_buffer(FRAME_SIZE*sizeof(COLOR))
+ frame = np.ndarray(shape=(DISPLAY_WIDTH, DISPLAY_HEIGHT, 4), dtype=np.uint8)
+ cbuf = frame.ctypes.data_as(POINTER(c_uint8))
textbytes = bytes(str(text), 'UTF-8')
res = bdf.framebuffer_render_text(textbytes, unifont, cbuf, DISPLAY_WIDTH, DISPLAY_HEIGHT, offset)
if res:
raise ValueError('Invalid text')
- return np.ctypeslib.as_array(cast(cbuf, POINTER(c_uint8)), shape=(DISPLAY_WIDTH, DISPLAY_HEIGHT, 4))
+ return frame
printlock = threading.Lock()
@@ -160,6 +161,7 @@ if __name__ == '__main__':
renderer = userver
else:
sendframe(next(defaulttexts))
+ #printframe(next(defaulttexts))
continue
for frame in renderer:
sendframe(frame)