Subversion Repositories Code-Repo

Rev

Rev 199 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

#ifndef CUBE_H
#define CUBE_H

#define CUBE_ROW_COUNT 8
#define CUBE_COLUMN_COUNT 8
#define CUBE_LAYER_COUNT 8

#define GCS_REG_SIZE 36
#define GCS_LAYER_SIZE (GCS_REG_SIZE*CUBE_ROW_COUNT)

#define RED    0x0FF,0x000,0x000
#define ORANGE 0x0FF,0x020,0x000
#define YELLOW 0x0FF,0x0FF,0x000
#define GREEN  0x000,0x0FF,0x000
#define TEAL   0x000,0x0FF,0x0FF
#define BLUE   0x000,0x000,0x0FF
#define PURPLE 0x0FF,0x000,0x0FF

#define SFT_D_TRIS TRISBbits.TRISB15
#define SFT_S_TRIS TRISDbits.TRISD5
#define SFT_K_TRIS TRISDbits.TRISD4
#define SFT_R_TRIS TRISBbits.TRISB14

#define SFT_D PORTBbits.RB15
#define SFT_S PORTDbits.RD5
#define SFT_K PORTDbits.RD4
#define SFT_R PORTBbits.RB14

#define GSLAT_TRIS TRISDbits.TRISD9
#define XBLNK_TRIS TRISDbits.TRISD2

#define GSLAT PORTDbits.RD9
#define XBLNK PORTDbits.RD2

#define CUBE_MAX_BRIGHTNESS 0x7F

typedef struct {
    unsigned char GCS[CUBE_LAYER_COUNT][GCS_LAYER_SIZE];
} CUBE_DATA;

void Cube_Init(CUBE_DATA *data, char BC);
void Cube_Timer_Interrupt(void);

// Callbacks on completion of DCS/GCS writes
void Cube_DCS_Write_Callback(void);
void Cube_GCS_Write_Callback(void);

// Cube control functions
void Cube_Write_DCS(char BC);
void Cube_Clear(void);
void Cube_Set_All(int R, int G, int B);
void Cube_Set_Layer(int layer, int R, int G, int B);
void Cube_Set_Pixel(int layer, int row, int column, int R, int G, int B);

#endif  /* CUBE_H */