Subversion Repositories Code-Repo

Rev

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

Rev 263 Rev 264
Line 2... Line 2...
2
#include "CUBE.h"
2
#include "CUBE.h"
3
#include "SPI1.h"
3
#include "SPI1.h"
4
#include "glcdfont.h"
4
#include "glcdfont.h"
5
#include "UART1.h"
5
#include "UART1.h"
6
#include "ETHERNET.h"
6
#include "ETHERNET.h"
-
 
7
#include "TIMER4.h"
7
 
8
 
8
static CUBE_DATA *cube_data_ptr;
9
static CUBE_DATA *cube_data_ptr;
9
 
10
 
10
inline void Cube_Delay() {
11
inline void Cube_Delay() {
11
    // Small delay to ensure that latch speeds are < 30Mhz
12
    // Small delay to ensure that latch speeds are < 30Mhz
Line 193... Line 194...
193
            cube_data_ptr->GCS[layer][j_var+8] = B >> 4;
194
            cube_data_ptr->GCS[layer][j_var+8] = B >> 4;
194
        }
195
        }
195
    }
196
    }
196
}
197
}
197
 
198
 
-
 
199
void Cube_Set_Row(uint8_t row, uint16_t R, uint16_t G, uint16_t B) {
-
 
200
    // Set the specified row to the given color
-
 
201
    R &= 0x0FFF;
-
 
202
    G &= 0x0FFF;
-
 
203
    B &= 0x0FFF;
-
 
204
    uint8_t column, layer;
-
 
205
    for (layer = 0; layer < CUBE_LAYER_COUNT; layer++) {
-
 
206
        for (column = 0; column < CUBE_COLUMN_COUNT; column++) {
-
 
207
            uint16_t var = row * GCS_REG_SIZE + (column / 2 * 9);
-
 
208
            switch (column % 2) {
-
 
209
                case 0:
-
 
210
                    cube_data_ptr->GCS[layer][var+0] = R & 0xFF;
-
 
211
                    cube_data_ptr->GCS[layer][var+1] = (G << 4) | (R >> 8);
-
 
212
                    cube_data_ptr->GCS[layer][var+2] = G >> 4;
-
 
213
                    cube_data_ptr->GCS[layer][var+3] = B & 0xFF;
-
 
214
                    cube_data_ptr->GCS[layer][var+4] = (cube_data_ptr->GCS[layer][var+4] & 0xF0) | (B >> 8);
-
 
215
                    break;
-
 
216
                case 1:
-
 
217
                    cube_data_ptr->GCS[layer][var+4] = (cube_data_ptr->GCS[layer][var+4] & 0x0F) | (R << 4);
-
 
218
                    cube_data_ptr->GCS[layer][var+5] = R >> 4;
-
 
219
                    cube_data_ptr->GCS[layer][var+6] = G & 0xFF;
-
 
220
                    cube_data_ptr->GCS[layer][var+7] = (B << 4) | (G >> 8);
-
 
221
                    cube_data_ptr->GCS[layer][var+8] = B >> 4;
-
 
222
                    break;
-
 
223
            }       
-
 
224
        }
-
 
225
    }
-
 
226
}
-
 
227
 
-
 
228
void Cube_Set_Column(uint8_t column, uint16_t R, uint16_t G, uint16_t B) {
-
 
229
    // Set the specified row to the given color
-
 
230
    R &= 0x0FFF;
-
 
231
    G &= 0x0FFF;
-
 
232
    B &= 0x0FFF;
-
 
233
    uint8_t row, layer;
-
 
234
    for (layer = 0; layer < CUBE_LAYER_COUNT; layer++) {
-
 
235
        for (row = 0; row < CUBE_COLUMN_COUNT; row++) {
-
 
236
            uint16_t var = row * GCS_REG_SIZE + (column / 2 * 9);
-
 
237
            switch (column % 2) {
-
 
238
                case 0:
-
 
239
                    cube_data_ptr->GCS[layer][var+0] = R & 0xFF;
-
 
240
                    cube_data_ptr->GCS[layer][var+1] = (G << 4) | (R >> 8);
-
 
241
                    cube_data_ptr->GCS[layer][var+2] = G >> 4;
-
 
242
                    cube_data_ptr->GCS[layer][var+3] = B & 0xFF;
-
 
243
                    cube_data_ptr->GCS[layer][var+4] = (cube_data_ptr->GCS[layer][var+4] & 0xF0) | (B >> 8);
-
 
244
                    break;
-
 
245
                case 1:
-
 
246
                    cube_data_ptr->GCS[layer][var+4] = (cube_data_ptr->GCS[layer][var+4] & 0x0F) | (R << 4);
-
 
247
                    cube_data_ptr->GCS[layer][var+5] = R >> 4;
-
 
248
                    cube_data_ptr->GCS[layer][var+6] = G & 0xFF;
-
 
249
                    cube_data_ptr->GCS[layer][var+7] = (B << 4) | (G >> 8);
-
 
250
                    cube_data_ptr->GCS[layer][var+8] = B >> 4;
-
 
251
                    break;
-
 
252
            }
-
 
253
        }
-
 
254
    }
-
 
255
}
-
 
256
 
198
void Cube_Set_Pixel(uint8_t layer, uint8_t row, uint8_t column, uint16_t R, uint16_t G, uint16_t B) {
257
void Cube_Set_Pixel(uint8_t layer, uint8_t row, uint8_t column, uint16_t R, uint16_t G, uint16_t B) {
199
    // Set the specified pixel to the given color
258
    // Set the specified pixel to the given color
200
    R &= 0x0FFF;
259
    R &= 0x0FFF;
201
    G &= 0x0FFF;
260
    G &= 0x0FFF;
202
    B &= 0x0FFF;
261
    B &= 0x0FFF;
Line 242... Line 301...
242
    uint16_t prev_R, prev_G, prev_B;
301
    uint16_t prev_R, prev_G, prev_B;
243
    Cube_Get_Pixel(layer1, row1, column1, &prev_R, &prev_G, &prev_B);
302
    Cube_Get_Pixel(layer1, row1, column1, &prev_R, &prev_G, &prev_B);
244
    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);
245
}
304
}
246
 
305
 
-
 
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
-
 
