create color-map-animation function, added one simple color animation

This commit is contained in:
Stefan H. 2018-12-16 22:04:41 +01:00
parent e5a3551d39
commit 95547cfe30
2 changed files with 113 additions and 8 deletions

View file

@ -28,7 +28,8 @@ const uint16_t PixelCount = 64; // Currently we have a 8x8 matrix connected
// make sure to set this to the correct pins
// SPI Hardware Pins: CLK=GPIO14=Pin12=D5 (orange), MOSI=GPIO13=Pin13=D7 (yellow)
NeoPixelBrightnessBus<DotStarBgrFeature, DotStarSpiMethod> strip(PixelCount);
//NeoPixelBrightnessBus<DotStarBgrFeature, DotStarSpiMethod> strip(PixelCount);
NeoPixelBus<DotStarBgrFeature, DotStarSpiMethod> strip(PixelCount);
void setup() {
Serial.begin(115200);
@ -39,7 +40,7 @@ void setup() {
// this resets all the neopixels to an off state
strip.Begin();
strip.SetBrightness(brightness);
//strip.SetBrightness(brightness);
strip.ClearTo(black);
strip.Show();
@ -64,7 +65,7 @@ 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));
if((anim[frame][n])&(1<<i)) strip.SetPixelColor(n*8+i, RgbColor(128));
else strip.SetPixelColor(n*8+i, RgbColor(0));
}
}
@ -72,6 +73,16 @@ void playBwAnimation(int animDelay, uint8_t anim[][8]) {
}
}
void playMapAnimation(int animDelay, uint8_t anim[][32]) {
for(int frame=0; frame<9; frame++) {
for(int n=0; n<strip.PixelCount()/2; n++) {
strip.SetPixelColor( 2*n , *c[(anim[frame][n]>>4 )] );
strip.SetPixelColor( 2*n+1, *c[(anim[frame][n]&0x0F)] );
}
strip.Show(); delay(animDelay);
}
}
void loop() {
Serial.println("Entering loop ...");
@ -80,7 +91,7 @@ void loop() {
strip.ClearTo(black);
Serial.println("Animation test ...");
playBwAnimation(50, eye_move_cr); delay(3000);
/*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);
@ -89,7 +100,9 @@ void loop() {
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);
playBwAnimation(50, eye_move_lc); delay(3000);*/
playMapAnimation(150, terminator);delay(3000);
/* Serial.println("Colormap test ...");
strip.ClearTo(black);

View file

@ -5,9 +5,9 @@ uint8_t colorMap[] = { 0x00, 0x00, 0x00,
0xa1, 0xd6, 0x85,
0x45, 0x3e, 0x78,
0x76, 0x64, 0xfe,
0x83, 0x31, 0x29,
0x43, 0x10, 0x10,
0x9e, 0xc2, 0xe8,
0xdc, 0x53, 0x4b,
0xff, 0x43, 0x4b,
0xe1, 0x8d, 0x79,
0xd6, 0xb9, 0x7b,
0xe9, 0xd8, 0xa1,
@ -16,7 +16,99 @@ uint8_t colorMap[] = { 0x00, 0x00, 0x00,
0xaf, 0xaa, 0xb9,
0xf5, 0xf4, 0xeb };
uint8_t brightness = 32;
uint8_t terminator[][32] = { {
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x06, 0x60, 0x06,
0x60, 0x68, 0x86, 0x06,
0x60, 0x68, 0x86, 0x06,
0x60, 0x06, 0x60, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x66, 0x00, 0x06,
0x66, 0x88, 0x60, 0x06,
0x66, 0x88, 0x60, 0x06,
0x60, 0x66, 0x00, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x66, 0x60, 0x00, 0x06,
0x68, 0x86, 0x00, 0x06,
0x68, 0x86, 0x00, 0x06,
0x66, 0x60, 0x00, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x66, 0x00, 0x06,
0x66, 0x88, 0x60, 0x06,
0x66, 0x88, 0x60, 0x06,
0x60, 0x66, 0x00, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x06, 0x60, 0x06,
0x60, 0x68, 0x86, 0x06,
0x60, 0x68, 0x86, 0x06,
0x60, 0x06, 0x60, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x00, 0x66, 0x06,
0x60, 0x06, 0x88, 0x66,
0x60, 0x06, 0x88, 0x66,
0x60, 0x00, 0x66, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x00, 0x06, 0x66,
0x60, 0x00, 0x68, 0x86,
0x60, 0x00, 0x68, 0x86,
0x60, 0x00, 0x06, 0x66,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x00, 0x66, 0x06,
0x60, 0x06, 0x88, 0x66,
0x60, 0x06, 0x88, 0x66,
0x60, 0x00, 0x66, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
},
{
0x00, 0x66, 0x66, 0x00,
0x06, 0x00, 0x00, 0x60,
0x60, 0x06, 0x60, 0x06,
0x60, 0x68, 0x86, 0x06,
0x60, 0x68, 0x86, 0x06,
0x60, 0x06, 0x60, 0x06,
0x06, 0x00, 0x00, 0x60,
0x00, 0x66, 0x66, 0x00
}
};
uint8_t brightness = 64;
uint8_t eye_blink_c[][8] = {
{