import neopixel
import machine
import time
from random import randrange as r
NUMPIXELS = 100
pin = 15
np = neopixel.NeoPixel(machine.Pin(pin), NUMPIXELS)
fill = 0
prev = []
# link do projekta
# https://tinyurl.com/mr96fwjy
def stack(pos, color, delay):
#print(fill)
# narišimo shranjene barve - fill pove koliko jih je
for i in range(fill):
# NUMPIXELS-i-1, ker rišemo iz zadnje strani
# iz seznama prev prerišemo ledice iz zadnjega konca
np[NUMPIXELS-i-1] = prev[i]
np.write()
# rotacija ledice do zadnje neprižgane ledice (do numpixels - fill)
for i in range(0, NUMPIXELS - fill):
if i != 0:
np[i-1] = [0,0,0]
np[i] = color
np.write()
time.sleep_ms(delay)
# main loop
for i in range(NUMPIXELS):
np.fill([0,0,0])
col = [r(100,255),r(100,255),r(100,255)]
stack(i, col, 100)
# povečamo število barv na koncu
fill += 1
#shranimo novo barvo
prev.append(col)
np.write()