Subversion Repositories Code-Repo

Rev

Rev 265 | Blame | Compare with Previous | Last modification | View Log | RSS feed

import serial,time
from CubeRawCommands import *
from CubeInterface import *

def Animation_Row_Column_Sweep(iterations, delay):
    for z in range(iterations):
        for i in range(3):
            for j in range(CUBE_ROW_COUNT):
                Cube_Clear();
                for k in range(CUBE_COLUMN_COUNT):
                    if (i % 3 == 0):
                        for a in range(CUBE_LAYER_COUNT):
                            Cube_Set_Pixel(a,j,k,0xFF,0x00,0x00)
                    elif (i % 3 == 1):
                        for a in range(CUBE_LAYER_COUNT):
                            Cube_Set_Pixel(a,j,k,0x00,0xFF,0x00)
                    else:
                        for a in range(CUBE_LAYER_COUNT):
                            Cube_Set_Pixel(a,j,k,0x00,0x00,0xFF)
                Cube_Update()
                time.sleep(delay)
            for j in range(CUBE_ROW_COUNT):
                Cube_Clear();
                for k in range(CUBE_COLUMN_COUNT):
                    if (i % 3 == 0):
                        for a in range(CUBE_LAYER_COUNT):
                            Cube_Set_Pixel(a,k,j,0xFF,0x00,0x00)
                    elif (i % 3 == 1):
                        for a in range(CUBE_LAYER_COUNT):
                            Cube_Set_Pixel(a,k,j,0x00,0xFF,0x00)
                    else:
                        for a in range(CUBE_LAYER_COUNT):
                            Cube_Set_Pixel(a,k,j,0x00,0x00,0xFF)
                Cube_Update()
                time.sleep(delay)
            for j in range(CUBE_LAYER_COUNT-1, -1, -1):
                Cube_Clear();
                if (i % 3 == 0):
                    for k in range(CUBE_LAYER_COUNT):
                        if (k == j):
                            for x in range(CUBE_ROW_COUNT):
                                for y in range(CUBE_COLUMN_COUNT):
                                    Cube_Set_Pixel(k,x,y,0xFF,0x00,0x00)
                elif (i % 3 == 1):
                    for k in range(CUBE_LAYER_COUNT):
                        if (k == j):
                            for x in range(CUBE_ROW_COUNT):
                                for y in range(CUBE_COLUMN_COUNT):
                                    Cube_Set_Pixel(k,x,y,0x00,0xFF,0x00)
                else:
                    for k in range(CUBE_LAYER_COUNT):
                        if (k == j):
                            for x in range(CUBE_ROW_COUNT):
                                for y in range(CUBE_COLUMN_COUNT):
                                    Cube_Set_Pixel(k,x,y,0x00,0x00,0xFF)
                Cube_Update()
                time.sleep(delay)

if __name__ == '__main__':
    Cube_Init('COM11', 256000)

    Animation_Row_Column_Sweep(3,0)