create bw-animation function, added a few arrays for bw-animations

This commit is contained in:
Stefan H. 2018-12-16 21:44:26 +01:00
parent f190e1a192
commit e5a3551d39
2 changed files with 539 additions and 68 deletions

View file

@ -58,6 +58,19 @@ void loadColorMap(uint8_t cmap[]) {
}
}
// play a given sub-animation
void playBwAnimation(int animDelay, uint8_t anim[][8]) {
for(int frame=0; frame<7; frame++) {
for(int n=0; n<strip.PixelCount()/8; n++) {
for(int i=0; i<8; i++) {
if((anim[frame][n])&(1<<i)) strip.SetPixelColor(n*8+i, RgbColor(255));
else strip.SetPixelColor(n*8+i, RgbColor(0));
}
}
strip.Show(); delay(animDelay);
}
}
void loop() {
Serial.println("Entering loop ...");
@ -67,35 +80,25 @@ void loop() {
strip.ClearTo(black);
Serial.println("Animation test ...");
for(int frame=0; frame<5; frame++) {
for(int n=0; n<strip.PixelCount()/8; n++) {
for(int i=0; i<8; i++) {
if((eye_blink[frame][n])&(1<<i)) strip.SetPixelColor(n*8+i, RgbColor(255));
else strip.SetPixelColor(n*8+i, RgbColor(0));
}
}
strip.Show(); delay(20);
}
delay(100);
for(int frame=3; frame>=0; frame--) {
for(int n=0; n<strip.PixelCount()/8; n++) {
for(int i=0; i<8; i++) {
if((eye_blink[frame][n])&(1<<i)) strip.SetPixelColor(n*8+i, RgbColor(255));
else strip.SetPixelColor(n*8+i, RgbColor(0));
}
}
strip.Show(); delay(20);
}
delay(2000);
Serial.println("Colormap test ...");
playBwAnimation(50, eye_move_cr); delay(3000);
playBwAnimation(50, eye_blink_r); delay(5000);
playBwAnimation(50, eye_blink_r); delay(3000);
playBwAnimation(50, eye_move_rc); delay(3000);
playBwAnimation(50, eye_blink_c); delay(3000);
playBwAnimation(50, eye_blink_c); delay(4000);
playBwAnimation(50, eye_blink_c); delay(3000);
playBwAnimation(50, eye_move_cl); delay(3000);
playBwAnimation(50, eye_blink_l); delay(2000);
playBwAnimation(50, eye_move_lc); delay(3000);
/* Serial.println("Colormap test ...");
strip.ClearTo(black);
for(int n=0; n<strip.PixelCount()/2; n++) {
strip.SetPixelColor( 2*n , *c[(test2[n]>>4 )] );
strip.SetPixelColor( 2*n+1, *c[(test2[n]&0x0F)] );
strip.Show(); delay(1000);
}
delay(10000);
delay(10000);*/
Serial.println("Loop end ...");
}

View file

@ -16,50 +16,518 @@ uint8_t colorMap[] = { 0x00, 0x00, 0x00,
0xaf, 0xaa, 0xb9,
0xf5, 0xf4, 0xeb };
uint8_t brightness = 64;
uint8_t brightness = 32;
uint8_t eye_blink_c[][8] = {
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
},
{
B00000000,
B00111100,
B01111110,
B11100111,
B11101111,
B01111110,
B00111100,
B00000000
},
{
B00000000,
B00000000,
B01111110,
B11100111,
B01111110,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00000000,
B00000000,
B11111111,
B11111111,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00000000,
B01111110,
B11100111,
B01111110,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00111100,
B01111110,
B11100111,
B11101111,
B01111110,
B00111100,
B00000000
},
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
}
};
uint8_t eye_blink_l[][8] = {
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
},
{
B00000000,
B00111100,
B01111110,
B10011111,
B10111111,
B01111110,
B00111100,
B00000000
},
{
B00000000,
B00000000,
B01111110,
B10011111,
B01111110,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00000000,
B00000000,
B11111111,
B11111111,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00000000,
B01111110,
B10011111,
B01111110,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00111100,
B01111110,
B10011111,
B10111111,
B01111110,
B00111100,
B00000000
},
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
}
};
uint8_t eye_blink_r[][8] = {
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
},
{
B00000000,
B00111100,
B01111110,
B11111001,
B11111011,
B01111110,
B00111100,
B00000000
},
{
B00000000,
B00000000,
B01111110,
B11111001,
B01111110,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00000000,
B00000000,
B11111111,
B11111111,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00000000,
B01111110,
B11111001,
B01111110,
B00000000,
B00000000,
B00000000
},
{
B00000000,
B00111100,
B01111110,
B11111001,
B11111011,
B01111110,
B00111100,
B00000000
},
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
}
};
uint8_t eye_move_cr[][8] = {
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11110011,
B11110111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11110011,
B11110111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
}
};
uint8_t eye_move_rc[][8] = {
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11111001,
B11111011,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11110011,
B11110111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11110011,
B11110111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
}
};
uint8_t eye_move_cl[][8] = {
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11001111,
B11011111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11001111,
B11011111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
}
};
uint8_t eye_move_lc[][8] = {
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B10011111,
B10111111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11001111,
B11011111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11001111,
B11011111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
},
{
B00111100,
B01111110,
B11111111,
B11100111,
B11101111,
B11111111,
B01111110,
B00111100
}
};
uint8_t eye_blink[][8] = {
{ B00111100,
B01000010,
B10000001,
B10001101,
B10001101,
B10000001,
B01000010,
B00111100 },
{ B00111100,
B01111110,
B10000001,
B10001101,
B10001101,
B10000001,
B01111110,
B00111100 },
{ B00000000,
B00111100,
B01111110,
B10000001,
B10000001,
B01111110,
B00111100,
B00000000 },
{ B00000000,
B00000000,
B01111110,
B11111111,
B11111111,
B01111110,
B00000000,
B00000000 },
{ B00000000,
B00000000,
B00000000,
B11111111,
B11111111,
B00000000,
B00000000,
B00000000 } };