Subversion Repositories Code-Repo

Rev

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

Rev 261 Rev 263
Line 115... Line 115...
115
void Cube_Write_DCS(uint8_t BC) {
115
void Cube_Write_DCS(uint8_t BC) {
116
    XBLNK = 0;
116
    XBLNK = 0;
117
    uint8_t i,j;
117
    uint8_t i,j;
118
    // Write configuration data to the DC/BC/FC/UD registers
118
    // Write configuration data to the DC/BC/FC/UD registers
119
    uint8_t DCS[GCS_LAYER_SIZE] = {0};
119
    uint8_t DCS[GCS_LAYER_SIZE] = {0};
-
 
120
 
120
    for (i = 0; i < 8; i++) {
121
    for (i = 0; i < 8; i++) {
121
        uint16_t offset = i * GCS_REG_SIZE;
122
        uint16_t offset = i * GCS_REG_SIZE;
122
 
123
 
123
        for (j = 0; j < 21; j++) {
124
        for (j = 0; j < 21; j++) {
124
            DCS[offset + j] = 0xFF; // Dot correction
125
            DCS[offset + j] = 0xFF; // Dot correction
125
        }
126
        }
126
 
127
 
127
        // Warning: do not set BC > 0x6F
128
        // Warning: do not set BC > 0x6F ?? NEED TO VERIFY THIS !!
128
        DCS[offset + 21] = BC; // Global red brightness
129
        DCS[offset + 21] = BC; // Global red brightness
129
        DCS[offset + 22] = BC; // Global green brightness
130
        DCS[offset + 22] = BC; // Global green brightness
130
        DCS[offset + 23] = BC; // Global blue brightness
131
        DCS[offset + 23] = BC; // Global blue brightness
131
 
132
 
132
        // DC low range, auto repeat, no timing reset, 8 bit counter mode
133
        // DC low range, auto repeat, no timing reset, 8 bit counter mode
Line 853... Line 854...
853
    uint16_t index = 1;
854
    uint16_t index = 1;
854
 
855
 
855
    // Read and process the ethernet packet
856
    // Read and process the ethernet packet
856
    if (!ETH_Read_Packet(buffer, &length)) {
857
    if (!ETH_Read_Packet(buffer, &length)) {
857
        // Check the opcode (first byte) to determine what to do
858
        // Check the opcode (first byte) to determine what to do
-
 
859
 
858
        if (buffer[0] == 0x1) {
860
        if (buffer[0] == 0x1) {                 // 0x1 - Reset into Ethernet mode
859
            Reset_Board(BOARD_MODE_ETHERNET);
861
            Reset_Board(BOARD_MODE_ETHERNET);
860
        }
-
 
861
        if (buffer[0] == 0x2) {
862
        } else if (buffer[0] == 0x2) {          // 0x2 - Reset back to idle mode
862
            Reset_Board(BOARD_MODE_IDLE);
863
            Reset_Board(BOARD_MODE_IDLE);
863
        }
-
 
864
        if (buffer[0] == 0xA) {
864
        } else if (buffer[0] == 0xA) {          // 0xA - Clear the entire cube
865
            Cube_Clear();
865
            Cube_Clear();
-
 
866
        } else if (buffer[0] == 0xB) {          // 0xB - Set the global brightness value
866
        }
867
            Cube_Write_DCS(buffer[1]);
867
        if (buffer[0] == 0xB) {
868
        } else if (buffer[0] == 0xC) {          // 0xC - Set the entire cube
868
            ClearWDT();
869
            if (length == 0x0601) {
869
            // Update the cube
870
                ClearWDT();
870
            for (i = 0; i < CUBE_LAYER_COUNT; i++) {
871
                for (i = 0; i < CUBE_LAYER_COUNT; i++) {
871
                for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
872
                    for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
872
                    for (k = 0; k < CUBE_ROW_COUNT; k++) {
873
                        for (k = 0; k < CUBE_ROW_COUNT; k++) {
873
                        Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]);
874
                            Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]);
874
                        index = index + 3;
875
                            index = index + 3;
-
 
876
                        }
875
                    }
877
                    }
876
                }
878
                }
877
            }
879
            }
-
 
880
        } else if (buffer[0] == 0xD) {          // 0xD - Rotate the cube
-
 
881
            Cube_Rotate(buffer[1]);
-
 
882
        } else if (buffer[0] == 0xE) {          // 0xE - Rotate a layer
-
 
883
            Cube_Rotate_Shell(buffer[1], buffer[2]);
878
        }
884
        }
879
    }
885
    }
880
}
886
}
881
887