1493,7 → 1493,7 |
cube_data_ptr->string_B = B; |
} |
|
void Cube_Text_Interrupt(void) { |
void Cube_Text_Update(void) { |
uint8_t layer; |
uint16_t line; |
|
1500,9 → 1500,9 |
// Rotate before drawing the new line at (0,0) |
Cube_Overlay_Rotate_Shell(0, 0); |
|
// Get the next vertical line of the int8_tacter currently being drawn |
// Get the next vertical line of the character currently being drawn |
if (cube_data_ptr->string_line == 5) { |
line = 0x0; // Leave a space between int8_tacters |
line = 0x0; // Leave a space between characters |
} else { |
line = font[(cube_data_ptr->string[cube_data_ptr->string_index] * 5) |
+ cube_data_ptr->string_line]; |
1519,7 → 1519,7 |
line >>= 1; |
} |
|
// Increment the vertical line and the int8_tacter as needed |
// Increment the vertical line and the character as needed |
if (cube_data_ptr->string_line == 5) { |
cube_data_ptr->string_line = 0; |
if (cube_data_ptr->string_index == cube_data_ptr->string_length-1) { |
1532,6 → 1532,40 |
} |
} |
|
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B) { |
uint8_t layer; |
uint8_t line = 0; |
uint8_t i; |
|
// 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); |
|
// Get the next vertical line of the character currently being drawn |
if (i == 0) { |
line = 0x0; // Leave a space between characters |
} else { |
line = font[(c * 5) + i - 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; |
} |
} |
} |
|
void Cube_Text_Interrupt(void) { |
Cube_Text_Update(); |
} |
|
///////////////////////////////////////////// |
// Functions for processing streaming data // |
///////////////////////////////////////////// |
1560,7 → 1594,7 |
// Process data |
switch (cube_data_ptr->frame_state) { |
case IDLE: |
// Reflect the int8_tacter back to the transmitter |
// Reflect the character back to the transmitter |
UART1_Write(&c, 1); |
break; |
case READ_LENGTH_MSB: // Save MSB of length |
1644,10 → 1678,10 |
// Read and process the ethernet packet |
if (!ETH_Read_Packet(buffer, &length)) { |
// Check the opcode (first byte) to determine what to do |
|
if (buffer[0] == CUBE_ETH_RESET) { // 0x1 - Reset into Ethernet mode |
Reset_Board(BOARD_MODE_ETHERNET); |
} else if (Get_Board_State() == BOARD_MODE_ETHERNET) { |
ClearWDT(); |
if (buffer[0] == CUBE_EHT_IDLE) { // 0x2 - Reset back to idle mode |
Reset_Board(BOARD_MODE_IDLE); |
} else if (buffer[0] == CUBE_ETH_CLEAR) { // 0xA |
1657,17 → 1691,14 |
Cube_Write_DCS(buffer[1]); |
} else if (buffer[0] == CUBE_ETH_ROTATE) { // 0xC |
// Byte 1 = directon to rotate |
ClearWDT(); |
Cube_Rotate(buffer[1]); |
} else if (buffer[0] == CUBE_ETH_ROTATE_LAYER) { // 0xD |
// Byte 1 = layer to rotate |
// Byte 2 = direction to rotate |
ClearWDT(); |
Cube_Rotate_Shell(buffer[1], buffer[2]); |
} else if (buffer[0] == CUBE_ETH_WRITE_ALL) { // 0x10 |
// Byte 1+ = pixel color data (R/G/B) |
if (length == 0x0601) { |
ClearWDT(); |
uint16_t index = 1; |
for (i = 0; i < CUBE_LAYER_COUNT; i++) { |
for (j = 0; j < CUBE_COLUMN_COUNT; j++) { |
1685,7 → 1716,6 |
// Byte 4 = red channel |
// Byte 5 = green channel |
// Byte 6 = blue channel |
ClearWDT(); |
Cube_Set_Pixel(buffer[3], buffer[1], buffer[2], buffer[4], buffer[5], buffer[6]); |
} else if (buffer[0] == CUBE_ETH_WRITE_CHANNEL) { // 0x12 |
// Byte 1 = color channel, 0 = red, 1 = green, 2 = blue |
1692,7 → 1722,6 |
// Byte 2+ = color data |
uint16_t r, g, b; |
uint16_t index = 2; |
ClearWDT(); |
if (buffer[1] % 3 == 0) { |
for (i = 0; i < CUBE_LAYER_COUNT; i++) { |
for (j = 0; j < CUBE_ROW_COUNT; j++) { |
1724,7 → 1753,7 |
} |
} |
} |
} else if (buffer[0] == CUBE_ETH_WRITE_TEXT) { // 0x20 |
} else if (buffer[0] == CUBE_ETH_WRITE_TEXT_SCROLL) { // 0x20 |
// Byte 1 = length of string |
// Byte 2 = red channel |
// Byte 3 = green channel |
1732,15 → 1761,37 |
// Byte 5 = update speed (ms) |
// Byte 6+ = text string |
if (buffer[1] != 0) { |
TIMER4_Stop(); |
Cube_Text_Init(&buffer[6], buffer[1], buffer[2], buffer[3], buffer[4]); |
|
TIMER4_Stop(); |
TIMER4_Init(NULL, NULL, &Cube_Text_Interrupt, buffer[5]); |
TIMER4_Start(); |
} else { |
TIMER4_Stop(); |
Cube_Overlay_Clear(); |
} |
} else if (buffer[0] == CUBE_ETH_WRITE_TEXT_STATIC) { // 0x21 |
// Byte 1 = length of string |
// Byte 2 = red channel |
// Byte 3 = green channel |
// Byte 4 = blue channel |
// Byte 5+ = text string |
if (buffer[1] != 0) { |
TIMER4_Stop(); |
Cube_Text_Init(&buffer[5], buffer[1], buffer[2], buffer[3], buffer[4]); |
for (i = 0; i < buffer[1] * 5; i++) { |
Cube_Text_Update(); |
} |
} else { |
TIMER4_Stop(); |
Cube_Overlay_Clear(); |
} |
} else if (buffer[0] == CUBE_EHT_WRITE_TEXT_INSERT) { // 0x22 |
// Byte 1 = red channel |
// Byte 2 = green channel |
// Byte 3 = blue channel |
// Byte 4 = character |
TIMER4_Stop(); |
Cube_Text_Insert(buffer[4], buffer[1], buffer[2], buffer[3]); |
} else if (buffer[0] == CUBE_ETH_WATERFALL) { // 0x30 |
// Byte 1 = height of column 0 |
// Byte 2 = height of column 1 |