308
    switch (layer) {
-
 
309
        case 0:
-
 
310
            Cube_Set_Pixel(3, 3, 3, R, G, B);
-
 
311
            Cube_Set_Pixel(3, 3, 4, R, G, B);
-
 
312
            Cube_Set_Pixel(3, 4, 3, R, G, B);
-
 
313
            Cube_Set_Pixel(3, 4, 4, R, G, B);
-
 
314
            Cube_Set_Pixel(4, 3, 3, R, G, B);
-
 
315
            Cube_Set_Pixel(4, 3, 4, R, G, B);
-
 
316
            Cube_Set_Pixel(4, 4, 3, R, G, B);
-
 
317
            Cube_Set_Pixel(4, 4, 4, R, G, B);
-
 
318
            break;
-
 
319
        case 1:
-
 
320
            Cube_Set_Pixel(2, 3, 3, R, G, B);
-
 
321
            Cube_Set_Pixel(2, 3, 4, R, G, B);
-
 
322
            Cube_Set_Pixel(2, 4, 3, R, G, B);
-
 
323
            Cube_Set_Pixel(2, 4, 4, R, G, B);
-
 
324
 
-
 
325
            Cube_Set_Pixel(5, 3, 3, R, G, B);
-
 
326
            Cube_Set_Pixel(5, 3, 4, R, G, B);
-
 
327
            Cube_Set_Pixel(5, 4, 3, R, G, B);
-
 
328
            Cube_Set_Pixel(5, 4, 4, R, G, B);
-
 
329
 
-
 
330
            Cube_Set_Pixel(3, 2, 3, R, G, B);
-
 
331
            Cube_Set_Pixel(3, 2, 4, R, G, B);
-
 
332
            Cube_Set_Pixel(3, 5, 3, R, G, B);
-
 
333
            Cube_Set_Pixel(3, 5, 4, R, G, B);
-
 
334
            Cube_Set_Pixel(3, 3, 2, R, G, B);
-
 
335
            Cube_Set_Pixel(3, 4, 2, R, G, B);
-
 
336
            Cube_Set_Pixel(3, 3, 5, R, G, B);
-
 
337
            Cube_Set_Pixel(3, 4, 5, R, G, B);
-
 
338
 
-
 
339
            Cube_Set_Pixel(4, 2, 3, R, G, B);
-
 
340
            Cube_Set_Pixel(4, 2, 4, R, G, B);
-
 
341
            Cube_Set_Pixel(4, 5, 3, R, G, B);
-
 
342
            Cube_Set_Pixel(4, 5, 4, R, G, B);
-
 
343
            Cube_Set_Pixel(4, 3, 2, R, G, B);
-
 
344
            Cube_Set_Pixel(4, 4, 2, R, G, B);
-
 
345
            Cube_Set_Pixel(4, 3, 5, R, G, B);
-
 
346
            Cube_Set_Pixel(4, 4, 5, R, G, B);
-
 
347
            break;
-
 
348
        case 2:
-
 
349
            Cube_Set_Pixel(1, 3, 3, R, G, B);
-
 
350
            Cube_Set_Pixel(1, 3, 4, R, G, B);
-
 
351
            Cube_Set_Pixel(1, 4, 3, R, G, B);
-
 
352
            Cube_Set_Pixel(1, 4, 4, R, G, B);
-
 
353
            
-
 
354
            Cube_Set_Pixel(6, 3, 3, R, G, B);
-
 
355
            Cube_Set_Pixel(6, 3, 4, R, G, B);
-
 
356
            Cube_Set_Pixel(6, 4, 3, R, G, B);
-
 
357
            Cube_Set_Pixel(6, 4, 4, R, G, B);
-
 
358
 
-
 
359
            Cube_Set_Pixel(3, 1, 3, R, G, B);
-
 
360
            Cube_Set_Pixel(3, 1, 4, R, G, B);
-
 
361
            Cube_Set_Pixel(3, 6, 3, R, G, B);
-
 
362
            Cube_Set_Pixel(3, 6, 4, R, G, B);
-
 
363
            Cube_Set_Pixel(3, 3, 1, R, G, B);
-
 
364
            Cube_Set_Pixel(3, 4, 1, R, G, B);
-
 
365
            Cube_Set_Pixel(3, 3, 6, R, G, B);
-
 
366
            Cube_Set_Pixel(3, 4, 6, R, G, B);
-
 
367
 
-
 
368
            Cube_Set_Pixel(3, 2, 2, R, G, B);
-
 
369
            Cube_Set_Pixel(3, 2, 5, R, G, B);
-
 
370
            Cube_Set_Pixel(3, 5, 5, R, G, B);
-
 
371
            Cube_Set_Pixel(3, 5, 2, R, G, B);
-
 
372
 
-
 
373
            Cube_Set_Pixel(4, 1, 3, R, G, B);
-
 
374
            Cube_Set_Pixel(4, 1, 4, R, G, B);
-
 
375
            Cube_Set_Pixel(4, 6, 3, R, G, B);
-
 
376
            Cube_Set_Pixel(4, 6, 4, R, G, B);
-
 
377
            Cube_Set_Pixel(4, 3, 1, R, G, B);
-
 
378
            Cube_Set_Pixel(4, 4, 1, R, G, B);
-
 
379
            Cube_Set_Pixel(4, 3, 6, R, G, B);
-
 
380
            Cube_Set_Pixel(4, 4, 6, R, G, B);
-
 
381
 
-
 
382
            Cube_Set_Pixel(4, 2, 2, R, G, B);
-
 
383
            Cube_Set_Pixel(4, 2, 5, R, G, B);
-
 
384
            Cube_Set_Pixel(4, 5, 5, R, G, B);
-
 
385
            Cube_Set_Pixel(4, 5, 2, R, G, B);
-
 
386
 
-
 
387
            Cube_Set_Pixel(2, 3, 2, R, G, B);
-
 
388
            Cube_Set_Pixel(2, 4, 2, R, G, B);
-
 
389
            Cube_Set_Pixel(2, 3, 5, R, G, B);
-
 
390
            Cube_Set_Pixel(2, 4, 5, R, G, B);
-
 
391
            Cube_Set_Pixel(2, 2, 3, R, G, B);
-
 
392
            Cube_Set_Pixel(2, 2, 4, R, G, B);
-
 
393
            Cube_Set_Pixel(2, 5, 3, R, G, B);
-
 
394
            Cube_Set_Pixel(2, 5, 4, R, G, B);
-
 
395
 
-
 
396
            Cube_Set_Pixel(2, 2, 2, R, G, B);
-
 
397
            Cube_Set_Pixel(2, 2, 5, R, G, B);
-
 
398
            Cube_Set_Pixel(2, 5, 2, R, G, B);
-
 
399
            Cube_Set_Pixel(2, 5, 5, R, G, B);
-
 
400
 
-
 
401
            Cube_Set_Pixel(5, 3, 2, R, G, B);
-
 
402
            Cube_Set_Pixel(5, 4, 2, R, G, B);
-
 
403
            Cube_Set_Pixel(5, 3, 5, R, G, B);
-
 
404
            Cube_Set_Pixel(5, 4, 5, R, G, B);
-
 
405
            Cube_Set_Pixel(5, 2, 3, R, G, B);
-
 
406
            Cube_Set_Pixel(5, 2, 4, R, G, B);
-
 
407
            Cube_Set_Pixel(5, 5, 3, R, G, B);
-
 
408
            Cube_Set_Pixel(5, 5, 4, R, G, B);
-
 
409
 
-
 
410
            Cube_Set_Pixel(5, 2, 2, R, G, B);
-
 
411
            Cube_Set_Pixel(5, 2, 5, R, G, B);
-
 
412
            Cube_Set_Pixel(5, 5, 2, R, G, B);
-
 
413
            Cube_Set_Pixel(5, 5, 5, R, G, B);
-
 
414
            break;
-
 
415
        case 3:
-
 
416
            Cube_Set_Pixel(0, 3, 3, R, G, B);
-
 
417
            Cube_Set_Pixel(0, 3, 4, R, G, B);
-
 
418
            Cube_Set_Pixel(0, 4, 3, R, G, B);
-
 
419
            Cube_Set_Pixel(0, 4, 4, R, G, B);
-
 
420
            Cube_Set_Pixel(7, 3, 3, R, G, B);
-
 
421
            Cube_Set_Pixel(7, 3, 4, R, G, B);
-
 
422
            Cube_Set_Pixel(7, 4, 3, R, G, B);
-
 
423
            Cube_Set_Pixel(7, 4, 4, R, G, B);
-
 
424
 
-
 
425
            Cube_Set_Pixel(3, 0, 3, R, G, B);
-
 
426
            Cube_Set_Pixel(3, 0, 4, R, G, B);
-
 
427
            Cube_Set_Pixel(3, 7, 3, R, G, B);
-
 
428
            Cube_Set_Pixel(3, 7, 4, R, G, B);
-
 
429
            Cube_Set_Pixel(3, 3, 0, R, G, B);
-
 
430
            Cube_Set_Pixel(3, 4, 0, R, G, B);
-
 
431
            Cube_Set_Pixel(3, 3, 7, R, G, B);
-
 
432
            Cube_Set_Pixel(3, 4, 7, R, G, B);
-
 
433
 
-
 
434
            Cube_Set_Pixel(3, 2, 6, R, G, B);
-
 
435
            Cube_Set_Pixel(3, 1, 5, R, G, B);
-
 
436
            Cube_Set_Pixel(3, 6, 2, R, G, B);
-
 
437
            Cube_Set_Pixel(3, 5, 1, R, G, B);
-
 
438
            Cube_Set_Pixel(3, 1, 2, R, G, B);
-
 
439
            Cube_Set_Pixel(3, 2, 1, R, G, B);
-
 
440
            Cube_Set_Pixel(3, 6, 5, R, G, B);
-
 
441
            Cube_Set_Pixel(3, 5, 6, R, G, B);
-
 
442
 
-
 
443
            Cube_Set_Pixel(4, 0, 3, R, G, B);
-
 
444
            Cube_Set_Pixel(4, 0, 4, R, G, B);
-
 
445
            Cube_Set_Pixel(4, 7, 3, R, G, B);
-
 
446
            Cube_Set_Pixel(4, 7, 4, R, G, B);
-
 
447
            Cube_Set_Pixel(4, 3, 0, R, G, B);
-
 
448
            Cube_Set_Pixel(4, 4, 0, R, G, B);
-
 
449
            Cube_Set_Pixel(4, 3, 7, R, G, B);
-
 
450
            Cube_Set_Pixel(4, 4, 7, R, G, B);
-
 
451
 
-
 
452
            Cube_Set_Pixel(4, 2, 6, R, G, B);
-
 
453
            Cube_Set_Pixel(4, 1, 5, R, G, B);
-
 
454
            Cube_Set_Pixel(4, 6, 2, R, G, B);
-
 
455
            Cube_Set_Pixel(4, 5, 1, R, G, B);
-
 
456
            Cube_Set_Pixel(4, 1, 2, R, G, B);
-
 
457
            Cube_Set_Pixel(4, 2, 1, R, G, B);
-
 
458
            Cube_Set_Pixel(4, 6, 5, R, G, B);
-
 
459
            Cube_Set_Pixel(4, 5, 6, R, G, B);
-
 
460
 
-
 
461
            Cube_Set_Pixel(1, 2, 5, R, G, B);
-
 
462
            Cube_Set_Pixel(1, 2, 4, R, G, B);
-
 
463
            Cube_Set_Pixel(1, 2, 3, R, G, B);
-
 
464
            Cube_Set_Pixel(1, 2, 2, R, G, B);
-
 
465
            Cube_Set_Pixel(1, 3, 5, R, G, B);
-
 
466
            Cube_Set_Pixel(1, 3, 2, R, G, B);
-
 
467
            Cube_Set_Pixel(1, 4, 5, R, G, B);
-
 
468
            Cube_Set_Pixel(1, 4, 2, R, G, B);
-
 
469
            Cube_Set_Pixel(1, 5, 5, R, G, B);
-
 
470
            Cube_Set_Pixel(1, 5, 4, R, G, B);
-
 
471
            Cube_Set_Pixel(1, 5, 3, R, G, B);
-
 
472
            Cube_Set_Pixel(1, 5, 2, R, G, B);
-
 
473
 
-
 
474
            Cube_Set_Pixel(2, 1, 5, R, G, B);
-
 
475
            Cube_Set_Pixel(2, 1, 4, R, G, B);
-
 
476
            Cube_Set_Pixel(2, 1, 3, R, G, B);
-
 
477
            Cube_Set_Pixel(2, 1, 2, R, G, B);
-
 
478
            Cube_Set_Pixel(2, 6, 5, R, G, B);
-
 
479
            Cube_Set_Pixel(2, 6, 4, R, G, B);
-
 
480
            Cube_Set_Pixel(2, 6, 3, R, G, B);
-
 
481
            Cube_Set_Pixel(2, 6, 2, R, G, B);
-
 
482
            Cube_Set_Pixel(2, 2, 6, R, G, B);
-
 
483
            Cube_Set_Pixel(2, 3, 6, R, G, B);
-
 
484
            Cube_Set_Pixel(2, 4, 6, R, G, B);
-
 
485
            Cube_Set_Pixel(2, 5, 6, R, G, B);
-
 
486
            Cube_Set_Pixel(2, 2, 1, R, G, B);
-
 
487
            Cube_Set_Pixel(2, 3, 1, R, G, B);
-
 
488
            Cube_Set_Pixel(2, 4, 1, R, G, B);
-
 
489
            Cube_Set_Pixel(2, 5, 1, R, G, B);
-
 
490
 
-
 
491
            Cube_Set_Pixel(5, 1, 5, R, G, B);
-
 
492
            Cube_Set_Pixel(5, 1, 4, R, G, B);
-
 
493
            Cube_Set_Pixel(5, 1, 3, R, G, B);
-
 
494
            Cube_Set_Pixel(5, 1, 2, R, G, B);
-
 
495
            Cube_Set_Pixel(5, 6, 5, R, G, B);
-
 
496
            Cube_Set_Pixel(5, 6, 4, R, G, B);
-
 
497
            Cube_Set_Pixel(5, 6, 3, R, G, B);
-
 
498
            Cube_Set_Pixel(5, 6, 2, R, G, B);
-
 
499
            Cube_Set_Pixel(5, 2, 6, R, G, B);
-
 
500
            Cube_Set_Pixel(5, 3, 6, R, G, B);
-
 
501
            Cube_Set_Pixel(5, 4, 6, R, G, B);
-
 
502
            Cube_Set_Pixel(5, 5, 6, R, G, B);
-
 
503
            Cube_Set_Pixel(5, 2, 1, R, G, B);
-
 
504
            Cube_Set_Pixel(5, 3, 1, R, G, B);
-
 
505
            Cube_Set_Pixel(5, 4, 1, R, G, B);
-
 
506
            Cube_Set_Pixel(5, 5, 1, R, G, B);
-
 
507
 
-
 
508
            Cube_Set_Pixel(6, 2, 5, R, G, B);
-
 
509
            Cube_Set_Pixel(6, 2, 4, R, G, B);
-
 
510
            Cube_Set_Pixel(6, 2, 3, R, G, B);
-
 
511
            Cube_Set_Pixel(6, 2, 2, R, G, B);
-
 
512
            Cube_Set_Pixel(6, 3, 5, R, G, B);
-
 
513
            Cube_Set_Pixel(6, 3, 2, R, G, B);
-
 
514
            Cube_Set_Pixel(6, 4, 5, R, G, B);
-
 
515
            Cube_Set_Pixel(6, 4, 2, R, G, B);
-
 
516
            Cube_Set_Pixel(6, 5, 5, R, G, B);
-
 
517
            Cube_Set_Pixel(6, 5, 4, R, G, B);
-
 
518
            Cube_Set_Pixel(6, 5, 3, R, G, B);
-
 
519
            Cube_Set_Pixel(6, 5, 2, R, G, B);
-
 
520
            break;
-
 
521
        case 4:
-
 
522
            Cube_Set_Pixel(0, 2, 5, R, G, B);
-
 
523
            Cube_Set_Pixel(0, 2, 4, R, G, B);
-
 
524
            Cube_Set_Pixel(0, 2, 3, R, G, B);
-
 
525
            Cube_Set_Pixel(0, 2, 2, R, G, B);
-
 
526
            Cube_Set_Pixel(0, 3, 5, R, G, B);
-
 
527
            Cube_Set_Pixel(0, 3, 2, R, G, B);
-
 
528
            Cube_Set_Pixel(0, 4, 5, R, G, B);
-
 
529
            Cube_Set_Pixel(0, 4, 2, R, G, B);
-
 
530
            Cube_Set_Pixel(0, 5, 5, R, G, B);
-
 
531
            Cube_Set_Pixel(0, 5, 4, R, G, B);
-
 
532
            Cube_Set_Pixel(0, 5, 3, R, G, B);
-
 
533
            Cube_Set_Pixel(0, 5, 2, R, G, B);
-
 
534
 
-
 
535
            Cube_Set_Pixel(7, 2, 5, R, G, B);
-
 
536
            Cube_Set_Pixel(7, 2, 4, R, G, B);
-
 
537
            Cube_Set_Pixel(7, 2, 3, R, G, B);
-
 
538
            Cube_Set_Pixel(7, 2, 2, R, G, B);
-
 
539
            Cube_Set_Pixel(7, 3, 5, R, G, B);
-
 
540
            Cube_Set_Pixel(7, 3, 2, R, G, B);
-
 
541
            Cube_Set_Pixel(7, 4, 5, R, G, B);
-
 
542
            Cube_Set_Pixel(7, 4, 2, R, G, B);
-
 
543
            Cube_Set_Pixel(7, 5, 5, R, G, B);
-
 
544
            Cube_Set_Pixel(7, 5, 4, R, G, B);
-
 
545
            Cube_Set_Pixel(7, 5, 3, R, G, B);
-
 
546
            Cube_Set_Pixel(7, 5, 2, R, G, B);
-
 
547
 
-
 
548
            Cube_Set_Pixel(1, 1, 5, R, G, B);
-
 
549
            Cube_Set_Pixel(1, 1, 4, R, G, B);
-
 
550
            Cube_Set_Pixel(1, 1, 3, R, G, B);
-
 
551
            Cube_Set_Pixel(1, 1, 2, R, G, B);
-
 
552
            Cube_Set_Pixel(1, 6, 5, R, G, B);
-
 
553
            Cube_Set_Pixel(1, 6, 4, R, G, B);
-
 
554
            Cube_Set_Pixel(1, 6, 3, R, G, B);
-
 
555
            Cube_Set_Pixel(1, 6, 2, R, G, B);
-
 
556
            Cube_Set_Pixel(1, 2, 6, R, G, B);
-
 
557
            Cube_Set_Pixel(1, 3, 6, R, G, B);
-
 
558
            Cube_Set_Pixel(1, 4, 6, R, G, B);
-
 
559
            Cube_Set_Pixel(1, 5, 6, R, G, B);
-
 
560
            Cube_Set_Pixel(1, 2, 1, R, G, B);
-
 
561
            Cube_Set_Pixel(1, 3, 1, R, G, B);
-
 
562
            Cube_Set_Pixel(1, 4, 1, R, G, B);
-
 
563
            Cube_Set_Pixel(1, 5, 1, R, G, B);
-
 
564
 
-
 
565
            Cube_Set_Pixel(6, 1, 5, R, G, B);
-
 
566
            Cube_Set_Pixel(6, 1, 4, R, G, B);
-
 
567
            Cube_Set_Pixel(6, 1, 3, R, G, B);
-
 
568
            Cube_Set_Pixel(6, 1, 2, R, G, B);
-
 
569
            Cube_Set_Pixel(6, 6, 5, R, G, B);
-
 
570
            Cube_Set_Pixel(6, 6, 4, R, G, B);
-
 
571
            Cube_Set_Pixel(6, 6, 3, R, G, B);
-
 
572
            Cube_Set_Pixel(6, 6, 2, R, G, B);
-
 
573
            Cube_Set_Pixel(6, 2, 6, R, G, B);
-
 
574
            Cube_Set_Pixel(6, 3, 6, R, G, B);
-
 
575
            Cube_Set_Pixel(6, 4, 6, R, G, B);
-
 
576
            Cube_Set_Pixel(6, 5, 6, R, G, B);
-
 
577
            Cube_Set_Pixel(6, 2, 1, R, G, B);
-
 
578
            Cube_Set_Pixel(6, 3, 1, R, G, B);
-
 
579
            Cube_Set_Pixel(6, 4, 1, R, G, B);
-
 
580
            Cube_Set_Pixel(6, 5, 1, R, G, B);
-
 
581
 
-
 
582
            Cube_Set_Pixel(2, 0, 5, R, G, B);
-
 
583
            Cube_Set_Pixel(2, 0, 4, R, G, B);
-
 
584
            Cube_Set_Pixel(2, 0, 3, R, G, B);
-
 
585
            Cube_Set_Pixel(2, 0, 2, R, G, B);
-
 
586
            Cube_Set_Pixel(2, 7, 5, R, G, B);
-
 
587
            Cube_Set_Pixel(2, 7, 4, R, G, B);
-
 
588
            Cube_Set_Pixel(2, 7, 3, R, G, B);
-
 
589
            Cube_Set_Pixel(2, 7, 2, R, G, B);
-
 
590
            Cube_Set_Pixel(2, 5, 0, R, G, B);
-
 
591
            Cube_Set_Pixel(2, 4, 0, R, G, B);
-
 
592
            Cube_Set_Pixel(2, 3, 0, R, G, B);
-
 
593
            Cube_Set_Pixel(2, 2, 0, R, G, B);
-
 
594
            Cube_Set_Pixel(2, 5, 7, R, G, B);
-
 
595
            Cube_Set_Pixel(2, 4, 7, R, G, B);
-
 
596
            Cube_Set_Pixel(2, 3, 7, R, G, B);
-
 
597
            Cube_Set_Pixel(2, 2, 7, R, G, B);
-
 
598
            Cube_Set_Pixel(2, 1, 1, R, G, B);
-
 
599
            Cube_Set_Pixel(2, 1, 6, R, G, B);
-
 
600
            Cube_Set_Pixel(2, 6, 1, R, G, B);
-
 
601
            Cube_Set_Pixel(2, 6, 6, R, G, B);
-
 
602
 
-
 
603
            Cube_Set_Pixel(5, 0, 5, R, G, B);
-
 
604
            Cube_Set_Pixel(5, 0, 4, R, G, B);
-
 
605
            Cube_Set_Pixel(5, 0, 3, R, G, B);
-
 
606
            Cube_Set_Pixel(5, 0, 2, R, G, B);
-
 
607
            Cube_Set_Pixel(5, 7, 5, R, G, B);
-
 
608
            Cube_Set_Pixel(5, 7, 4, R, G, B);
-
 
609
            Cube_Set_Pixel(5, 7, 3, R, G, B);
-
 
610
            Cube_Set_Pixel(5, 7, 2, R, G, B);
-
 
611
            Cube_Set_Pixel(5, 5, 0, R, G, B);
-
 
612
            Cube_Set_Pixel(5, 4, 0, R, G, B);
-
 
613
            Cube_Set_Pixel(5, 3, 0, R, G, B);
-
 
614
            Cube_Set_Pixel(5, 2, 0, R, G, B);
-
 
615
            Cube_Set_Pixel(5, 5, 7, R, G, B);
-
 
616
            Cube_Set_Pixel(5, 4, 7, R, G, B);
-
 
617
            Cube_Set_Pixel(5, 3, 7, R, G, B);
-
 
618
            Cube_Set_Pixel(5, 2, 7, R, G, B);
-
 
619
            Cube_Set_Pixel(5, 1, 1, R, G, B);
-
 
620
            Cube_Set_Pixel(5, 1, 6, R, G, B);
-
 
621
            Cube_Set_Pixel(5, 6, 1, R, G, B);
-
 
622
            Cube_Set_Pixel(5, 6, 6, R, G, B);
-
 
623
 
-
 
624
            Cube_Set_Pixel(3, 0, 2, R, G, B);
-
 
625
            Cube_Set_Pixel(3, 0, 5, R, G, B);
-
 
626
            Cube_Set_Pixel(3, 2, 0, R, G, B);
-
 
627
            Cube_Set_Pixel(3, 5, 0, R, G, B);
-
 
628
            Cube_Set_Pixel(3, 7, 2, R, G, B);
-
 
629
            Cube_Set_Pixel(3, 7, 5, R, G, B);
-
 
630
            Cube_Set_Pixel(3, 2, 7, R, G, B);
-
 
631
            Cube_Set_Pixel(3, 5, 7, R, G, B);
-
 
632
            Cube_Set_Pixel(3, 1, 1, R, G, B);
-
 
633
            Cube_Set_Pixel(3, 1, 6, R, G, B);
-
 
634
            Cube_Set_Pixel(3, 6, 1, R, G, B);
-
 
635
            Cube_Set_Pixel(3, 6, 6, R, G, B);
-
 
636
 
-
 
637
            Cube_Set_Pixel(4, 0, 2, R, G, B);
-
 
638
            Cube_Set_Pixel(4, 0, 5, R, G, B);
-
 
639
            Cube_Set_Pixel(4, 2, 0, R, G, B);
-
 
640
            Cube_Set_Pixel(4, 5, 0, R, G, B);
-
 
641
            Cube_Set_Pixel(4, 7, 2, R, G, B);
-
 
642
            Cube_Set_Pixel(4, 7, 5, R, G, B);
-
 
643
            Cube_Set_Pixel(4, 2, 7, R, G, B);
-
 
644
            Cube_Set_Pixel(4, 5, 7, R, G, B);
-
 
645
            Cube_Set_Pixel(4, 1, 1, R, G, B);
-
 
646
            Cube_Set_Pixel(4, 1, 6, R, G, B);
-
 
647
            Cube_Set_Pixel(4, 6, 1, R, G, B);
-
 
648
            Cube_Set_Pixel(4, 6, 6, R, G, B);
-
 
649
            break;
-
 
650
        case 5:
-
 
651
            Cube_Set_Pixel(0, 1, 5, R, G, B);
-
 
652
            Cube_Set_Pixel(0, 1, 4, R, G, B);
-
 
653
            Cube_Set_Pixel(0, 1, 3, R, G, B);
-
 
654
            Cube_Set_Pixel(0, 1, 2, R, G, B);
-
 
655
            Cube_Set_Pixel(0, 6, 5, R, G, B);
-
 
656
            Cube_Set_Pixel(0, 6, 4, R, G, B);
-
 
657
            Cube_Set_Pixel(0, 6, 3, R, G, B);
-
 
658
            Cube_Set_Pixel(0, 6, 2, R, G, B);
-
 
659
            Cube_Set_Pixel(0, 2, 6, R, G, B);
-
 
660
            Cube_Set_Pixel(0, 3, 6, R, G, B);
-
 
661
            Cube_Set_Pixel(0, 4, 6, R, G, B);
-
 
662
            Cube_Set_Pixel(0, 5, 6, R, G, B);
-
 
663
            Cube_Set_Pixel(0, 2, 1, R, G, B);
-
 
664
            Cube_Set_Pixel(0, 3, 1, R, G, B);
-
 
665
            Cube_Set_Pixel(0, 4, 1, R, G, B);
-
 
666
            Cube_Set_Pixel(0, 5, 1, R, G, B);
-
 
667
 
-
 
668
            Cube_Set_Pixel(1, 0, 2, R, G, B);
-
 
669
            Cube_Set_Pixel(1, 0, 3, R, G, B);
-
 
670
            Cube_Set_Pixel(1, 0, 4, R, G, B);
-
 
671
            Cube_Set_Pixel(1, 0, 5, R, G, B);
-
 
672
            Cube_Set_Pixel(1, 1, 6, R, G, B);
-
 
673
            Cube_Set_Pixel(1, 2, 7, R, G, B);
-
 
674
            Cube_Set_Pixel(1, 3, 7, R, G, B);
-
 
675
            Cube_Set_Pixel(1, 4, 7, R, G, B);
-
 
676
            Cube_Set_Pixel(1, 5, 7, R, G, B);
-
 
677
            Cube_Set_Pixel(1, 6, 6, R, G, B);
-
 
678
            Cube_Set_Pixel(1, 7, 5, R, G, B);
-
 
679
            Cube_Set_Pixel(1, 7, 4, R, G, B);
-
 
680
            Cube_Set_Pixel(1, 7, 3, R, G, B);
-
 
681
            Cube_Set_Pixel(1, 7, 2, R, G, B);
-
 
682
            Cube_Set_Pixel(1, 6, 1, R, G, B);
-
 
683
            Cube_Set_Pixel(1, 5, 0, R, G, B);
-
 
684
            Cube_Set_Pixel(1, 4, 0, R, G, B);
-
 
685
            Cube_Set_Pixel(1, 3, 0, R, G, B);
-
 
686
            Cube_Set_Pixel(1, 2, 0, R, G, B);
-
 
687
            Cube_Set_Pixel(1, 1, 1, R, G, B);
-
 
688
 
-
 
689
            Cube_Set_Pixel(2, 0, 1, R, G, B);
-
 
690
            Cube_Set_Pixel(2, 1, 0, R, G, B);
-
 
691
            Cube_Set_Pixel(2, 0, 6, R, G, B);
-
 
692
            Cube_Set_Pixel(2, 1, 7, R, G, B);
-
 
693
            Cube_Set_Pixel(2, 6, 7, R, G, B);
-
 
694
            Cube_Set_Pixel(2, 7, 6, R, G, B);
-
 
695
            Cube_Set_Pixel(2, 6, 0, R, G, B);
-
 
696
            Cube_Set_Pixel(2, 7, 1, R, G, B);
-
 
697
 
-
 
698
            Cube_Set_Pixel(3, 0, 1, R, G, B);
-
 
699
            Cube_Set_Pixel(3, 1, 0, R, G, B);
-
 
700
            Cube_Set_Pixel(3, 0, 6, R, G, B);
-
 
701
            Cube_Set_Pixel(3, 1, 7, R, G, B);
-
 
702
            Cube_Set_Pixel(3, 6, 7, R, G, B);
-
 
703
            Cube_Set_Pixel(3, 7, 6, R, G, B);
-
 
704
            Cube_Set_Pixel(3, 6, 0, R, G, B);
-
 
705
            Cube_Set_Pixel(3, 7, 1, R, G, B);
-
 
706
 
-
 
707
            Cube_Set_Pixel(4, 0, 1, R, G, B);
-
 
708
            Cube_Set_Pixel(4, 1, 0, R, G, B);
-
 
709
            Cube_Set_Pixel(4, 0, 6, R, G, B);
-
 
710
            Cube_Set_Pixel(4, 1, 7, R, G, B);
-
 
711
            Cube_Set_Pixel(4, 6, 7, R, G, B);
-
 
712
            Cube_Set_Pixel(4, 7, 6, R, G, B);
-
 
713
            Cube_Set_Pixel(4, 6, 0, R, G, B);
-
 
714
            Cube_Set_Pixel(4, 7, 1, R, G, B);
-
 
715
 
-
 
716
            Cube_Set_Pixel(5, 0, 1, R, G, B);
-
 
717
            Cube_Set_Pixel(5, 1, 0, R, G, B);
-
 
718
            Cube_Set_Pixel(5, 0, 6, R, G, B);
-
 
719
            Cube_Set_Pixel(5, 1, 7, R, G, B);
-
 
720
            Cube_Set_Pixel(5, 6, 7, R, G, B);
-
 
721
            Cube_Set_Pixel(5, 7, 6, R, G, B);
-
 
722
            Cube_Set_Pixel(5, 6, 0, R, G, B);
-
 
723
            Cube_Set_Pixel(5, 7, 1, R, G, B);
-
 
724
 
-
 
725
 
-
 
726
            Cube_Set_Pixel(6, 0, 2, R, G, B);
-
 
727
            Cube_Set_Pixel(6, 0, 3, R, G, B);
-
 
728
            Cube_Set_Pixel(6, 0, 4, R, G, B);
-
 
729
            Cube_Set_Pixel(6, 0, 5, R, G, B);
-
 
730
            Cube_Set_Pixel(6, 1, 6, R, G, B);
-
 
731
            Cube_Set_Pixel(6, 2, 7, R, G, B);
-
 
732
            Cube_Set_Pixel(6, 3, 7, R, G, B);
-
 
733
            Cube_Set_Pixel(6, 4, 7, R, G, B);
-
 
734
            Cube_Set_Pixel(6, 5, 7, R, G, B);
-
 
735
            Cube_Set_Pixel(6, 6, 6, R, G, B);
-
 
736
            Cube_Set_Pixel(6, 7, 5, R, G, B);
-
 
737
            Cube_Set_Pixel(6, 7, 4, R, G, B);
-
 
738
            Cube_Set_Pixel(6, 7, 3, R, G, B);
-
 
739
            Cube_Set_Pixel(6, 7, 2, R, G, B);
-
 
740
            Cube_Set_Pixel(6, 6, 1, R, G, B);
-
 
741
            Cube_Set_Pixel(6, 5, 0, R, G, B);
-
 
742
            Cube_Set_Pixel(6, 4, 0, R, G, B);
-
 
743
            Cube_Set_Pixel(6, 3, 0, R, G, B);
-
 
744
            Cube_Set_Pixel(6, 2, 0, R, G, B);
-
 
745
            Cube_Set_Pixel(6, 1, 1, R, G, B);
-
 
746
 
-
 
747
            Cube_Set_Pixel(7, 1, 5, R, G, B);
-
 
748
            Cube_Set_Pixel(7, 1, 4, R, G, B);
-
 
749
            Cube_Set_Pixel(7, 1, 3, R, G, B);
-
 
750
            Cube_Set_Pixel(7, 1, 2, R, G, B);
-
 
751
            Cube_Set_Pixel(7, 6, 5, R, G, B);
-
 
752
            Cube_Set_Pixel(7, 6, 4, R, G, B);
-
 
753
            Cube_Set_Pixel(7, 6, 3, R, G, B);
-
 
754
            Cube_Set_Pixel(7, 6, 2, R, G, B);
-
 
755
            Cube_Set_Pixel(7, 2, 6, R, G, B);
-
 
756
            Cube_Set_Pixel(7, 3, 6, R, G, B);
-
 
757
            Cube_Set_Pixel(7, 4, 6, R, G, B);
-
 
758
            Cube_Set_Pixel(7, 5, 6, R, G, B);
-
 
759
            Cube_Set_Pixel(7, 2, 1, R, G, B);
-
 
760
            Cube_Set_Pixel(7, 3, 1, R, G, B);
-
 
761
            Cube_Set_Pixel(7, 4, 1, R, G, B);
-
 
762
            Cube_Set_Pixel(7, 5, 1, R, G, B);
-
 
763
            break;
-
 
764
        case 6:
-
 
765
            Cube_Set_Pixel(0, 0, 2, R, G, B);
-
 
766
            Cube_Set_Pixel(0, 0, 3, R, G, B);
-
 
767
            Cube_Set_Pixel(0, 0, 4, R, G, B);
-
 
768
            Cube_Set_Pixel(0, 0, 5, R, G, B);
-
 
769
            Cube_Set_Pixel(0, 1, 1, R, G, B);
-
 
770
            Cube_Set_Pixel(0, 1, 6, R, G, B);
-
 
771
            Cube_Set_Pixel(0, 2, 0, R, G, B);
-
 
772
            Cube_Set_Pixel(0, 2, 7, R, G, B);
-
 
773
            Cube_Set_Pixel(0, 3, 0, R, G, B);
-
 
774
            Cube_Set_Pixel(0, 3, 7, R, G, B);
-
 
775
            Cube_Set_Pixel(0, 4, 0, R, G, B);
-
 
776
            Cube_Set_Pixel(0, 4, 7, R, G, B);
-
 
777
            Cube_Set_Pixel(0, 5, 0, R, G, B);
-
 
778
            Cube_Set_Pixel(0, 5, 7, R, G, B);
-
 
779
            Cube_Set_Pixel(0, 6, 6, R, G, B);
-
 
780
            Cube_Set_Pixel(0, 6, 1, R, G, B);
-
 
781
            Cube_Set_Pixel(0, 7, 2, R, G, B);
-
 
782
            Cube_Set_Pixel(0, 7, 3, R, G, B);
-
 
783
            Cube_Set_Pixel(0, 7, 4, R, G, B);
-
 
784
            Cube_Set_Pixel(0, 7, 5, R, G, B);
-
 
785
 
-
 
786
            Cube_Set_Pixel(1, 0, 1, R, G, B);
-
 
787
            Cube_Set_Pixel(1, 1, 0, R, G, B);
-
 
788
            Cube_Set_Pixel(1, 0, 6, R, G, B);
-
 
789
            Cube_Set_Pixel(1, 1, 7, R, G, B);
-
 
790
            Cube_Set_Pixel(1, 6, 7, R, G, B);
-
 
791
            Cube_Set_Pixel(1, 7, 6, R, G, B);
-
 
792
            Cube_Set_Pixel(1, 6, 0, R, G, B);
-
 
793
            Cube_Set_Pixel(1, 7, 1, R, G, B);
-
 
794
 
-
 
795
            Cube_Set_Pixel(2, 0, 0, R, G, B);
-
 
796
            Cube_Set_Pixel(2, 0, 7, R, G, B);
-
 
797
            Cube_Set_Pixel(2, 7, 7, R, G, B);
-
 
798
            Cube_Set_Pixel(2, 7, 0, R, G, B);
-
 
799
 
-
 
800
            Cube_Set_Pixel(3, 0, 0, R, G, B);
-
 
801
            Cube_Set_Pixel(3, 0, 7, R, G, B);
-
 
802
            Cube_Set_Pixel(3, 7, 7, R, G, B);
-
 
803
            Cube_Set_Pixel(3, 7, 0, R, G, B);
-
 
804
 
-
 
805
            Cube_Set_Pixel(4, 0, 0, R, G, B);
-
 
806
            Cube_Set_Pixel(4, 0, 7, R, G, B);
-
 
807
            Cube_Set_Pixel(4, 7, 7, R, G, B);
-
 
808
            Cube_Set_Pixel(4, 7, 0, R, G, B);
-
 
809
 
-
 
810
            Cube_Set_Pixel(5, 0, 0, R, G, B);
-
 
811
            Cube_Set_Pixel(5, 0, 7, R, G, B);
-
 
812
            Cube_Set_Pixel(5, 7, 7, R, G, B);
-
 
813
            Cube_Set_Pixel(5, 7, 0, R, G, B);
-
 
814
 
-
 
815
            Cube_Set_Pixel(6, 0, 1, R, G, B);
-
 
816
            Cube_Set_Pixel(6, 1, 0, R, G, B);
-
 
817
            Cube_Set_Pixel(6, 0, 6, R, G, B);
-
 
818
            Cube_Set_Pixel(6, 1, 7, R, G, B);
-
 
819
            Cube_Set_Pixel(6, 6, 7, R, G, B);
-
 
820
            Cube_Set_Pixel(6, 7, 6, R, G, B);
-
 
821
            Cube_Set_Pixel(6, 6, 0, R, G, B);
-
 
822
            Cube_Set_Pixel(6, 7, 1, R, G, B);
-
 
823
 
-
 
824
            Cube_Set_Pixel(7, 0, 2, R, G, B);
-
 
825
            Cube_Set_Pixel(7, 0, 3, R, G, B);
-
 
826
            Cube_Set_Pixel(7, 0, 4, R, G, B);
-
 
827
            Cube_Set_Pixel(7, 0, 5, R, G, B);
-
 
828
            Cube_Set_Pixel(7, 1, 1, R, G, B);
-
 
829
            Cube_Set_Pixel(7, 1, 6, R, G, B);
-
 
830
            Cube_Set_Pixel(7, 2, 0, R, G, B);
-
 
831
            Cube_Set_Pixel(7, 2, 7, R, G, B);
-
 
832
            Cube_Set_Pixel(7, 3, 0, R, G, B);
-
 
833
            Cube_Set_Pixel(7, 3, 7, R, G, B);
-
 
834
            Cube_Set_Pixel(7, 4, 0, R, G, B);
-
 
835
            Cube_Set_Pixel(7, 4, 7, R, G, B);
-
 
836
            Cube_Set_Pixel(7, 5, 0, R, G, B);
-
 
837
            Cube_Set_Pixel(7, 5, 7, R, G, B);
-
 
838
            Cube_Set_Pixel(7, 6, 6, R, G, B);
-
 
839
            Cube_Set_Pixel(7, 6, 1, R, G, B);
-
 
840
            Cube_Set_Pixel(7, 7, 2, R, G, B);
-
 
841
            Cube_Set_Pixel(7, 7, 3, R, G, B);
-
 
842
            Cube_Set_Pixel(7, 7, 4, R, G, B);
-
 
843
            Cube_Set_Pixel(7, 7, 5, R, G, B);
-
 
844
            break;
-
 
845
        case 7:
-
 
846
            Cube_Set_Pixel(0, 0, 1, R, G, B);
-
 
847
            Cube_Set_Pixel(0, 1, 0, R, G, B);
-
 
848
            Cube_Set_Pixel(0, 0, 6, R, G, B);
-
 
849
            Cube_Set_Pixel(0, 1, 7, R, G, B);
-
 
850
            Cube_Set_Pixel(0, 6, 7, R, G, B);
-
 
851
            Cube_Set_Pixel(0, 7, 6, R, G, B);
-
 
852
            Cube_Set_Pixel(0, 7, 1, R, G, B);
-
 
853
            Cube_Set_Pixel(0, 6, 0, R, G, B);
-
 
854
 
-
 
855
            Cube_Set_Pixel(1, 0, 0, R, G, B);
-
 
856
            Cube_Set_Pixel(1, 0, 7, R, G, B);
-
 
857
            Cube_Set_Pixel(1, 7, 7, R, G, B);
-
 
858
            Cube_Set_Pixel(1, 7, 0, R, G, B);
-
 
859
 
-
 
860
            Cube_Set_Pixel(6, 0, 0, R, G, B);
-
 
861
            Cube_Set_Pixel(6, 0, 7, R, G, B);
-
 
862
            Cube_Set_Pixel(6, 7, 7, R, G, B);
-
 
863
            Cube_Set_Pixel(6, 7, 0, R, G, B);
-
 
864
 
-
 
865
            Cube_Set_Pixel(7, 0, 1, R, G, B);
-
 
866
            Cube_Set_Pixel(7, 1, 0, R, G, B);
-
 
867
            Cube_Set_Pixel(7, 0, 6, R, G, B);
-
 
868
            Cube_Set_Pixel(7, 1, 7, R, G, B);
-
 
869
            Cube_Set_Pixel(7, 6, 7, R, G, B);
-
 
870
            Cube_Set_Pixel(7, 7, 6, R, G, B);
-
 
871
            Cube_Set_Pixel(7, 7, 1, R, G, B);
-
 
872
            Cube_Set_Pixel(7, 6, 0, R, G, B);
-
 
873
            break;
-
 
874
        case 8:
-
 
875
            Cube_Set_Pixel(0, 0, 0, R, G, B);
-
 
876
            Cube_Set_Pixel(0, 0, 7, R, G, B);
-
 
877
            Cube_Set_Pixel(0, 7, 7, R, G, B);
-
 
878
            Cube_Set_Pixel(0, 7, 0, R, G, B);
-
 
879
 
-
 
880
            Cube_Set_Pixel(7, 0, 0, R, G, B);
-
 
881
            Cube_Set_Pixel(7, 0, 7, R, G, B);
-
 
882
            Cube_Set_Pixel(7, 7, 7, R, G, B);
-
 
883
            Cube_Set_Pixel(7, 7, 0, R, G, B);
-
 
884
            break;
-
 
885
        default:
-
 
886
            break;
-
 
887
    }
