def diagonal_wave_animation():
    '''Displays a diagonal wave animation over ~3 seconds.  Movement should
    appear in the direction from the botton right to the top left.
    '''
    fb = FrameBuffer(matrix_layout=[(0,0,90)])
    colors = list(range(16)) + list(reversed(range(16)))
    for i in range(80):
        for x in range(16):
            fb.line((x-8,0),(x,fb.height), color=colors[x])
        fb.show()
        # rotate colors
        colors = colors[1:] + colors[:1]
        time.sleep(0.04)
def diagonal_wave_animation():
    '''Displays a diagonal wave animation over ~3 seconds.  Movement should
    appear in the direction from the botton right to the top left.
    '''
    fb = FrameBuffer(matrix_layout=[(0, 0, 90)])
    colors = list(range(16)) + list(reversed(range(16)))
    for i in range(80):
        for x in range(16):
            fb.line((x - 8, 0), (x, fb.height), color=colors[x])
        fb.show()
        # rotate colors
        colors = colors[1:] + colors[:1]
        time.sleep(0.04)
def init_two():
    fb = FrameBuffer(matrix_layout=[(0,0,0), (8,0,0)])
    fb.line((0,0),(fb.width, fb.height), color=0xa)
    expected_fb = '''
        00000000000000aa
        000000000000aa00
        0000000000aa0000
        00000000aa000000
        000000aa00000000
        0000aa0000000000
        00aa000000000000
        aa00000000000000
        '''
    return arrays_equal(expected_fb, fb)
def line5():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.line((1,3),(6,5))
    expected_fb = '''
        00000000
        00000000
        00000FF0
        000FF000
        0FF00000
        00000000
        00000000
        00000000
        '''
    return arrays_equal(expected_fb, fb)
def line3():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.line((0,0),(7,7))
    expected_fb = '''
        0000000F
        000000F0
        00000F00
        0000F000
        000F0000
        00F00000
        0F000000
        F0000000
        '''
    return arrays_equal(expected_fb, fb)
def init_two():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0), (8, 0, 0)])
    fb.line((0, 0), (fb.width, fb.height), color=0xa)
    expected_fb = '''
        00000000000000aa
        000000000000aa00
        0000000000aa0000
        00000000aa000000
        000000aa00000000
        0000aa0000000000
        00aa000000000000
        aa00000000000000
        '''
    return arrays_equal(expected_fb, fb)
def line5():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.line((1, 3), (6, 5))
    expected_fb = '''
        00000000
        00000000
        00000FF0
        000FF000
        0FF00000
        00000000
        00000000
        00000000
        '''
    return arrays_equal(expected_fb, fb)
def line3():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.line((0, 0), (7, 7))
    expected_fb = '''
        0000000F
        000000F0
        00000F00
        0000F000
        000F0000
        00F00000
        0F000000
        F0000000
        '''
    return arrays_equal(expected_fb, fb)
def line4():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.line((0,0),(7,7))
    fb.line((7,0),(0,7), color=1)
    fb.line((2,0),(2,7), color=2)
    fb.line((0,2),(7,2), color=3)
    expected_fb = '''
        1020000F
        012000F0
        00200F00
        0021F000
        002F1000
        33333333
        0F200010
        F0200001
        '''
    return arrays_equal(expected_fb, fb)
def line4():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.line((0, 0), (7, 7))
    fb.line((7, 0), (0, 7), color=1)
    fb.line((2, 0), (2, 7), color=2)
    fb.line((0, 2), (7, 2), color=3)
    expected_fb = '''
        1020000F
        012000F0
        00200F00
        0021F000
        002F1000
        33333333
        0F200010
        F0200001
        '''
    return arrays_equal(expected_fb, fb)
    fb.erase(0xF)
    fb.show()
    time.sleep(1)

    for color in range(16):
        fb.erase(color)
        fb.show()
        time.sleep(2/16)

    fb.erase()
    fb.show()
    time.sleep(0.2)

    for y in range(8):
        fb.erase()
        fb.line((8,y),(15,y))
        fb.show()
        time.sleep(1/8)

    fb.erase()
    fb.show()
    time.sleep(0.2)

    for x in range(8):
        fb.erase()
        fb.line((8+x,0),(8+x,7))
        fb.show()
        time.sleep(1/8)

    fb.erase()
    fb.show()
    for uut in range(1,num_uuts-1):
        fb.draw(digits[uut], (8*uut+1, 0))
    fb.show()
    time.sleep(3)

    # Brightness sequence
    for color in range(16):
        endcaps()
        fb.rect((8,0), (fb.width-16,8), fill=True, color=color)
        fb.show()
        time.sleep(4/16)

    # Horizontal line moving down
    for y in reversed(range(8)):
        endcaps()
        fb.line((8,y),(fb.width-9,y))
        fb.show()
        time.sleep(4/8)

    def hash(color=0xF):
        for x in range(8, fb.width-8, 2):
            for y in range(0,8,2):
                fb.point(x, y, color=color)
                fb.point(x + 1, y + 1, color=color)
        fb.show()

    # Hash 1
    endcaps()
    hash()
    time.sleep(2)