Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 267 → Rev 268

/PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.c
305,7 → 305,7
 
void Cube_Set_Sphere(uint8_t layer, uint8_t R, uint8_t G, uint8_t B) {
// Super code inefficient (or is it?) lookup table
switch (layer) {
switch (layer % 9) {
case 0:
Cube_Set_Pixel(3, 3, 3, R, G, B);
Cube_Set_Pixel(3, 3, 4, R, G, B);
1172,7 → 1172,7
// Then update the empty row
for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
for (j = 0; j < CUBE_LAYER_COUNT; j++) {
if (j < values[i]) {
if (j < values[i] % 9) {
// Specify the color for each column
if (i == 0)
Cube_Set_Pixel(j, update_row, i, RED);
1209,7 → 1209,7
// Then update the empty row
for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
for (j = 0; j < CUBE_LAYER_COUNT; j++) {
if (j < values[i]) {
if (j < values[i] % 9) {
// Specify the color for each layer
if (j == 7)
Cube_Set_Pixel(j, update_row, i, RED);
1532,33 → 1532,58
}
}
 
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B) {
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B, uint16_t delay) {
// Save the character to insert
cube_data_ptr->string[0] = c;
cube_data_ptr->string_length = 1;
cube_data_ptr->string_line = 0;
cube_data_ptr->string_R = R;
cube_data_ptr->string_G = G;
cube_data_ptr->string_B = B;
 
if (delay == 0) {
int i;
for (i = 0; i < 6; i++) {
Cube_Text_Single_Char_Interupt();
}
} else {
// Start a timer to update the overlay with the inserted character
TIMER4_Stop();
TIMER4_Init(NULL, NULL, &Cube_Text_Single_Char_Interupt, delay);
TIMER4_Start();
}
}
 
void Cube_Text_Single_Char_Interupt(void) {
uint8_t layer;
uint8_t line = 0;
uint8_t i;
uint8_t line;
 
// Insert a single character to the overlay text
for (i = 0; i < 6; i++) {
// Rotate before drawing the new line at (0,0)
Cube_Overlay_Rotate_Shell(0, 0);
 
// Rotate before drawing the new line at (0,0)
Cube_Overlay_Rotate_Shell(0, 0);
// Get the next vertical line of the character currently being drawn
if (cube_data_ptr->string_line == 0) {
line = 0x0; // Leave a space between characters
} else {
line = font[(cube_data_ptr->string[0] * 5) + cube_data_ptr->string_line - 1];
}
 
// Get the next vertical line of the character currently being drawn
if (i == 0) {
line = 0x0; // Leave a space between characters
// Draw the line onto (0,0) using the specified color
for (layer = 8; layer != 0; layer--) {
if (line & 0x1) {
Cube_Overlay_Set_Pixel(layer-1, 0, 0, cube_data_ptr->string_R,
cube_data_ptr->string_G, cube_data_ptr->string_B);
} else {
line = font[(c * 5) + i - 1];
Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
}
line >>= 1;
}
 
// Draw the line onto (0,0) using the specified color
for (layer = 8; layer != 0; layer--) {
if (line & 0x1) {
Cube_Overlay_Set_Pixel(layer-1, 0, 0, R, G, B);
} else {
Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
}
line >>= 1;
}
// Increment the vertical line or stop the timer as needed
if (cube_data_ptr->string_line == 5) {
TIMER4_Stop();
} else {
cube_data_ptr->string_line += 1;
}
}
 
1789,9 → 1814,10
// Byte 1 = red channel
// Byte 2 = green channel
// Byte 3 = blue channel
// Byte 4 = character
// Byte 4 = delay x6 between shifts
// Byte 5 = character
TIMER4_Stop();
Cube_Text_Insert(buffer[4], buffer[1], buffer[2], buffer[3]);
Cube_Text_Insert(buffer[5], buffer[1], buffer[2], buffer[3], buffer[4]);
} else if (buffer[0] == CUBE_ETH_WATERFALL) { // 0x30
// Byte 1 = height of column 0
// Byte 2 = height of column 1