Subversion Repositories Code-Repo

Rev

Rev 264 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 264 Rev 266
Line 1491... Line 1491...
1491
    cube_data_ptr->string_R = R;
1491
    cube_data_ptr->string_R = R;
1492
    cube_data_ptr->string_G = G;
1492
    cube_data_ptr->string_G = G;
1493
    cube_data_ptr->string_B = B;
1493
    cube_data_ptr->string_B = B;
1494
}
1494
}
1495
 
1495
 
1496
void Cube_Text_Interrupt(void) {
1496
void Cube_Text_Update(void) {
1497
    uint8_t layer;
1497
    uint8_t layer;
1498
    uint16_t line;
1498
    uint16_t line;
1499
 
1499
 
1500
    // Rotate before drawing the new line at (0,0)
1500
    // Rotate before drawing the new line at (0,0)
1501
    Cube_Overlay_Rotate_Shell(0, 0);
1501
    Cube_Overlay_Rotate_Shell(0, 0);
1502
 
1502
 
1503
    // Get the next vertical line of the int8_tacter currently being drawn
1503
    // Get the next vertical line of the character currently being drawn
1504
    if (cube_data_ptr->string_line == 5) {
1504
    if (cube_data_ptr->string_line == 5) {
1505
        line = 0x0; // Leave a space between int8_tacters
1505
        line = 0x0; // Leave a space between characters
1506
    } else {
1506
    } else {
1507
        line = font[(cube_data_ptr->string[cube_data_ptr->string_index] * 5)
1507
        line = font[(cube_data_ptr->string[cube_data_ptr->string_index] * 5)
1508
                + cube_data_ptr->string_line];
1508
                + cube_data_ptr->string_line];
1509
    }
1509
    }
1510
 
1510
 
Line 1517... Line 1517...
1517
            Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
1517
            Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
1518
        }
1518
        }
1519
        line >>= 1;
1519
        line >>= 1;
1520
    }
1520
    }
1521
 
1521
 
1522
    // Increment the vertical line and the int8_tacter as needed
1522
    // Increment the vertical line and the character as needed
1523
    if (cube_data_ptr->string_line == 5) {
1523
    if (cube_data_ptr->string_line == 5) {
1524
        cube_data_ptr->string_line = 0;
1524
        cube_data_ptr->string_line = 0;
1525
        if (cube_data_ptr->string_index == cube_data_ptr->string_length-1) {
1525
        if (cube_data_ptr->string_index == cube_data_ptr->string_length-1) {
1526
            cube_data_ptr->string_index = 0;
1526
            cube_data_ptr->string_index = 0;
1527
        } else {
1527
        } else {
Line 1530... Line 1530...
1530
    } else {
1530
    } else {
1531
        cube_data_ptr->string_line += 1;
1531
        cube_data_ptr->string_line += 1;
1532
    }
1532
    }
1533
}
1533
}
1534
 
1534
 
-
 
1535
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B) {
-
 
1536
    uint8_t layer;
-
 
1537
    uint8_t line = 0;
-
 
1538
    uint8_t i;
-
 
1539
 
-
 
1540
    // Insert a single character to the overlay text
-
 
1541
    for (i = 0; i < 6; i++) {
-
 
1542
 
-
 
1543
        // Rotate before drawing the new line at (0,0)
-
 
1544
        Cube_Overlay_Rotate_Shell(0, 0);
-
 
1545
 
-
 
1546
        // Get the next vertical line of the character currently being drawn
-
 
1547
        if (i == 0) {
-
 
1548
            line = 0x0; // Leave a space between characters
-
 
1549
        } else {
-
 
1550
            line = font[(c * 5) + i - 1];
-
 
1551
        }
-
 
1552
 
-
 
1553
        // Draw the line onto (0,0) using the specified color
-
 
1554
        for (layer = 8; layer != 0; layer--) {
-
 
1555
            if (line & 0x1) {
-
 
1556
                Cube_Overlay_Set_Pixel(layer-1, 0, 0, R, G, B);
-
 
1557
            } else {
-
 
1558
                Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
-
 
1559
            }
-
 
1560
            line >>= 1;
-
 
1561
        }
-
 
1562
    }
-
 
1563
}
-
 
