From 9bdc8f8cb954a4177a5298c310f3f3d5c4eb3e05 Mon Sep 17 00:00:00 2001 From: Scott Lawson Date: Sun, 13 Nov 2016 01:10:44 -0800 Subject: [PATCH] Changed pixels from row vectors to column vectors to improve performance --- python/led.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/led.py b/python/led.py index 4632e2e..1861907 100644 --- a/python/led.py +++ b/python/led.py @@ -5,9 +5,9 @@ import config _sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) _gamma = np.load(config.GAMMA_TABLE_PATH) -_prev_pixels = np.tile(253, (config.N_PIXELS, 3)) +_prev_pixels = np.tile(253, (3, config.N_PIXELS)) -pixels = np.tile(1, (config.N_PIXELS, 3)) +pixels = np.tile(1, (3, config.N_PIXELS)) """Array containing the pixel values for the LED strip""" @@ -18,9 +18,9 @@ def update(): p = _gamma[pixels] if config.GAMMA_CORRECTION else np.copy(pixels) for i in range(config.N_PIXELS): # Ignore pixels if they haven't changed (saves bandwidth) - if np.array_equal(p[i], _prev_pixels[i]): + if np.array_equal(p[:, i], _prev_pixels[:, i]): continue - m += chr(i) + chr(p[i][0]) + chr(p[i][1]) + chr(p[i][2]) + m += chr(i) + chr(p[0][i]) + chr(p[1][i]) + chr(p[2][i]) _prev_pixels = np.copy(p) _sock.sendto(m, (config.UDP_IP, config.UDP_PORT))