-
 
888
}
-
 
889
 
-
 
890
void Cube_Set_Shell(uint8_t layer, uint8_t R, uint8_t G, uint8_t B) {
-
 
891
    // Sets the specified shell to the specific color
-
 
892
    // Shell 0 is the outermost layer, 3 is the innermost cube of pixels
-
 
893
    uint8_t i, j, k;
-
 
894
    
-
 
895
    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
896
        if ((layer == 0 || layer == 4)&&(i == 0 || i == 7)) {
-
 
897
            Cube_Set_Layer(i,R,G,B);
-
 
898
        } else if ((layer == 1 || layer == 4)&&(i == 1 || i == 6)) {
-
 
899
            for (j = 1; j < CUBE_ROW_COUNT-1; j++)
-
 
900
                for (k = 1; k < CUBE_COLUMN_COUNT-1; k++)
-
 
901
                    Cube_Set_Pixel(i,j,k,R,G,B);
-
 
902
        } else if ((layer == 2 || layer == 4)&&(i == 2 || i == 5)) {
-
 
903
            for (j = 2; j < CUBE_ROW_COUNT-2; j++)
-
 
904
                for (k = 2; k < CUBE_COLUMN_COUNT-2; k++)
-
 
905
                    Cube_Set_Pixel(i,j,k,R,G,B);
-
 
906
        } else if ((layer == 3 || layer == 4)&&(i == 3 || i == 4)) {
-
 
907
            for (j = 3; j < CUBE_ROW_COUNT-3; j++)
-
 
908
                for (k = 3; k < CUBE_COLUMN_COUNT-3; k++)
-
 
909
                    Cube_Set_Pixel(i,j,k,R,G,B);
-
 
910
        }
-
 
911
 
-
 
912
        if ((layer == 0 || layer == 4)&&(i > 0 && i < 8)) {
-
 
913
            for (j = 0; j < 8; j++) {
-
 
914
                Cube_Set_Pixel(i,j,0,R,G,B);
-
 
915
                Cube_Set_Pixel(i,j,7,R,G,B);
-
 
916
                Cube_Set_Pixel(i,0,j,R,G,B);
-
 
917
                Cube_Set_Pixel(i,7,j,R,G,B);
-
 
918
            }
-
 
919
        }
-
 
920
        if ((layer == 1 || layer == 4)&&(i > 1 && i < 7)) {
-
 
921
            for (j = 1; j < 7; j++) {
-
 
922
                Cube_Set_Pixel(i,j,1,R,G,B);
-
 
923
                Cube_Set_Pixel(i,j,6,R,G,B);
-
 
924
                Cube_Set_Pixel(i,1,j,R,G,B);
-
 
925
                Cube_Set_Pixel(i,6,j,R,G,B);
-
 
926
            }
-
 
927
        }
-
 
928
        if ((layer == 2 || layer == 4)&&(i > 2 && i < 6)) {
-
 
929
            for (j = 2; j < 6; j++) {
-
 
930
                Cube_Set_Pixel(i,j,2,R,G,B);
-
 
931
                Cube_Set_Pixel(i,j,5,R,G,B);
-
 
932
                Cube_Set_Pixel(i,2,j,R,G,B);
-
 
933
                Cube_Set_Pixel(i,5,j,R,G,B);
-
 
934
            }
-
 
935
        }
-
 
936
    }
