Subversion Repositories Code-Repo

Rev

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

Rev 216 Rev 226
Line 18... Line 18...
18
#pragma config UPLLEN    = ON       // USB PLL Enable
18
#pragma config UPLLEN    = ON       // USB PLL Enable
19
#pragma config UPLLIDIV  = DIV_2    // USB PLL Input Divider
19
#pragma config UPLLIDIV  = DIV_2    // USB PLL Input Divider
20
#pragma config FVBUSONIO = OFF      // USB VBUS ON Selection
20
#pragma config FVBUSONIO = OFF      // USB VBUS ON Selection
21
#pragma config FUSBIDIO  = OFF      // USB USID Selection
21
#pragma config FUSBIDIO  = OFF      // USB USID Selection
22
/* Other Peripheral Device Settings */
22
/* Other Peripheral Device Settings */
23
#pragma config FWDTEN    = OFF      // Watchdog Timer Enable
23
#pragma config FWDTEN    = ON       // Watchdog Timer Enable
24
#pragma config WDTPS     = PS1024   // Watchdog Timer Postscaler
24
#pragma config WDTPS     = PS1048576    // Watchdog Timer Postscaler (1048.576s)
25
#pragma config FSRSSEL   = PRIORITY_7   // SRS Interrupt Priority
25
#pragma config FSRSSEL   = PRIORITY_7   // SRS Interrupt Priority
26
#pragma config FCANIO    = OFF      // CAN I/O Pin Select (default/alternate)
26
#pragma config FCANIO    = OFF      // CAN I/O Pin Select (default/alternate)
27
#pragma config FETHIO    = ON       // Ethernet I/O Pin Select (default/alternate)
27
#pragma config FETHIO    = ON       // Ethernet I/O Pin Select (default/alternate)
28
#pragma config FMIIEN    = OFF      // Ethernet MII/RMII select (OFF=RMII)
28
#pragma config FMIIEN    = OFF      // Ethernet MII/RMII select (OFF=RMII)
29
/* Code Protection Settings */
29
/* Code Protection Settings */
Line 39... Line 39...
39
#include <plib.h>
39
#include <plib.h>
40
#include <stdlib.h>
40
#include <stdlib.h>
41
#include "defines.h"
41
#include "defines.h"
42
#include "UART1.h"
42
#include "UART1.h"
43
#include "SPI1.h"
43
#include "SPI1.h"
-
 
44
#include "SPI4.h"
44
#include "TIMER4.h"
45
#include "TIMER4.h"
45
#include "TIMER5.h"
46
#include "TIMER5.h"
46
#include "CUBE.h"
47
#include "CUBE.h"
47
#include "BTN.h"
48
#include "BTN.h"
-
 
49
#include "ANIMATIONS.h"
48
 
50
 
49
void BTN1_Interrupt(void);
51
void BTN1_Interrupt(void);
50
void BTN2_Interrupt(void);
52
void BTN2_Interrupt(void);
51
void BTN3_Interrupt(void);
53
void BTN3_Interrupt(void);
52
void Animation_Solid_Colors(int iterations, int delay_ms);
-
 
53
void Animation_Layer_Alternate(int iterations, int delay_ms);
-
 
54
void Animation_Pixel_Alternate(int iterations, int delay_ms);
-
 
55
void Animation_Full_Color_Sweep(int iterations, int delay_us);
-
 
56
void Animation_Row_Column_Sweep(int iterations, int delay_ms);
-
 
57
void Animation_Pixel_Sweep(int iterations, int delay_ms);
-
 
58
void Animation_Pseudo_Random_Colors(int iterations,int delay_ms);
-
 
59
void Animation_Random_Colors(int iterations, int delay_ms);
-
 
60
void Animation_Cube_In_Cube(int iterations, int delay_ms);
-
 
61
void Animation_Double_Rotation(int iterations, int delay_ms);
-
 
62
 
54
 
