def flash_random(flash_count, delay):
# Copied from https://github.com/pimoroni/unicorn-hat/blob/master/python/examples/random_blinky.py
for index in range(flash_count):
rand_mat = np.random.rand(8, 8)
for y in range(8):
for x in range(8):
h = 0.1 * rand_mat[x, y]
s = 0.8
v = rand_mat[x, y]
rgb = colorsys.hsv_to_rgb(h, s, v)
r = int(rgb[0] * 255.0)
g = int(rgb[1] * 255.0)
b = int(rgb[2] * 255.0)
lights.set_pixel(x, y, r, g, b)
lights.show()
time.sleep(delay)
lights.off()
time.sleep(delay)
评论列表
文章目录