-
 
937
}
-
 
938
 
247
void Cube_Rotate_Shell(uint8_t shell, uint8_t direction) {
939
void Cube_Rotate_Shell(uint8_t shell, uint8_t direction) {
248
    // Shell is the layer to rotate, with the outermost being 0
940
    // Shell is the layer to rotate, with the outermost being 0
249
    uint8_t layer;
941
    uint8_t layer;
250
    uint16_t origin_R, origin_G, origin_B;
942
    uint16_t origin_R, origin_G, origin_B;
251
    for (layer = 0; layer < CUBE_LAYER_COUNT; layer++) {
943
    for (layer = 0; layer < CUBE_LAYER_COUNT; layer++) {
Line 443... Line 1135...
443
        cube_data_ptr->rotation_counter = (cube_data_ptr->rotation_counter == 0)
1135
        cube_data_ptr->rotation_counter = (cube_data_ptr->rotation_counter == 0)
444
                ? CUBE_ROTATIONS - 1 : cube_data_ptr->rotation_counter - 1;
1136
                ? CUBE_ROTATIONS - 1 : cube_data_ptr->rotation_counter - 1;
445
    }
1137
    }
446
}
1138
}
447
 
1139
 
-
 
1140
void Cube_Shift_Row(uint8_t direction) {
-
 
1141
    // Shifts the display by an entire row
-
 
1142
    int i, j, k;
-
 
1143
    if (direction) {
-
 
1144
        // Shift values in each row by one
-
 
1145
        for (i = CUBE_ROW_COUNT - 1; i >= 0; i--) {   // Row
-
 
1146
            for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
-
 
1147
                for (k = 0; k < CUBE_LAYER_COUNT; k++) {
-
 
1148
                    Cube_Move_Pixel(k, i - 1, j, k, i, j);
-
 
1149
                }
-
 
1150
            }
-
 
1151
        }
-
 
1152
    } else {
-
 
1153
        for (i = 0; i < CUBE_ROW_COUNT - 1; i++) {
-
 
1154
            for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
-
 
1155
                for (k = 0; k < CUBE_LAYER_COUNT; k++) {
-
 
1156
                    Cube_Move_Pixel(k, i + 1, j, k, i, j);
-
 
1157
                }
-
 
1158
            }
-
 
1159
        }
