Subversion Repositories Code-Repo

Rev

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
 
206 Kevin 12
#define CUBE_STRING_MAX_LENGTH 32
13
 
199 Kevin 14
#define RED    0x0FF,0x000,0x000
15
#define ORANGE 0x0FF,0x020,0x000
16
#define YELLOW 0x0FF,0x0FF,0x000
17
#define GREEN  0x000,0x0FF,0x000
18
#define TEAL   0x000,0x0FF,0x0FF
19
#define BLUE   0x000,0x000,0x0FF
20
#define PURPLE 0x0FF,0x000,0x0FF
21
 
22
#define SFT_D_TRIS TRISBbits.TRISB15
23
#define SFT_S_TRIS TRISDbits.TRISD5
24
#define SFT_K_TRIS TRISDbits.TRISD4
25
#define SFT_R_TRIS TRISBbits.TRISB14
26
 
27
#define SFT_D PORTBbits.RB15
28
#define SFT_S PORTDbits.RD5
29
#define SFT_K PORTDbits.RD4
30
#define SFT_R PORTBbits.RB14
31
 
32
#define GSLAT_TRIS TRISDbits.TRISD9
33
#define XBLNK_TRIS TRISDbits.TRISD2
34
 
35
#define GSLAT PORTDbits.RD9
36
#define XBLNK PORTDbits.RD2
37
 
38
typedef struct {
39
    unsigned char GCS[CUBE_LAYER_COUNT][GCS_LAYER_SIZE];
206 Kevin 40
    unsigned char GCS_OVERLAY[CUBE_LAYER_COUNT][GCS_LAYER_SIZE];
41
    unsigned char GCS_WRITE[CUBE_LAYER_COUNT][GCS_LAYER_SIZE];
201 Kevin 42
    unsigned char current_layer;
205 Kevin 43
    unsigned char rotation_counter;
206 Kevin 44
 
45
    unsigned char string[CUBE_STRING_MAX_LENGTH];
46
    unsigned char string_length;
47
    unsigned char string_index;
48
    unsigned char string_line;
49
    int string_R, string_G, string_B;
199 Kevin 50
} CUBE_DATA;
51
 
200 Kevin 52
void Cube_Init(CUBE_DATA *data, char BC);
199 Kevin 53
void Cube_Timer_Interrupt(void);
54
 
55
// Callbacks on completion of DCS/GCS writes
56
void Cube_DCS_Write_Callback(void);
57
void Cube_GCS_Write_Callback(void);
58
 
59
// Cube control functions
200 Kevin 60
void Cube_Write_DCS(char BC);
199 Kevin 61
void Cube_Clear(void);
62
void Cube_Set_All(int R, int G, int B);
63
void Cube_Set_Layer(int layer, int R, int G, int B);
64
void Cube_Set_Pixel(int layer, int row, int column, int R, int G, int B);
205 Kevin 65
void Cube_Get_Pixel(int layer, int row, int column, int* R, int* G, int* B);
66
void Cube_Move_Pixel(int layer1, int row1, int column1, int layer2, int row2, int column2);
206 Kevin 67
void Cube_Rotate_Shell(char shell, char direction);
68
void Cube_Rotate(char direction);
205 Kevin 69
 
206 Kevin 70
void Cube_Overlay_Clear(void);
71
void Cube_Overlay_Set_Pixel(int layer, int row, int column, int R, int G, int B);
72
void Cube_Overlay_Get_Pixel(int layer, int row, int column, int* R, int* G, int* B);
73
void Cube_Overlay_Move_Pixel(int layer1, int row1, int column1, int layer2, int row2, int column2);
74
void Cube_Overlay_Rotate_Shell(char shell, char direction);
205 Kevin 75
 
206 Kevin 76
void Cube_Text_Init(char *string, char length, int R, int G, int B);
77
void Cube_Text_Interrupt(void);
78
 
199 Kevin 79
#endif	/* CUBE_H */
80