1564
 
-
 
1565
void Cube_Text_Interrupt(void) {
-
 
1566
    Cube_Text_Update();
-
 
1567
}
-
 
1568
 
1535
/////////////////////////////////////////////
1569
/////////////////////////////////////////////
1536
// Functions for processing streaming data //
1570
// Functions for processing streaming data //
1537
/////////////////////////////////////////////
1571
/////////////////////////////////////////////
1538
 
1572
 
1539
void Cube_Data_In(uint8_t c) {
1573
void Cube_Data_In(uint8_t c) {
Line 1558... Line 1592...
1558
        cube_data_ptr->frame_escape = 0;
1592
        cube_data_ptr->frame_escape = 0;
1559
    }
1593
    }
1560
    // Process data
1594
    // Process data
1561
    switch (cube_data_ptr->frame_state) {
1595
    switch (cube_data_ptr->frame_state) {
1562
        case IDLE:
1596
        case IDLE:
1563
            // Reflect the int8_tacter back to the transmitter
1597
            // Reflect the character back to the transmitter
1564
            UART1_Write(&c, 1);
1598
            UART1_Write(&c, 1);
1565
            break;
1599
            break;
1566
        case READ_LENGTH_MSB: // Save MSB of length
1600
        case READ_LENGTH_MSB: // Save MSB of length
1567
            cube_data_ptr->frame_length |= (c << 8);
1601
            cube_data_ptr->frame_length |= (c << 8);
1568
            cube_data_ptr->frame_state = READ_LENGTH_LSB;
1602
            cube_data_ptr->frame_state = READ_LENGTH_LSB;
Line 1642... Line 1676...
1642
    uint16_t length;
1676
    uint16_t length;
1643
 
1677
 
1644
    // Read and process the ethernet packet
1678
    // Read and process the ethernet packet
1645
    if (!ETH_Read_Packet(buffer, &length)) {
1679
    if (!ETH_Read_Packet(buffer, &length)) {
1646
        // Check the opcode (first byte) to determine what to do
1680
        // Check the opcode (first byte) to determine what to do
1647
 
-
 
1648
        if (buffer[0] == CUBE_ETH_RESET) {  // 0x1 - Reset into Ethernet mode
1681
        if (buffer[0] == CUBE_ETH_RESET) {  // 0x1 - Reset into Ethernet mode
1649
            Reset_Board(BOARD_MODE_ETHERNET);
1682
            Reset_Board(BOARD_MODE_ETHERNET);
1650
        } else if (Get_Board_State() == BOARD_MODE_ETHERNET) {
1683
        } else if (Get_Board_State() == BOARD_MODE_ETHERNET) {
-
 
1684
            ClearWDT();
1651
            if (buffer[0] == CUBE_EHT_IDLE) {   // 0x2 - Reset back to idle mode
1685
            if (buffer[0] == CUBE_EHT_IDLE) {   // 0x2 - Reset back to idle mode
1652
                Reset_Board(BOARD_MODE_IDLE);
1686
                Reset_Board(BOARD_MODE_IDLE);
1653
            } else if (buffer[0] == CUBE_ETH_CLEAR) {   // 0xA
1687
            } else if (buffer[0] == CUBE_ETH_CLEAR) {   // 0xA
1654
                Cube_Clear();
1688
                Cube_Clear();
1655
            } else if (buffer[0] == CUBE_ETH_DCS) {     // 0xB
1689
            } else if (buffer[0] == CUBE_ETH_DCS) {     // 0xB
1656
                // Byte 1 = global brightness value
1690
                // Byte 1 = global brightness value
1657
                Cube_Write_DCS(buffer[1]);
1691
                Cube_Write_DCS(buffer[1]);
1658
            } else if (buffer[0] == CUBE_ETH_ROTATE) {  // 0xC
1692
            } else if (buffer[0] == CUBE_ETH_ROTATE) {  // 0xC
1659
                // Byte 1 = directon to rotate
1693
                // Byte 1 = directon to rotate
1660
                ClearWDT();
-
 
1661
                Cube_Rotate(buffer[1]);
1694
                Cube_Rotate(buffer[1]);
1662
            } else if (buffer[0] == CUBE_ETH_ROTATE_LAYER) {    // 0xD
1695
            } else if (buffer[0] == CUBE_ETH_ROTATE_LAYER) {    // 0xD
1663
                // Byte 1 = layer to rotate
1696
                // Byte 1 = layer to rotate
1664
                // Byte 2 = direction to rotate
1697
                // Byte 2 = direction to rotate
1665
                ClearWDT();
-
 
1666
                Cube_Rotate_Shell(buffer[1], buffer[2]);
1698
                Cube_Rotate_Shell(buffer[1], buffer[2]);
1667
            } else if (buffer[0] == CUBE_ETH_WRITE_ALL) {       // 0x10
1699
            } else if (buffer[0] == CUBE_ETH_WRITE_ALL) {       // 0x10
1668
                // Byte 1+ = pixel color data (R/G/B)
1700
                // Byte 1+ = pixel color data (R/G/B)
1669
                if (length == 0x0601) {
1701
                if (length == 0x0601) {
1670
                    ClearWDT();
-
 
1671
                    uint16_t index = 1;
1702
                    uint16_t index = 1;
1672
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
1703
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
1673
                        for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
1704
                        for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
1674
                            for (k = 0; k < CUBE_ROW_COUNT; k++) {
1705
                            for (k = 0; k < CUBE_ROW_COUNT; k++) {
1675
                                Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]);
1706
                                Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]);
Line 1683... Line 1714...
1683
                // Byte 2 = column index
1714
                // Byte 2 = column index
1684
                // Byte 3 = layer index
1715
                // Byte 3 = layer index
1685
                // Byte 4 = red channel
1716
                // Byte 4 = red channel
1686
                // Byte 5 = green channel
1717
                // Byte 5 = green channel
1687
                // Byte 6 = blue channel
1718
                // Byte 6 = blue channel
1688
                ClearWDT();
-
 
1689
                Cube_Set_Pixel(buffer[3], buffer[1], buffer[2], buffer[4], buffer[5], buffer[6]);
1719
                Cube_Set_Pixel(buffer[3], buffer[1], buffer[2], buffer[4], buffer[5], buffer[6]);
1690
            } else if (buffer[0] == CUBE_ETH_WRITE_CHANNEL) {   // 0x12
1720
            } else if (buffer[0] == CUBE_ETH_WRITE_CHANNEL) {   // 0x12
1691
                // Byte 1 = color channel, 0 = red, 1 = green, 2 = blue
1721
                // Byte 1 = color channel, 0 = red, 1 = green, 2 = blue
1692
                // Byte 2+ = color data
1722
                // Byte 2+ = color data
1693
                uint16_t r, g, b;
1723
                uint16_t r, g, b;
1694
                uint16_t index = 2;
1724
                uint16_t index = 2;
1695
                ClearWDT();
-
 
1696
                if (buffer[1] % 3 == 0) {
1725
                if (buffer[1] % 3 == 0) {
1697
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
1726
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
1698
                        for (j = 0; j < CUBE_ROW_COUNT; j++) {
1727
                        for (j = 0; j < CUBE_ROW_COUNT; j++) {
1699
                            for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
1728
                            for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
1700
//                                Cube_Get_Pixel(i, j, k, &r, &g, &b);
1729
//                                Cube_Get_Pixel(i, j, k, &r, &g, &b);
Line 1722... Line 1751...
1722
                                index++;
1751
                                index++;
1723
                            }
1752
                            }
1724
                        }
1753
                        }
1725
                    }
1754
                    }
1726
                }
1755
                }
1727
            } else if (buffer[0] == CUBE_ETH_WRITE_TEXT) {      // 0x20
1756
            } else if (buffer[0] == CUBE_ETH_WRITE_TEXT_SCROLL) {   // 0x20
1728
                // Byte 1 = length of string
1757
                // Byte 1 = length of string
1729
                // Byte 2 = red channel
1758
                // Byte 2 = red channel
1730
                // Byte 3 = green channel
1759
                // Byte 3 = green channel
1731
                // Byte 4 = blue channel
1760
                // Byte 4 = blue channel
1732
                // Byte 5 = update speed (ms)
1761
                // Byte 5 = update speed (ms)
1733
                // Byte 6+ = text string
1762
                // Byte 6+ = text string
1734
                if (buffer[1] != 0) {
1763
                if (buffer[1] != 0) {
1735
                    Cube_Text_Init(&buffer[6], buffer[1], buffer[2], buffer[3], buffer[4]);
-
 
1736
 
-
 
1737
                    TIMER4_Stop();
1764
                    TIMER4_Stop();
-
 
1765
                    Cube_Text_Init(&buffer[6], buffer[1], buffer[2], buffer[3], buffer[4]);
1738
                    TIMER4_Init(NULL, NULL, &Cube_Text_Interrupt, buffer[5]);
1766
                    TIMER4_Init(NULL, NULL, &Cube_Text_Interrupt, buffer[5]);
1739
                    TIMER4_Start();
1767
                    TIMER4_Start();
1740
                } else {
1768
                } else {
-
 
1769
                    TIMER4_Stop();
1741
                    Cube_Overlay_Clear();
1770
                    Cube_Overlay_Clear();
-
 
1771
                }
-
 
1772
            } else if (buffer[0] == CUBE_ETH_WRITE_TEXT_STATIC) {   // 0x21
-
 
1773
                // Byte 1 = length of string
-
 
1774
                // Byte 2 = red channel
-
 
1775
                // Byte 3 = green channel
-
 
1776
                // Byte 4 = blue channel
-
 
1777
                // Byte 5+ = text string
-
 
1778
                if (buffer[1] != 0) {
1742
                    TIMER4_Stop();
1779
                    TIMER4_Stop();
-
 
1780
                    Cube_Text_Init(&buffer[5], buffer[1], buffer[2], buffer[3], buffer[4]);
-
 
1781
                    for (i = 0; i < buffer[1] * 5; i++) {
-
 
1782
                        Cube_Text_Update();
-
 
1783
                    }
-
 
1784
                } else {
-
 
1785
                    TIMER4_Stop();
-
 
1786
                    Cube_Overlay_Clear();
1743
                }
1787
                }
-
 
1788
            } else if (buffer[0] == CUBE_EHT_WRITE_TEXT_INSERT) {   // 0x22
-
 
1789
                // Byte 1 = red channel
-
 
1790
                // Byte 2 = green channel
-
 
1791
                // Byte 3 = blue channel
-
 
1792
                // Byte 4 = character
-
 
1793
                TIMER4_Stop();
-
 
1794
                Cube_Text_Insert(buffer[4], buffer[1], buffer[2], buffer[3]);
1744
            } else if (buffer[0] == CUBE_ETH_WATERFALL) {       // 0x30
1795
            } else if (buffer[0] == CUBE_ETH_WATERFALL) {       // 0x30
1745
                // Byte 1 = height of column 0
1796
                // Byte 1 = height of column 0
1746
                // Byte 2 = height of column 1
1797
                // Byte 2 = height of column 1
1747
                // Byte 3 = height of column 2
1798
                // Byte 3 = height of column 2
1748
                // Byte 4 = height of column 3
1799
                // Byte 4 = height of column 3