Subversion Repositories Code-Repo

Rev

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

Rev 266 Rev 268
Line 303... Line 303...
303
    Cube_Set_Pixel(layer2, row2, column2, prev_R, prev_G, prev_B);
303
    Cube_Set_Pixel(layer2, row2, column2, prev_R, prev_G, prev_B);
304
}
304
}
305
 
305
 
306
void Cube_Set_Sphere(uint8_t layer, uint8_t R, uint8_t G, uint8_t B) {
306
void Cube_Set_Sphere(uint8_t layer, uint8_t R, uint8_t G, uint8_t B) {
307
    // Super code inefficient (or is it?) lookup table
307
    // Super code inefficient (or is it?) lookup table
308
    switch (layer) {
308
    switch (layer % 9) {
309
        case 0:
309
        case 0:
310
            Cube_Set_Pixel(3, 3, 3, R, G, B);
310
            Cube_Set_Pixel(3, 3, 3, R, G, B);
311
            Cube_Set_Pixel(3, 3, 4, R, G, B);
311
            Cube_Set_Pixel(3, 3, 4, R, G, B);
312
            Cube_Set_Pixel(3, 4, 3, R, G, B);
312
            Cube_Set_Pixel(3, 4, 3, R, G, B);
313
            Cube_Set_Pixel(3, 4, 4, R, G, B);
313
            Cube_Set_Pixel(3, 4, 4, R, G, B);
Line 1170... Line 1170...
1170
    Cube_Shift_Row(0);
1170
    Cube_Shift_Row(0);
1171
 
1171
 
1172
    // Then update the empty row
1172
    // Then update the empty row
1173
    for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
1173
    for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
1174
        for (j = 0; j < CUBE_LAYER_COUNT; j++) {
1174
        for (j = 0; j < CUBE_LAYER_COUNT; j++) {
1175
            if (j < values[i]) {
1175
            if (j < values[i] % 9) {
1176
                // Specify the color for each column
1176
                // Specify the color for each column
1177
                if (i == 0)
1177
                if (i == 0)
1178
                    Cube_Set_Pixel(j, update_row, i, RED);
1178
                    Cube_Set_Pixel(j, update_row, i, RED);
1179
                else if (i == 1)
1179
                else if (i == 1)
1180
                    Cube_Set_Pixel(j, update_row, i, ORANGE);
1180
                    Cube_Set_Pixel(j, update_row, i, ORANGE);
Line 1207... Line 1207...
1207
    Cube_Shift_Row(0);
1207
    Cube_Shift_Row(0);
1208
 
1208
 
1209
    // Then update the empty row
1209
    // Then update the empty row
1210
    for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
1210
    for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
1211
        for (j = 0; j < CUBE_LAYER_COUNT; j++) {
1211
        for (j = 0; j < CUBE_LAYER_COUNT; j++) {
1212
            if (j < values[i]) {
1212
            if (j < values[i] % 9) {
1213
                // Specify the color for each layer
1213
                // Specify the color for each layer
1214
                if (j == 7)
1214
                if (j == 7)
1215
                    Cube_Set_Pixel(j, update_row, i, RED);
1215
                    Cube_Set_Pixel(j, update_row, i, RED);
1216
                else if (j == 6)
1216
                else if (j == 6)
1217
                    Cube_Set_Pixel(j, update_row, i, ORANGE);
1217
                    Cube_Set_Pixel(j, update_row, i, ORANGE);
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) {
1535
void Cube_Text_Insert(uint8_t c, uint16_t R, uint16_t G, uint16_t B, uint16_t delay) {
-
 
1536
    // Save the character to insert
-
 
1537
    cube_data_ptr->string[0] = c;
-
 
1538
    cube_data_ptr->string_length = 1;
-
 
1539
    cube_data_ptr->string_line = 0;
-
 
1540
    cube_data_ptr->string_R = R;
-
 
1541
    cube_data_ptr->string_G = G;
-
 
1542
    cube_data_ptr->string_B = B;
-
 
1543
 
-
 
1544
    if (delay == 0) {
-
 
1545
        int i;
-
 
1546
        for (i = 0; i < 6; i++) {
-
 
1547
            Cube_Text_Single_Char_Interupt();
-
 
1548
        }
-
 
1549
    } else {
-
 
1550
        // Start a timer to update the overlay with the inserted character
-
 
1551
        TIMER4_Stop();
-
 
1552
        TIMER4_Init(NULL, NULL, &Cube_Text_Single_Char_Interupt, delay);
-
 
1553
        TIMER4_Start();
-
 
1554
    }
-
 
1555
}
-
 
1556
 
-
 
1557
void Cube_Text_Single_Char_Interupt(void) {
1536
    uint8_t layer;
1558
    uint8_t layer;
1537
    uint8_t line = 0;
-
 
1538
    uint8_t i;
1559
    uint8_t line;
1539
 
1560
 
1540
    // Insert a single character to the overlay text
1561
    // Rotate before drawing the new line at (0,0)
1541
    for (i = 0; i < 6; i++) {
1562
    Cube_Overlay_Rotate_Shell(0, 0);
1542
 
1563
 
1543
        // Rotate before drawing the new line at (0,0)
1564
    // Get the next vertical line of the character currently being drawn
1544
        Cube_Overlay_Rotate_Shell(0, 0);
1565
    if (cube_data_ptr->string_line == 0) {
-
 
1566
        line = 0x0; // Leave a space between characters
-
 
1567
    } else {
-
 
1568
        line = font[(cube_data_ptr->string[0] * 5) + cube_data_ptr->string_line - 1];
-
 
1569
    }
1545
 
1570
 
1546
        // Get the next vertical line of the character currently being drawn
1571
    // Draw the line onto (0,0) using the specified color
-
 
1572
    for (layer = 8; layer != 0; layer--) {
1547
        if (i == 0) {
1573
        if (line & 0x1) {
-
 
1574
            Cube_Overlay_Set_Pixel(layer-1, 0, 0, cube_data_ptr->string_R,
1548
            line = 0x0; // Leave a space between characters
1575
                    cube_data_ptr->string_G, cube_data_ptr->string_B);
1549
        } else {
1576
        } else {
1550
            line = font[(c * 5) + i - 1];
1577
            Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
1551
        }
1578
        }
-
 
1579
        line >>= 1;
-
 
1580
    }
1552
 
1581
 
1553
        // Draw the line onto (0,0) using the specified color
1582
    // Increment the vertical line or stop the timer as needed
1554
        for (layer = 8; layer != 0; layer--) {
1583
    if (cube_data_ptr->string_line == 5) {
1555
            if (line & 0x1) {
-
 
1556
                Cube_Overlay_Set_Pixel(layer-1, 0, 0, R, G, B);
-
 
1557
            } else {
1584
        TIMER4_Stop();
1558
                Cube_Overlay_Set_Pixel(layer-1, 0, 0, 0x00, 0x00, 0x00);
-
 
1559
            }
1585
    } else {
1560
            line >>= 1;
1586
        cube_data_ptr->string_line += 1;
1561
        }
-
 
1562
    }
1587
    }
1563
}
1588
}
1564
 
1589
 
1565
void Cube_Text_Interrupt(void) {
1590
void Cube_Text_Interrupt(void) {
1566
    Cube_Text_Update();
1591
    Cube_Text_Update();
Line 1787... Line 1812...
1787
                }
1812
                }
1788
            } else if (buffer[0] == CUBE_EHT_WRITE_TEXT_INSERT) {   // 0x22
1813
            } else if (buffer[0] == CUBE_EHT_WRITE_TEXT_INSERT) {   // 0x22
1789
                // Byte 1 = red channel
1814
                // Byte 1 = red channel
1790
                // Byte 2 = green channel
1815
                // Byte 2 = green channel
1791
                // Byte 3 = blue channel
1816
                // Byte 3 = blue channel
-
 
1817
                // Byte 4 = delay x6 between shifts
1792
                // Byte 4 = character
1818
                // Byte 5 = character
1793
                TIMER4_Stop();
1819
                TIMER4_Stop();
1794
                Cube_Text_Insert(buffer[4], buffer[1], buffer[2], buffer[3]);
1820
                Cube_Text_Insert(buffer[5], buffer[1], buffer[2], buffer[3], buffer[4]);
1795
            } else if (buffer[0] == CUBE_ETH_WATERFALL) {       // 0x30
1821
            } else if (buffer[0] == CUBE_ETH_WATERFALL) {       // 0x30
1796
                // Byte 1 = height of column 0
1822
                // Byte 1 = height of column 0
1797
                // Byte 2 = height of column 1
1823
                // Byte 2 = height of column 1
1798
                // Byte 3 = height of column 2
1824
                // Byte 3 = height of column 2
1799
                // Byte 4 = height of column 3
1825
                // Byte 4 = height of column 3