-
 
1160
    }
-
 
1161
}
-
 
1162
 
-
 
1163
void Cube_Shift_Waterfall(uint8_t *values) {
-
 
1164
    // Takes an array of 8 values and sets them to the column height
-
 
1165
    // Each column is set to a manually specified color
-
 
1166
    uint8_t i, j;
-
 
1167
    uint8_t update_row = CUBE_ROW_COUNT - 1;
-
 
1168
 
-
 
1169
    // First shift the rows
-
 
1170
    Cube_Shift_Row(0);
-
 
1171
 
-
 
1172
    // Then update the empty row
-
 
1173
    for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
-
 
1174
        for (j = 0; j < CUBE_LAYER_COUNT; j++) {
-
 
1175
            if (j < values[i]) {
-
 
1176
                // Specify the color for each column
-
 
1177
                if (i == 0)
-
 
1178
                    Cube_Set_Pixel(j, update_row, i, RED);
-
 
1179
                else if (i == 1)
-
 
1180
                    Cube_Set_Pixel(j, update_row, i, ORANGE);
-
 
1181
                else if (i == 2)
-
 
1182
                    Cube_Set_Pixel(j, update_row, i, YELLOW);
-
 
1183
                else if (i == 3)
-
 
1184
                    Cube_Set_Pixel(j, update_row, i, GREEN);
-
 
1185
                else if (i == 4)
-
 
1186
                    Cube_Set_Pixel(j, update_row, i, TEAL);
-
 
1187
                else if (i == 5)
-
 
1188
                    Cube_Set_Pixel(j, update_row, i, BLUE);
-
 
1189
                else if (i == 6)
-
 
1190
                    Cube_Set_Pixel(j, update_row, i, PURPLE);
-
 
1191
                else
-
 
1192
                    Cube_Set_Pixel(j, update_row, i, WHITE);
-
 
1193
            } else {
-
 
1194
                Cube_Set_Pixel(j, update_row, i, CLEAR);
-
 
1195
            }
-
 
1196
        }
-
 
1197
    }