63
void Delay_MS(unsigned int delay_ms) {
55
void Delay_MS(unsigned int delay_ms) {
64
    // Delays the CPU for the given amount of time.
56
    // Delays the CPU for the given amount of time.
65
    // Note: Watch out for integer overflow! (max delay_ms = 107374) ??
57
    // Note: Watch out for integer overflow! (max delay_ms = 107374) ??
66
    unsigned int delay = delay_ms * MS_TO_CT_TICKS;
58
    unsigned int delay = delay_ms * MS_TO_CT_TICKS;
Line 75... Line 67...
75
    unsigned int startTime = ReadCoreTimer();
67
    unsigned int startTime = ReadCoreTimer();
76
    while ((unsigned int)(ReadCoreTimer() - startTime) < delay) {};
68
    while ((unsigned int)(ReadCoreTimer() - startTime) < delay) {};
77
}
69
}
78
 
70
 
79
int main() {
71
int main() {
-
 
72
    // WARNING!! THIS BOARD WILL RESET EVERY 1048.576s DUE TO THE WDT!!
-
 
73
    
80
    /* Configure the target for maximum performance at 80 MHz. */
74
    /* Configure the target for maximum performance at 80 MHz. */
81
    // Note: This overrides the peripheral clock to 80Mhz regardless of config
75
    // Note: This overrides the peripheral clock to 80Mhz regardless of config
82
    SYSTEMConfigPerformance(CPU_CLOCK_HZ);
76
    SYSTEMConfigPerformance(CPU_CLOCK_HZ);
83
 
77
 
84
    // Configure the interrupts for multiple vectors
78
    // Configure the interrupts for multiple vectors
Line 86... Line 80...
86
 
80
 
87
    // Set all analog I/O pins to digital
81
    // Set all analog I/O pins to digital
88
    AD1PCFGSET = 0xFFFF;
82
    AD1PCFGSET = 0xFFFF;
89
 
83
 
90
    // Initialize the SPI1 module
84
    // Initialize the SPI1 module
91
    SPI1_DATA spi_data;
85
    SPI1_DATA spi_1_data;
92
    SPI1_Init(&spi_data, NULL);
86
    SPI1_Init(&spi_1_data, NULL);
-
 
87
 
-
 
88
    // Initialize the SPI4 module
-
 
89
    SPI4_DATA spi_4_data;
-
 
90
    SPI4_Init(&spi_4_data);
93
 
91
 
94
    // Initialize the UART1 module
92
    // Initialize the UART1 module
95
    UART1_DATA uart_data;
93
    UART1_DATA uart_data;
96
    UART1_Init(&uart_data, &Cube_Data_In);
94
    UART1_Init(&uart_data, &Cube_Data_In);
97
 
95
 
Line 109... Line 107...
109
    TIMER5_Init(&timer_5_data, &Cube_Timer_Interrupt, 500);
107
    TIMER5_Init(&timer_5_data, &Cube_Timer_Interrupt, 500);
110
    TIMER5_Start();
108
    TIMER5_Start();
111
 
109
 
112
    // Start the overlay rotation interrupt
110
    // Start the overlay rotation interrupt
113
    TIMER4_DATA timer_4_data;
111
    TIMER4_DATA timer_4_data;
114
    TIMER4_Init(&timer_4_data, &Cube_Text_Interrupt, 120000);
112
    TIMER4_Init(&timer_4_data, &Cube_Text_Interrupt, 90000);
115
 
113
 
116
    // Process button inputs
114
    // Process button inputs
117
    BTN_DATA btn_data;
115
    BTN_DATA btn_data;
118
    BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, &BTN3_Interrupt);
116
    BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, &BTN3_Interrupt);
119
    
117
    
120
    // Begin display
118
    // Begin display
121
 
119
 
122
//    Cube_Set_All(RED);
120
//    Cube_Set_All(RED);
123
//    Delay_MS(6000);
121
//    Delay_MS(2000);
124
//    Cube_Set_All(GREEN);
122
//    Cube_Set_All(GREEN);
125
//    Delay_MS(6000);
123
//    Delay_MS(2000);
126
//    Cube_Set_All(BLUE);
124
//    Cube_Set_All(BLUE);
127
//    Delay_MS(6000);
125
//    Delay_MS(2000);
-
 
126
//    Animation_Pseudo_Random_Colors(10,300);
128
 
127
 
