Example #1
0
while True:

    #x = 0
    #y = 0
    #z = 0
    #COLOR = (x,y,z)
    #for v in range (5):
    #    x = v+1 % 255
    #    y = v+1 % 255
    #    z = v+1 % 255
    #COLOR = (x,y,z)
    #pixels.fill(OFF)
    #pixels.show()

    if playing:
        gridbeat.outline = 0x009900
        sequencer(seq, beat, gridbeat, x)
        x = (x + 1) % 16
        pixels.fill(PLAY)
        pixels.show()
        set_note_playing((seq[x][0]))

    else:
        gridbeat.outline = 0xff0000
        pixels.fill(OFF)
        pixels.show()

        # Reading buttons too fast returns 0
    if (last_read + 0.1) < time.monotonic():
        buttons = pad.get_pressed()
        last_read = time.monotonic()
                b.selected = True
                command = (10 * int(active_page)) + b.id

                # Not doing anything wiht the buttons right now.
                # Just dumping out the associated command
                if (b in buttons):
                    print("Button {} pressed on page {}. Running command {}".
                          format(b.label, active_page, command))

                # Change the active page with the tab
                if b == tab0:
                    active_page = 0
                    print("Setting active page to {}".format(active_page))
                    active_fill = active_outline = page0_color
                    main_page.fill = page0_color
                    main_page.outline = page0_color

                elif b == tab1:
                    active_page = 1
                    print("Setting active page to {}".format(active_page))
                    active_fill = active_outline = page1_color
                    main_page.fill = page1_color
                    main_page.outline = page1_color

                elif b == tab2:
                    active_page = 2
                    print("Setting active page to {}".format(active_page))
                    active_fill = active_outline = page2_color
                    main_page.fill = page2_color
                    main_page.outline = page2_color