-
 
1198
}
-
 
1199
 
-
 
1200
void Cube_Shift_Waterfall2(uint8_t *values) {
-
 
1201
    // Takes an array of 8 values and sets them to the column height
-
 
1202
    // Each layer is set to a manually specified color
-
 
1203
    uint8_t i, j;
-
 
1204
    uint8_t update_row = CUBE_ROW_COUNT - 1;
-
 
1205
 
-
 
1206
    // First shift the rows
-
 
1207
    Cube_Shift_Row(0);
-
 
1208
 
-
 
1209
    // Then update the empty row
-
 
1210
    for (i = 0; i < CUBE_COLUMN_COUNT; i++) {
-
 
1211
        for (j = 0; j < CUBE_LAYER_COUNT; j++) {
-
 
1212
            if (j < values[i]) {
-
 
1213
                // Specify the color for each layer
-
 
1214
                if (j == 7)
-
 
1215
                    Cube_Set_Pixel(j, update_row, i, RED);
-
 
1216
                else if (j == 6)
-
 
1217
                    Cube_Set_Pixel(j, update_row, i, ORANGE);
-
 
1218
                else if (j == 5)
-
 
1219
                    Cube_Set_Pixel(j, update_row, i, YELLOW);
-
 
1220
                else if (j == 4)
-
 
1221
                    Cube_Set_Pixel(j, update_row, i, GREEN);
-
 
1222
                else if (j == 3)
-
 
1223
                    Cube_Set_Pixel(j, update_row, i, TEAL);
-
 
1224
                else if (j == 2)
-
 
1225
                    Cube_Set_Pixel(j, update_row, i, BLUE);
-
 
1226
                else if (j == 1)
-
 
1227
                    Cube_Set_Pixel(j, update_row, i, PURPLE);
-
 
1228
                else
-
 
1229
                    Cube_Set_Pixel(j, update_row, i, WHITE);
-
 
1230
            } else {
-
 
1231
                Cube_Set_Pixel(j, update_row, i, CLEAR);
-
 
1232
            }
-
 
1233
        }
-
 
1234
    }
-
 
1235
}
-
 
