123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
-
- #include <stdint.h>
- #include <stdlib.h>
- #include <avr/io.h>
- #include <avr/wdt.h>
-
- #include <buffhelp.h>
- #include <cube.h>
-
-
-
-
- void upWave(uint8_t i);
- void downWave(uint8_t i);
- void xWave1(uint8_t i);
- void xWave2(uint8_t i);
- void zWave1(uint8_t i);
- void zWave2(uint8_t i);
-
-
- #define NUMOFANIMATIONS 0
- uint8_t (*animations[NUMOFANIMATIONS])(void) = { };
-
- #define WAVELENGTH 2
-
- uint8_t numOfAnimations(void) {
- return NUMOFANIMATIONS + 24;
- }
-
- uint8_t executeAnimation(uint8_t id) {
- if (id < (6*4)) {
- if (id < 4) {
- upWave(id);
- } else if (id < 8) {
- downWave(id - 4);
- } else if (id < 12) {
- xWave1(id - 8);
- } else if (id < 16) {
- xWave2(id - 12);
- } else if (id < 20) {
- zWave1(id - 16);
- } else {
- zWave2(id - 20);
- }
- return 1;
- } else if ((id - (6*4)) < NUMOFANIMATIONS) {
- return animations[id - (6*4)]();
- }
- return 1;
- }
-
- void upWave(uint8_t i) {
- uint8_t *buff;
- int8_t x, y, z;
-
- buff = buffNew();
-
- for(y = (i * 2); y < ((i * 2) + 2); y++) {
- for(x = 0; x < 8; x++) {
- for(z = 0; z < 8; z++) {
- buffSetPixel(buff, x, y, z);
- }
- }
- setImage(buff);
- while(isFinished() < WAVELENGTH) {
- wdt_reset();
- }
- buffClearAllPixels(buff);
- }
- free(buff);
- }
-
- void downWave(uint8_t i) {
- uint8_t *buff;
- int8_t x, y, z;
-
- buff = buffNew();
-
- for(y = (7 - (2 * i)); y >= ((7 - (2 * i)) - 1); y--) {
- for(x = 0; x < 8; x++) {
- for(z = 0; z < 8; z++) {
- buffSetPixel(buff, x, y, z);
- }
- }
- setImage(buff);
- while(isFinished() < WAVELENGTH) {
- wdt_reset();
- }
- buffClearAllPixels(buff);
- }
- free(buff);
- }
-
- void xWave1(uint8_t i) {
- uint8_t *buff;
- int8_t x, y, z;
-
- buff = buffNew();
-
- for(x = (i * 2); x < ((i * 2) + 2); x++) {
- for(y = 0; y < 8; y++) {
- for(z = 0; z < 8; z++) {
- buffSetPixel(buff, x, y, z);
- }
- }
- setImage(buff);
- while(isFinished() < WAVELENGTH) {
- wdt_reset();
- }
- buffClearAllPixels(buff);
- }
- free(buff);
- }
-
- void xWave2(uint8_t i) {
- uint8_t *buff;
- int8_t x, y, z;
-
- buff = buffNew();
- for(x = (7 - (2 * i)); x >= ((7 - (2 * i)) - 1); x--) {
- for(y = 0; y < 8; y++) {
- for(z = 0; z < 8; z++) {
- buffSetPixel(buff, x, y, z);
- }
- }
- setImage(buff);
- while(isFinished() < WAVELENGTH) {
- wdt_reset();
- }
- buffClearAllPixels(buff);
- }
- free(buff);
- }
-
- void zWave1(uint8_t i) {
- uint8_t *buff;
- int8_t x, y, z;
-
- buff = buffNew();
-
- for(z = (i * 2); z < ((i * 2) + 2); z++) {
- for(y = 0; y < 8; y++) {
- for(x = 0; x < 8; x++) {
- buffSetPixel(buff, x, y, z);
- }
- }
- setImage(buff);
- while(isFinished() < WAVELENGTH) {
- wdt_reset();
- }
- buffClearAllPixels(buff);
- }
- free(buff);
- }
-
- void zWave2(uint8_t i) {
- uint8_t *buff;
- int8_t x, y, z;
-
- buff = buffNew();
- for(z = (7 - (2 * i)); z >= ((7 - (2 * i)) - 1); z--) {
- for(x = 0; x < 8; x++) {
- for(y = 0; y < 8; y++) {
- buffSetPixel(buff, x, y, z);
- }
- }
- setImage(buff);
- while(isFinished() < WAVELENGTH) {
- wdt_reset();
- }
- buffClearAllPixels(buff);
- }
- free(buff);
- }
|