Subversion Repositories Code-Repo

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
199 Kevin 1
#ifndef CUBE_H
2
#define	CUBE_H
3
 
4
#define CUBE_ROW_COUNT 8
5
#define CUBE_COLUMN_COUNT 8
6
#define CUBE_LAYER_COUNT 8
205 Kevin 7
#define CUBE_ROTATIONS 7
199 Kevin 8
 
9
#define GCS_REG_SIZE 36
10
#define GCS_LAYER_SIZE (GCS_REG_SIZE*CUBE_ROW_COUNT)
11
 
12
#define RED    0x0FF,0x000,0x000
13
#define ORANGE 0x0FF,0x020,0x000
14
#define YELLOW 0x0FF,0x0FF,0x000
15
#define GREEN  0x000,0x0FF,0x000
16
#define TEAL   0x000,0x0FF,0x0FF
17
#define BLUE   0x000,0x000,0x0FF
18
#define PURPLE 0x0FF,0x000,0x0FF
19
 
20
#define SFT_D_TRIS TRISBbits.TRISB15
21
#define SFT_S_TRIS TRISDbits.TRISD5
22
#define SFT_K_TRIS TRISDbits.TRISD4
23
#define SFT_R_TRIS TRISBbits.TRISB14
24
 
25
#define SFT_D PORTBbits.RB15
26
#define SFT_S PORTDbits.RD5
27
#define SFT_K PORTDbits.RD4
28
#define SFT_R PORTBbits.RB14
29
 
30
#define GSLAT_TRIS TRISDbits.TRISD9
31
#define XBLNK_TRIS TRISDbits.TRISD2
32
 
33
#define GSLAT PORTDbits.RD9
34
#define XBLNK PORTDbits.RD2
35
 
36
typedef struct {
37
    unsigned char GCS[CUBE_LAYER_COUNT][GCS_LAYER_SIZE];
201 Kevin 38
    unsigned char current_layer;
205 Kevin 39
    unsigned char rotation_counter;
199 Kevin 40
} CUBE_DATA;
41
 
200 Kevin 42
void Cube_Init(CUBE_DATA *data, char BC);
199 Kevin 43
void Cube_Timer_Interrupt(void);
44
 
45
// Callbacks on completion of DCS/GCS writes
46
void Cube_DCS_Write_Callback(void);
47
void Cube_GCS_Write_Callback(void);
48
 
49
// Cube control functions
200 Kevin 50
void Cube_Write_DCS(char BC);
199 Kevin 51
void Cube_Clear(void);
52
void Cube_Set_All(int R, int G, int B);
53
void Cube_Set_Layer(int layer, int R, int G, int B);
54
void Cube_Set_Pixel(int layer, int row, int column, int R, int G, int B);
205 Kevin 55
void Cube_Get_Pixel(int layer, int row, int column, int* R, int* G, int* B);
199 Kevin 56
 
205 Kevin 57
void Cube_Move_Pixel(int layer1, int row1, int column1, int layer2, int row2, int column2);
58
 
59
void Cube_Rotate_Shell(char shell);
60
void Cube_Rotate(void);
61
 
199 Kevin 62
#endif	/* CUBE_H */
63