1236
 
448
///////////////////////////////
1237
///////////////////////////////
449
// Overlay control functions //
1238
// Overlay control functions //
450
///////////////////////////////
1239
///////////////////////////////
451
 
1240
 
452
void Cube_Overlay_Clear(void) {
1241
void Cube_Overlay_Clear(void) {
Line 849... Line 1638...
849
 
1638
 
850
void Cube_Ethernet_Frame_In(void) {
1639
void Cube_Ethernet_Frame_In(void) {
851
    uint8_t i,j,k;
1640
    uint8_t i,j,k;
852
    uint8_t buffer[2048] = {0};
1641
    uint8_t buffer[2048] = {0};
853
    uint16_t length;
1642
    uint16_t length;
854
    uint16_t index = 1;
-
 
855
 
1643
 
856
    // Read and process the ethernet packet
1644
    // Read and process the ethernet packet
857
    if (!ETH_Read_Packet(buffer, &length)) {
1645
    if (!ETH_Read_Packet(buffer, &length)) {
858
        // Check the opcode (first byte) to determine what to do
1646
        // Check the opcode (first byte) to determine what to do
859
 
1647
 
860
        if (buffer[0] == 0x1) {                 // 0x1 - Reset into Ethernet mode
1648
        if (buffer[0] == CUBE_ETH_RESET) {  // 0x1 - Reset into Ethernet mode
861
            Reset_Board(BOARD_MODE_ETHERNET);
1649
            Reset_Board(BOARD_MODE_ETHERNET);
-
 
1650
        } else if (Get_Board_State() == BOARD_MODE_ETHERNET) {
862
        } else if (buffer[0] == 0x2) {          // 0x2 - Reset back to idle mode
1651
            if (buffer[0] == CUBE_EHT_IDLE) {   // 0x2 - Reset back to idle mode
863
            Reset_Board(BOARD_MODE_IDLE);
1652
                Reset_Board(BOARD_MODE_IDLE);
864
        } else if (buffer[0] == 0xA) {          // 0xA - Clear the entire cube
1653
            } else if (buffer[0] == CUBE_ETH_CLEAR) {   // 0xA
865
            Cube_Clear();
1654
                Cube_Clear();
-
 
1655
            } else if (buffer[0] == CUBE_ETH_DCS) {     // 0xB
866
        } else if (buffer[0] == 0xB) {          // 0xB - Set the global brightness value
1656
                // Byte 1 = global brightness value
867
            Cube_Write_DCS(buffer[1]);
1657
                Cube_Write_DCS(buffer[1]);
-
 
1658
            } else if (buffer[0] == CUBE_ETH_ROTATE) {  // 0xC
-
 
1659
                // Byte 1 = directon to rotate
-
 
1660
                ClearWDT();
-
 
1661
                Cube_Rotate(buffer[1]);
-
 
1662
            } else if (buffer[0] == CUBE_ETH_ROTATE_LAYER) {    // 0xD
-
 
1663
                // Byte 1 = layer to rotate
-
 
1664
                // Byte 2 = direction to rotate
-
 
1665
                ClearWDT();
-
 
1666
                Cube_Rotate_Shell(buffer[1], buffer[2]);
868
        } else if (buffer[0] == 0xC) {          // 0xC - Set the entire cube
1667
            } else if (buffer[0] == CUBE_ETH_WRITE_ALL) {       // 0x10
-
 
1668
                // Byte 1+ = pixel color data (R/G/B)
869
            if (length == 0x0601) {
1669
                if (length == 0x0601) {
-
 
1670
                    ClearWDT();
-
 
1671
                    uint16_t index = 1;
-
 
1672
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
1673
                        for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
-
 
1674
                            for (k = 0; k < CUBE_ROW_COUNT; k++) {
-
 
1675
                                Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]);
-
 
1676
                                index = index + 3;
-
 
1677
                            }
-
 
1678
                        }
-
 
1679
                    }
-
 
1680
                }
-
 
1681
            } else if (buffer[0] == CUBE_ETH_WRITE_PIXEL) {     // 0x11
-
 
1682
                // Byte 1 = row index
-
 
1683
                // Byte 2 = column index
-
 
1684
                // Byte 3 = layer index
-
 
1685
                // Byte 4 = red channel
-
 
1686
                // Byte 5 = green channel
-
 
1687
                // Byte 6 = blue channel
870
                ClearWDT();
1688
                ClearWDT();
-
 
1689
                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
-
 
1691
                // Byte 1 = color channel, 0 = red, 1 = green, 2 = blue
-
 
1692
                // Byte 2+ = color data
-
 
1693
                uint16_t r, g, b;
-
 
1694
                uint16_t index = 2;
-
 
1695
                ClearWDT();
-
 
1696
                if (buffer[1] % 3 == 0) {
871
                for (i = 0; i < CUBE_LAYER_COUNT; i++) {
1697
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
872
                    for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
1698
                        for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
1699
                            for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
1700
//                                Cube_Get_Pixel(i, j, k, &r, &g, &b);
-
 
1701
                                Cube_Set_Pixel(i, j, k, buffer[index], 0x00, 0x00);
-
 
1702
                                index++;
-
 
1703
                            }
-
 
1704
                        }
-
 
1705
                    }
-
 
1706
                } else if (buffer[1] % 3 == 1) {
-
 
1707
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
873
                        for (k = 0; k < CUBE_ROW_COUNT; k++) {
1708
                        for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
1709
                            for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
1710
                                Cube_Get_Pixel(i, j, k, &r, &g, &b);
874
                            Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]);
1711
                                Cube_Set_Pixel(i, j, k, r, buffer[index], b);
-
 
1712
                                index++;
-
 
1713
                            }
-
 
1714
                        }
-
 
1715
                    }
-
 
1716
                } else {
-
 
1717
                    for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
1718
                        for (j = 0; j < CUBE_ROW_COUNT; j++) {
-
 
1719
                            for (k = 0; k < CUBE_COLUMN_COUNT; k++) {
-
 
1720
                                Cube_Get_Pixel(i, j, k, &r, &g, &b);
-
 
1721
                                Cube_Set_Pixel(i, j, k, r, g, buffer[index]);
875
                            index = index + 3;
1722
                                index++;
-
 
1723
                            }
876
                        }
1724
                        }