129
//    char start_text[] = "Cube Initialized\r\n";
128
//    char start_text[] = "Cube Initialized\r\n";
130
//    UART1_Write(start_text, 18);
129
//    UART1_Write(start_text, 18);
131
 
130
 
132
    // Set the overlay text
131
    // Set the overlay text
133
    char text_string[] = "Welcome to the CCM Lab    ";
132
    char text_string[] = "Welcome to the AMP Lab     ";
134
    Cube_Text_Init(text_string, 26, 0xFF, 0xFF, 0xFF);
133
    Cube_Text_Init(text_string, 27, 0xFF, 0xFF, 0xFF);
135
    TIMER4_Start();
134
    TIMER4_Start();
136
 
135
 
137
    // Loop through some preset animations
136
    // Loop through some preset animations
138
    while(1) {
137
    while(1) {
139
//        Animation_Solid_Colors(2,300);
138
//        Animation_Solid_Colors(2,300);
Line 141... Line 140...
141
//        Animation_Pixel_Alternate(1,200);
140
//        Animation_Pixel_Alternate(1,200);
142
//        Animation_Full_Color_Sweep(2,1000);
141
//        Animation_Full_Color_Sweep(2,1000);
143
        Animation_Row_Column_Sweep(2,40);
142
        Animation_Row_Column_Sweep(2,40);
144
        Animation_Cube_In_Cube(4,300);
143
        Animation_Cube_In_Cube(4,300);
145
        Animation_Double_Rotation(2,40);
144
        Animation_Double_Rotation(2,40);
146
        Animation_Pseudo_Random_Colors(10,300);
145
//        Animation_Pseudo_Random_Colors(10,300);
147
//        Animation_Random_Colors(10,300);
146
//        Animation_Random_Colors(10,300);
-
 
147
 
-
 
148
//        ClearWDT(); // Clear the WDT if we dont want the board to reset
148
    }
149
    }
149
}
150
}
150
 
151
 
151
// Function call on button 1 press to change refresh rate
152
// Function call on button 1 press to change refresh rate
152
void BTN1_Interrupt(void) {
153
void BTN1_Interrupt(void) {
Line 229... Line 230...
229
            TIMER4_Init(NULL, &Cube_Text_Interrupt, 90000);
230
            TIMER4_Init(NULL, &Cube_Text_Interrupt, 90000);
230
            break;
231
            break;
231
    }
232
    }
232
    TIMER4_Start();
233
    TIMER4_Start();
233
}
234
}
234
 
-
 
235
void Animation_Solid_Colors(int iterations, int delay_ms) {
-
 
236
    int i;
-
 
237
    for (i = 0; i < iterations; i++) {
-
 
238
        Cube_Set_All(RED);
-
 
239
        Delay_MS(delay_ms);
-
 
240
        Cube_Set_All(GREEN);
-
 
241
        Delay_MS(delay_ms);
-
 
242
        Cube_Set_All(BLUE);
-
 
243
        Delay_MS(delay_ms);
-
 
244
    }
-
 
245
}
-
 
246
 
-
 
247
void Animation_Layer_Alternate(int iterations, int delay_ms) {
-
 
248
    int i,z;
-
 
249
    for (z = 0; z < iterations; z++) {
-
 
250
        for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
251
            if (i % 3 == 0)
-
 
252
                Cube_Set_Layer(i,RED);
-
 
253
            else if (i % 3 == 1)
-
 
254
                Cube_Set_Layer(i,GREEN);
-
 
255
            else
-
 
256
                Cube_Set_Layer(i,BLUE);
-
 
257
        }
-
 
258
        Delay_MS(delay_ms);
-
 
259
        for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
260
            if (i % 3 == 0)
-
 
261
                Cube_Set_Layer(i,GREEN);
-
 
262
            else if (i % 3 == 1)
-
 
263
                Cube_Set_Layer(i,BLUE);
-
 
264
            else
-
 
265
                Cube_Set_Layer(i,RED);
-
 
266
        }
-
 
267
        Delay_MS(delay_ms);
-
 
268
        for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
269
            if (i % 3 == 0)
-
 
270
                Cube_Set_Layer(i,BLUE);
-
 
