Adjusted animation play method to read only one frame to display in advance

This commit is contained in:
Stefan H. 2018-12-29 13:59:19 +01:00
parent d94de7edd9
commit 4024970f80
3 changed files with 29 additions and 632 deletions

View file

@ -1,622 +0,0 @@
// the default Colormap
uint8_t colorMap[] = { 0x00, 0x00, 0x00,
0x19, 0x10, 0x28,
0x46, 0xaf, 0x45,
0xa1, 0xd6, 0x85,
0x45, 0x3e, 0x78,
0x76, 0x64, 0xfe,
0x43, 0x10, 0x10,
0x9e, 0xc2, 0xe8,
0xff, 0x43, 0x4b,
0xe1, 0x8d, 0x79,
0xd6, 0xb9, 0x7b,
0xe9, 0xd8, 0xa1,
0x21, 0x6c, 0x4b,
0xd3, 0x65, 0xc8,
0xaf, 0xaa, 0xb9,
0xf5, 0xf4, 0xeb };
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 = 50;
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
}
};

View file

@ -1,4 +1,3 @@
int getFileFrames(char* file) { int getFileFrames(char* file) {
File f = SPIFFS.open(file, "r"); File f = SPIFFS.open(file, "r");
String line; String line;
@ -27,7 +26,7 @@ int getFileFrames(char* file) {
void playFile(char* file, int framespeed) { void playFile(char* file, int framespeed) {
int frameNumber = getFileFrames(file); int frameNumber = getFileFrames(file);
int n = -1; int n = -1;
RgbColor *anim[frameNumber][64];; RgbColor *anim[64];;
//uint8_t anim[frameNumber][64*3]; //uint8_t anim[frameNumber][64*3];
File f = SPIFFS.open(file, "r"); File f = SPIFFS.open(file, "r");
@ -49,16 +48,23 @@ void playFile(char* file, int framespeed) {
for(int i=0; i<8; i++) { for(int i=0; i<8; i++) {
String rgbStr=line.substring(4+i*12,4+i*12+6); String rgbStr=line.substring(4+i*12,4+i*12+6);
uint32_t rgb = strtol(rgbStr.c_str(), NULL, 16); uint32_t rgb = strtol(rgbStr.c_str(), NULL, 16);
anim[frame][i*8+j] = new RgbColor(rgb & 0xFF, rgb>>8 & 0xFF, rgb>>16); anim[i*8+j] = new RgbColor(rgb & 0xFF, rgb>>8 & 0xFF, rgb>>16);
strip.SetPixelColor( i*8+j , *anim[i*8+j]);
strip.SetPixelColor( 64+i*8+j , *anim[i*8+j]);
} }
line = f.readStringUntil('\n'); line = f.readStringUntil('\n');
} }
strip.Show();
delay(framespeed);
line = f.readStringUntil('\n'); line = f.readStringUntil('\n'); line = f.readStringUntil('\n'); line = f.readStringUntil('\n');
for(int i=0; i<64; i++) {
delete anim[i];
}
} }
} }
f.close(); f.close();
Serial.println(frameNumber); /*Serial.println(frameNumber);
for(int frame=0; frame<frameNumber; frame++) { for(int frame=0; frame<frameNumber; frame++) {
//Serial.print("Sending Frame: "); Serial.println(frame); //Serial.print("Sending Frame: "); Serial.println(frame);
for(int i=0; i<strip.PixelCount()/2; i++) { for(int i=0; i<strip.PixelCount()/2; i++) {
@ -67,13 +73,13 @@ void playFile(char* file, int framespeed) {
} }
strip.Show(); strip.Show();
delay(framespeed); delay(framespeed);
} }*/
for(int frame=0; frame<frameNumber; frame++) { /*for(int frame=0; frame<frameNumber; frame++) {
for(int j=0; j<8; j++) { for(int j=0; j<8; j++) {
for(int i=0; i<8; i++) { for(int i=0; i<8; i++) {
delete anim[frame][i*8+j]; delete anim[frame][i*8+j];
} }
} }
} }*/
} }

View file

@ -8,10 +8,10 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <NeoPixelBus.h> #include <NeoPixelBus.h>
#include <NeoPixelBrightnessBus.h> #include <NeoPixelBrightnessBus.h>
#include "defaults.h"
#include <FS.h> #include <FS.h>
#include "defaults.h"
char* filename = "/Terminator2.c"; char* filename = "/Blink_center_getAngry.c";
RgbColor *c[16]; RgbColor *c[16];
RgbColor black(0); RgbColor black(0);
@ -100,7 +100,20 @@ void loop() {
strip.ClearTo(black); strip.ClearTo(black);
Serial.print("Framecounter of file: "); Serial.print("Framecounter of file: ");
playFile(filename, 100); playFile("/Center.c",2000);
playFile("/Blink_center.c", 100);
playFile("/Move_left.c", 100);
playFile("/Blink_left.c", 100);
playFile("/Move_left_center.c", 100);
playFile("/Blink_LSD_start.c", 100);
playFile("/Blink_LSD.c", 100);
playFile("/Blink_LSD.c", 100);
playFile("/Blink_LSD_end.c", 100);
playFile("/Blink_center.c", 100);
playFile("/Move_right.c", 100);
playFile("/Blink_right.c", 100);
playFile("/Move_right_center.c", 100);
playFile("/Blink_center_getAngry.c", 100);
/* Serial.println("Animation test ..."); /* Serial.println("Animation test ...");