import utime
import leds
import ujson

class RainbowRunner:

    # Calculate the HSV color steps for the 11 LEDs
    STEP = int(360/11)

    def __init__(self):
        leds.clear()
        self.states = []
        self.setup()

    def setup(self):
        # prepare the initial color for each of the 11 LEDs
        for i in range(0,11):
            self.states.append(int(self.STEP * i))

    def run(self):
        while True:
            # set every LED to its current color value
            for i in range(0,11):
                leds.prep_hsv(i, [self.states[i],1,0.5])
            leds.update()
            leds.dim_top(3)
            # wait a certain amount of time
            utime.sleep(0.1)
            # prepare the next color for each LED
            for i in range(0,11):
                self.states[i] = (self.states[i] + self.STEP) % 360
       

rr = RainbowRunner()
rr.run()