271
            else if (i % 3 == 1)
-
 
272
                Cube_Set_Layer(i,RED);
-
 
273
            else
-
 
274
                Cube_Set_Layer(i,GREEN);
-
 
275
        }
-
 
276
        Delay_MS(delay_ms);
-
 
277
    }
-
 
278
}
-
 
279
 
-
 
280
void Animation_Pixel_Alternate(int iterations, int delay_ms) {
-
 
281
    int i,j,k,z;
-
 
282
    for (z = 0; z < iterations; z++) {
-
 
283
        for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
284
            Cube_Clear();
-
 
285
            for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
286
                for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
287
                    int var = (j * 8) + k;
-
 
288
                    if (var % 3 == 0)
-
 
289
                        Cube_Set_Pixel(i,j,k,RED);
-
 
290
                    else if (var % 3 == 1)
-
 
291
                        Cube_Set_Pixel(i,j,k,GREEN);
-
 
292
                    else
-
 
293
                        Cube_Set_Pixel(i,j,k,BLUE);
-
 
294
                }
-
 
295
            }
-
 
296
            Delay_MS(delay_ms);
-
 
297
            Cube_Clear();
-
 
298
            for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
299
                for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
300
                    int var = (j * 8) + k;
-
 
301
                    if (var % 3 == 0)
-
 
302
                        Cube_Set_Pixel(i,j,k,GREEN);
-
 
303
                    else if (var % 3 == 1)
-
 
304
                        Cube_Set_Pixel(i,j,k,BLUE);
-
 
305
                    else
-
 
306
                        Cube_Set_Pixel(i,j,k,RED);
-
 
307
                }
-
 
308
            }
-
 
309
            Delay_MS(delay_ms);
-
 
310
            Cube_Clear();
-
 
311
            for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
312
                for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
313
                    int var = (j * 8) + k;
-
 
314
                    if (var % 3 == 0)
-
 
315
                        Cube_Set_Pixel(i,j,k,BLUE);
-
 
316
                    else if (var % 3 == 1)
-
 
317
                        Cube_Set_Pixel(i,j,k,RED);
-
 
318
                    else
-
 
319
                        Cube_Set_Pixel(i,j,k,GREEN);
-
 
320
                }
-
 
321
            }
-
 
322
            Delay_MS(delay_ms);
-
 
323
        }
-
 
324
    }
-
 
325
}
-
 
326
 
-
 
327
void Animation_Full_Color_Sweep(int iterations, int delay_us) {
-
 
328
    int i,z;
-
 
329
    for (z = 0; z < iterations; z++) {
-
 
330
        for (i = 0; i < 0x0FF; i+=2) {
-
 
331
            Cube_Set_All(i,0,0);
-
 
332
            Delay_US(delay_us);
-
 
333
        }
-
 
334
        for (i = 0; i < 0x0FF; i+=2) {
-
 
335
            Cube_Set_All(0x0FF,i,0);
-
 
336
            Delay_US(delay_us);
-
 
337
        }
-
 
338
        for (i = 0x0FF; i >= 0; i-=2) {
-
 
339
            Cube_Set_All(i,0x0FF,0);
-
 
340
            Delay_US(delay_us);
-
 
341
        }
-
 
342
        for (i = 0; i < 0x0FF; i+=2) {
-
 
343
            Cube_Set_All(0,0x0FF,i);
-
 
344
            Delay_US(delay_us);
-
 
345
        }
-
 
346
        for (i = 0; i < 0x0FF; i+=2) {
-
 
347
            Cube_Set_All(i,0x0FF,0x0FF);
-
 
348
            Delay_US(delay_us);
-
 
349
        }
-
 
350
        for (i = 0x0FF; i >= 0; i-=2) {
-
 
351
            Cube_Set_All(0x0FF,i,0x0FF);
-
 
352
            Delay_US(delay_us);
-
 
353
        }
-
 
354
        for (i = 0x0FF; i >= 0; i-=2) {
-
 
355
            Cube_Set_All(i,0,0x0FF);
-
 
356
            Delay_US(delay_us);
-
 
357
        }
-
 
358
        for (i = 0x100; i >= 0; i-=2) {
-
 
359
            Cube_Set_All(0,0,i);
-
 
360
            Delay_US(delay_us);
-
 
361
        }
-
 
362
    }
-
 
363
}
-
 
