1,6 → 1,7 |
#ifndef CUBE_H |
#define CUBE_H |
|
// Cube Parameters |
#define CUBE_ROW_COUNT 8 |
#define CUBE_COLUMN_COUNT 8 |
#define CUBE_LAYER_COUNT 8 |
9,8 → 10,7 |
#define GCS_REG_SIZE 36 |
#define GCS_LAYER_SIZE (GCS_REG_SIZE*CUBE_ROW_COUNT) |
|
#define CUBE_STRING_MAX_LENGTH 32 |
|
// Color Definitions |
#define RED 0x08F,0x000,0x000 |
#define ORANGE 0x08F,0x020,0x000 |
#define YELLOW 0x08F,0x08F,0x000 |
19,6 → 19,7 |
#define BLUE 0x000,0x000,0x08F |
#define PURPLE 0x08F,0x000,0x08F |
|
// Control Pin Declarations |
#define SFT_D_TRIS TRISBbits.TRISB15 |
#define SFT_S_TRIS TRISDbits.TRISD5 |
#define SFT_K_TRIS TRISDbits.TRISD4 |
35,7 → 36,30 |
#define GSLAT PORTDbits.RD9 |
#define XBLNK PORTDbits.RD2 |
|
// String Overlay Buffer Size |
#define CUBE_STRING_MAX_LENGTH 32 |
|
// Data Streaming In Buffer Size |
#define CUBE_FRAME_BUFFER_SIZE 128 |
#define CUBE_START_CHAR 0x7E |
#define CUBE_ESCAPE_CHAR 0x7D |
#define CUBE_ESCAPE_XOR 0x20 |
|
// Data Streaming In Command Set |
#define CUBE_COMMAND_SET_PIXEL 0x10 // Layer, Row, Column, R, G, B <-- frame layout |
|
|
typedef enum { |
IDLE, |
READ_LENGTH_MSB, |
READ_LENGTH_LSB, |
READ_COMMAND, |
READ_DATA, |
READ_CHECKSUM |
} PROCESS_STATE; |
|
typedef struct { |
// Variables for base cube |
unsigned char GCS[CUBE_LAYER_COUNT][GCS_LAYER_SIZE]; |
unsigned char GCS_OVERLAY[CUBE_LAYER_COUNT][GCS_LAYER_SIZE]; |
unsigned char GCS_WRITE[CUBE_LAYER_COUNT][GCS_LAYER_SIZE]; |
42,11 → 66,21 |
unsigned char current_layer; |
unsigned char rotation_counter; |
|
// Variables for the scrolling text |
unsigned char string[CUBE_STRING_MAX_LENGTH]; |
unsigned char string_length; |
unsigned char string_index; |
unsigned char string_line; |
int string_R, string_G, string_B; |
|
// Variables for input frame data |
PROCESS_STATE frame_state; |
unsigned char frame_buffer[CUBE_FRAME_BUFFER_SIZE]; |
int frame_checksum; |
int frame_length; |
int frame_index; |
int frame_command; |
int frame_escape; |
} CUBE_DATA; |
|
void Cube_Init(CUBE_DATA *data, char BC); |
67,6 → 101,7 |
void Cube_Rotate_Shell(char shell, char direction); |
void Cube_Rotate(char direction); |
|
// Overlay control functions |
void Cube_Overlay_Clear(void); |
void Cube_Overlay_Set_Pixel(int layer, int row, int column, int R, int G, int B); |
void Cube_Overlay_Get_Pixel(int layer, int row, int column, int* R, int* G, int* B); |
73,8 → 108,13 |
void Cube_Overlay_Move_Pixel(int layer1, int row1, int column1, int layer2, int row2, int column2); |
void Cube_Overlay_Rotate_Shell(char shell, char direction); |
|
// Text control functions |
void Cube_Text_Init(char *string, char length, int R, int G, int B); |
void Cube_Text_Interrupt(void); |
|
// Data stream in control functions |
void Cube_Data_In(char c); |
void Cube_Data_In_Process_Frame(void); |
|
#endif /* CUBE_H */ |
|