From 15c7154c0525849a4931127f01e6b63a0ee3f973 Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 18 Jul 2019 13:34:10 -0700 Subject: [PATCH] code to test led ticker without using pi --- sim.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 sim.py diff --git a/sim.py b/sim.py new file mode 100644 index 0000000..4b98e9b --- /dev/null +++ b/sim.py @@ -0,0 +1,45 @@ +#%% +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation +import numpy as np + +#%% +matrixSize = (32, 64, 3) +#%% +a = np.random.randint(1, high=256, size=(32, 128, 3)) + +# for i in range(10): +# a = np.delete(a,0,1) +# a.shape + +#%% +plt.imshow(a[:, :64]) +plt.show() + +#%% +blank = np.zeros(matrixSize, dtype=int) +noise = np.random.randint(1, high=256, size=(32, 128, 3)) + +#%% +buffer = np.concatenate((blank, noise), axis=1) + + +#%% +plt.imshow(buffer[:, :64]) +plt.show() + + +#%% +fig = plt.figure(figsize=matrixSize[0:2], facecolor="black") + + +def update(): + np.delete(buffer, 0, 1) + + +plt.imshow(buffer[:, :64]) +ani = FuncAnimation(fig, update, frames=buffer.shape[1]) +plt.show() + + +#%%