364
 
-
 
365
void Animation_Row_Column_Sweep(int iterations, int delay_ms) {
-
 
366
    int i,j,k,a,z;
-
 
367
    for (z = 0; z < iterations; z++) {
-
 
368
        for (i = 0; i < 3; i++) {
-
 
369
            for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
370
                Cube_Clear();
-
 
371
                for (k = 0; k < CUBE_COLUMN_COUNT; k++)
-
 
372
                    if (i % 3 == 0)
-
 
373
                        for (a = 0; a < CUBE_LAYER_COUNT; a++)
-
 
374
                            Cube_Set_Pixel(a,j,k,RED);
-
 
375
                    else if (i % 3 == 1)
-
 
376
                        for (a = 0; a < CUBE_LAYER_COUNT; a++)
-
 
377
                            Cube_Set_Pixel(a,j,k,GREEN);
-
 
378
                    else
-
 
379
                        for (a = 0; a < CUBE_LAYER_COUNT; a++)
-
 
380
                            Cube_Set_Pixel(a,j,k,BLUE);
-
 
381
                Delay_MS(delay_ms);
-
 
382
            }
-
 
383
            for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
384
                Cube_Clear();
-
 
385
                for (k = 0; k < CUBE_COLUMN_COUNT; k++)
-
 
386
                    if (i % 3 == 0)
-
 
387
                        for (a = 0; a < CUBE_LAYER_COUNT; a++)
-
 
388
                            Cube_Set_Pixel(a,k,j,RED);
-
 
389
                    else if (i % 3 == 1)
-
 
390
                        for (a = 0; a < CUBE_LAYER_COUNT; a++)
-
 
391
                            Cube_Set_Pixel(a,k,j,GREEN);
-
 
392
                    else
-
 
393
                        for (a = 0; a < CUBE_LAYER_COUNT; a++)
-
 
394
                            Cube_Set_Pixel(a,k,j,BLUE);
-
 
395
                Delay_MS(delay_ms);
-
 
396
            }
-
 
397
            for (j = CUBE_LAYER_COUNT-1; j >= 0; j--) {
-
 
398
                Cube_Clear();
-
 
399
                if (i % 3 == 0) {
-
 
400
                    for (k = 0; k < CUBE_LAYER_COUNT; k++)
-
 
401
                        if (k == j)
-
 
402
                            Cube_Set_Layer(k,RED);
-
 
403
                } else if (i % 3 == 1) {
-
 
404
                    for (k = 0; k < CUBE_LAYER_COUNT; k++)
-
 
405
                        if (k == j)
-
 
406
                            Cube_Set_Layer(k,GREEN);
-
 
407
                } else {
-
 
408
                    for (k = 0; k < CUBE_LAYER_COUNT; k++)
-
 
409
                        if (k == j)
-
 
410
                            Cube_Set_Layer(k,BLUE);
-
 
411
                }
-
 
412
                Delay_MS(delay_ms);
-
 
413
            }
-
 
414
        }
-
 
415
    }
-
 
416
}
-
 
417
 
-
 
418
void Animation_Pixel_Sweep(int iterations, int delay_ms) {
-
 
419
    int i,j,k,z,a;
-
 
420
    for (z = 0; z < iterations; z++) {
-
 
421
        for (a = 0; a < 3; a++) {
-
 
422
            for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
423
                for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
424
                    for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
425
                        Cube_Clear();
-
 
426
                        if (a % 3 == 0) {
-
 
427
                            Cube_Set_Pixel(i,j,k,RED);
-
 
428
                        } else if (a % 3 == 1) {
-
 
429
                            Cube_Set_Pixel(i,j,k,GREEN);
-
 
430
                        } else {
-
 
431
                            Cube_Set_Pixel(i,j,k,BLUE);
-
 
432
                        }
-
 
433
                        Delay_MS(delay_ms);
-
 
434
                    }
-
 
435
                }
-
 
436
            }
-
 
437
        }
-
 