877
                    }
1725
                    }
878
                }
1726
                }
-
 
1727
            } else if (buffer[0] == CUBE_ETH_WRITE_TEXT) {      // 0x20
-
 
1728
                // Byte 1 = length of string
-
 
1729
                // Byte 2 = red channel
-
 
1730
                // Byte 3 = green channel
-
 
1731
                // Byte 4 = blue channel
-
 
1732
                // Byte 5 = update speed (ms)
-
 
1733
                // Byte 6+ = text string
-
 
1734
                if (buffer[1] != 0) {
-
 
1735
                    Cube_Text_Init(&buffer[6], buffer[1], buffer[2], buffer[3], buffer[4]);
-
 
1736
 
-
 
1737
                    TIMER4_Stop();
-
 
1738
                    TIMER4_Init(NULL, NULL, &Cube_Text_Interrupt, buffer[5]);
-
 
1739
                    TIMER4_Start();
-
 
1740
                } else {
-
 
1741
                    Cube_Overlay_Clear();
-
 
1742
                    TIMER4_Stop();
-
 
1743
                }
-
 
1744
            } else if (buffer[0] == CUBE_ETH_WATERFALL) {       // 0x30
-
 
1745
                // Byte 1 = height of column 0
-
 
1746
                // Byte 2 = height of column 1
-
 
1747
                // Byte 3 = height of column 2
-
 
1748
                // Byte 4 = height of column 3
-
 
1749
                // Byte 5 = height of column 4
-
 
1750
                // Byte 6 = height of column 5
-
 
1751
                // Byte 7 = height of column 6
-
 
1752
                // Byte 8 = height of column 7
-
 
1753
                Cube_Shift_Waterfall(&buffer[1]);
-
 
1754
            } else if (buffer[0] == CUBE_ETH_SPHERE) {          // 0x31
-
 
1755
                // Byte 1 = layer (0 = innermost)
-
 
1756
                // Byte 2 = red channel
-
 
1757
                // Byte 3 = green channel
-
 
1758
                // Byte 4 = blue channel
-
 
1759
                Cube_Set_Sphere(buffer[1], buffer[2], buffer[3], buffer[4]);
879
            }
1760
            }
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]);
-
 
884
        }
1761
        }
885
    }
1762
    }
886
}
-
 
887
1763
}
-
 
1764