438
    }
-
 
439
}
-
 
440
 
-
 
441
void Animation_Pseudo_Random_Colors(int iterations, int delay_ms) {
-
 
442
    int i,j,k,z;
-
 
443
    for (z = 0; z < iterations; z++) {
-
 
444
        for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
445
            for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
446
                for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
447
                    unsigned int a = rand();
-
 
448
                    if (a % 5 == 0)
-
 
449
                        Cube_Set_Pixel(i,j,k,RED);
-
 
450
                    else if (a % 5 == 1)
-
 
451
                        Cube_Set_Pixel(i,j,k,GREEN);
-
 
452
                    else if (a % 5 == 2)
-
 
453
                        Cube_Set_Pixel(i,j,k,BLUE);
-
 
454
                    else if (a % 5 == 3)
-
 
455
                        Cube_Set_Pixel(i,j,k,PURPLE);
-
 
456
                    else if (a % 5 == 4)
-
 
457
                        Cube_Set_Pixel(i,j,k,YELLOW);
-
 
458
                    else
-
 
459
                        Cube_Set_Pixel(i,j,k,ORANGE);
-
 
460
                }
-
 
461
            }
-
 
462
        }
-
 
463
        Delay_MS(delay_ms);
-
 
464
    }
-
 
465
}
-
 
466
 
-
 
467
void Animation_Random_Colors(int iterations, int delay_ms) {
-
 
468
    int i,j,k,z;
-
 
469
    for (z = 0; z < iterations; z++) {
-
 
470
        for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
471
            for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
472
                for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
473
                    Cube_Set_Pixel(i,j,k,rand()&0x0FF,rand()&0x0FF,rand()&0x0FF);
-
 
474
                }
-
 
475
            }
-
 
476
        }
-
 
477
        Delay_MS(delay_ms);
-
 
478
    }
-
 
479
}
-
 
480
 
-
 
481
void Animation_Cube_In_Cube(int iterations, int delay_ms) {
-
 
482
    int z,x,i,j,k;
-
 
483
    for (z = 0; z < iterations; z++) {
-
 
484
        for (x = 0; x < 5; x++) {
-
 
485
            Cube_Clear();
-
 
486
            for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
487
                if ((x == 0 || x == 4)&&(i == 0 || i == 7)) {
-
 
488
                    Cube_Set_Layer(i,RED);
-
 
489
                } else if ((x == 1 || x == 4)&&(i == 1 || i == 6)) {
-
 
490
                    for (j = 1; j < CUBE_ROW_COUNT-1; j++)
-
 
491
                        for (k = 1; k < CUBE_COLUMN_COUNT-1; k++)
-
 
492
                            Cube_Set_Pixel(i,j,k,YELLOW);
-
 
493
                } else if ((x == 2 || x == 4)&&(i == 2 || i == 5)) {
-
 
494
                    for (j = 2; j < CUBE_ROW_COUNT-2; j++)
-
 
495
                        for (k = 2; k < CUBE_COLUMN_COUNT-2; k++)
-
 
496
                            Cube_Set_Pixel(i,j,k,GREEN);
-
 
497
                } else if ((x == 3 || x == 4)&&(i == 3 || i == 4)) {
-
 
498
                    for (j = 3; j < CUBE_ROW_COUNT-3; j++)
-
 
499
                        for (k = 3; k < CUBE_COLUMN_COUNT-3; k++)
-
 
500
                            Cube_Set_Pixel(i,j,k,BLUE);
-
 
501
                }
-
 
502
 
-
 
503
                if ((x == 0 || x == 4)&&(i > 0 && i < 8)) {
-
 
504
                    for (j = 0; j < 8; j++) {
-
 
505
                        Cube_Set_Pixel(i,j,0,RED);
-
 
506
                        Cube_Set_Pixel(i,j,7,RED);
-
 
507
                        Cube_Set_Pixel(i,0,j,RED);
-
 
508
                        Cube_Set_Pixel(i,7,j,RED);
-
 
509
                    }
-
 
510
                }
-
 
511
                if ((x == 1 || x == 4)&&(i > 1 && i < 7)) {
-
 
512
                    for (j = 1; j < 7; j++) {
-
 
513
                        Cube_Set_Pixel(i,j,1,YELLOW);
-
 
514
                        Cube_Set_Pixel(i,j,6,YELLOW);
-
 
515
                        Cube_Set_Pixel(i,1,j,YELLOW);
-
 
516
                        Cube_Set_Pixel(i,6,j,YELLOW);
-
 
517
                    }
-
 
518
                }
-
 
519
                if ((x == 2 || x == 4)&&(i > 2 && i < 6)) {
-
 
520
                    for (j = 2; j < 6; j++) {
-
 
521
                        Cube_Set_Pixel(i,j,2,GREEN);
-
 
522
                        Cube_Set_Pixel(i,j,5,GREEN);
-
 
523
                        Cube_Set_Pixel(i,2,j,GREEN);
-
 
524
                        Cube_Set_Pixel(i,5,j,GREEN);
-
 
525
                    }
-
 
526
                }
-
 
527
            }
-
 
528
            Delay_MS(delay_ms);
-
 
529
        }
-
 
530
    }
-
 
531
}
-
 
532
 
-
 
533
void Animation_Double_Rotation(int iterations, int delay_ms) {
-
 
534
    Cube_Clear();
-
 
535
    int i,x,y,z;
-
 
536
    for (z = 0; z < 3; z++) {
-
 
537
        switch (z % 3) {
-
 
538
            case 0:
-
 
539
                for (y = 0; y < CUBE_LAYER_COUNT; y++) {
-
 
540
                    Cube_Set_Pixel(y,0,0,RED);
-
 
541
                    Cube_Set_Pixel(y,1,1,RED);
-
 
542
                    Cube_Set_Pixel(y,2,2,RED);
-
 
543
                    Cube_Set_Pixel(y,3,3,RED);
-
 
544
                    Cube_Set_Pixel(y,4,4,RED);
-
 
545
                    Cube_Set_Pixel(y,5,5,RED);
-
 
546
                    Cube_Set_Pixel(y,6,6,RED);
-
 
547
                    Cube_Set_Pixel(y,7,7,RED);
-
 
548
                }
-
 
549
                break;
-
 
550
            case 1:
-
 
551
                for (y = 0; y < CUBE_LAYER_COUNT; y++) {
-
 
552
                    Cube_Set_Pixel(y,0,0,GREEN);
-
 
553
                    Cube_Set_Pixel(y,1,1,GREEN);
-
 
554
                    Cube_Set_Pixel(y,2,2,GREEN);
-
 
555
                    Cube_Set_Pixel(y,3,3,GREEN);
-
 
556
                    Cube_Set_Pixel(y,4,4,GREEN);
-
 
557
                    Cube_Set_Pixel(y,5,5,GREEN);
-
 
558
                    Cube_Set_Pixel(y,6,6,GREEN);
-
 
559
                    Cube_Set_Pixel(y,7,7,GREEN);
-
 
560
                }
-
 
561
                break;
-
 
562
            case 2:
-
 
563
                for (y = 0; y < CUBE_LAYER_COUNT; y++) {
-
 
564
                    Cube_Set_Pixel(y,0,0,BLUE);
-
 
565
                    Cube_Set_Pixel(y,1,1,BLUE);
-
 
566
                    Cube_Set_Pixel(y,2,2,BLUE);
-
 
567
                    Cube_Set_Pixel(y,3,3,BLUE);
-
 
568
                    Cube_Set_Pixel(y,4,4,BLUE);
-
 
569
                    Cube_Set_Pixel(y,5,5,BLUE);
-
 
570
                    Cube_Set_Pixel(y,6,6,BLUE);
-
 
571
                    Cube_Set_Pixel(y,7,7,BLUE);
-
 
572
                }
-
 
573
                break;
-
 
574
        }
-
 
575
 
-
 
576
        for (i = 0; i < iterations; i++) {
-
 
577
            for (x = 0; x < 28; x++) {
-
 
578
                Delay_MS(delay_ms);
-
 
579
                Cube_Rotate(0);
-
 
580
            }
-
 
581
        }
-
 
582
    }
-
 
583
}
-
 
584
235