added function to play two frame-equal animations simulatniously on one eye each; some minor code cleanups
This commit is contained in:
parent
6484f6dc71
commit
42a7dd2805
2 changed files with 70 additions and 38 deletions
|
@ -61,23 +61,70 @@ void playFile(char* file, int framespeed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.close();
|
f.close();
|
||||||
|
}
|
||||||
/*Serial.println(frameNumber);
|
|
||||||
for(int frame=0; frame<frameNumber; frame++) {
|
void playLRFile(char* lfile, char* rfile, int framespeed) {
|
||||||
//Serial.print("Sending Frame: "); Serial.println(frame);
|
int leftFrameNumber = getFileFrames(lfile);
|
||||||
for(int i=0; i<strip.PixelCount()/2; i++) {
|
int rightFrameNumber = getFileFrames(rfile);
|
||||||
strip.SetPixelColor( i , *anim[frame][i]);
|
int n = -1;
|
||||||
strip.SetPixelColor( 64+i , *anim[frame][i]);
|
RgbColor *lanim[64];
|
||||||
}
|
RgbColor *ranim[64];;
|
||||||
strip.Show();
|
|
||||||
delay(framespeed);
|
File lf = SPIFFS.open(lfile, "r");
|
||||||
}*/
|
File rf = SPIFFS.open(rfile, "r");
|
||||||
|
|
||||||
/*for(int frame=0; frame<frameNumber; frame++) {
|
String lline, rline;
|
||||||
for(int j=0; j<8; j++) {
|
char rgbChar[8];
|
||||||
for(int i=0; i<8; i++) {
|
String rgbStr;
|
||||||
delete anim[frame][i*8+j];
|
uint32_t rgb;
|
||||||
}
|
|
||||||
}
|
if(leftFrameNumber != rightFrameNumber) { Serial.println("Frame mismatch for playLRFile"); return; }
|
||||||
}*/
|
|
||||||
|
// load file into array
|
||||||
|
if (!lf | !rf) {
|
||||||
|
Serial.println("Cannot open any of the left-/rightfile!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// forward to first hex number
|
||||||
|
while(lf.available() && n<0) {
|
||||||
|
lline = lf.readStringUntil('\n');
|
||||||
|
n = lline.lastIndexOf("0x");
|
||||||
|
}
|
||||||
|
n=-1;
|
||||||
|
while(rf.available() && n<0) {
|
||||||
|
rline = rf.readStringUntil('\n');
|
||||||
|
n = rline.lastIndexOf("0x");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int frame=0; frame<leftFrameNumber; frame++) {
|
||||||
|
for(int j=0; j<8; j++) {
|
||||||
|
for(int i=0; i<8; i++) {
|
||||||
|
rgbStr=lline.substring(4+i*12,4+i*12+6);
|
||||||
|
rgb = strtol(rgbStr.c_str(), NULL, 16);
|
||||||
|
lanim[i*8+j] = new RgbColor(rgb & 0xFF, rgb>>8 & 0xFF, rgb>>16);
|
||||||
|
strip.SetPixelColor( i*8+j , *lanim[i*8+j]);
|
||||||
|
|
||||||
|
rgbStr=rline.substring(4+i*12,4+i*12+6);
|
||||||
|
rgb = strtol(rgbStr.c_str(), NULL, 16);
|
||||||
|
ranim[i*8+j] = new RgbColor(rgb & 0xFF, rgb>>8 & 0xFF, rgb>>16);
|
||||||
|
strip.SetPixelColor( 64+i*8+j , *ranim[i*8+j]);
|
||||||
|
}
|
||||||
|
lline = lf.readStringUntil('\n');
|
||||||
|
rline = rf.readStringUntil('\n');
|
||||||
|
}
|
||||||
|
strip.Show();
|
||||||
|
delay(framespeed);
|
||||||
|
|
||||||
|
if(frame<leftFrameNumber-1) {
|
||||||
|
lline = lf.readStringUntil('\n'); lline = lf.readStringUntil('\n');
|
||||||
|
rline = rf.readStringUntil('\n'); rline = rf.readStringUntil('\n');
|
||||||
|
}
|
||||||
|
for(int i=0; i<64; i++) {
|
||||||
|
delete lanim[i];
|
||||||
|
delete ranim[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lf.close();
|
||||||
|
rf.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,10 +113,10 @@ void loop() {
|
||||||
playFile("/Move_right.c", 100);
|
playFile("/Move_right.c", 100);
|
||||||
playFile("/Blink_right.c", 100);
|
playFile("/Blink_right.c", 100);
|
||||||
playFile("/Move_right_center.c", 100);
|
playFile("/Move_right_center.c", 100);
|
||||||
playFile("/Blink_center_getAngry.c", 100);
|
playLRFile("/Blink_center_getAngry.c", "/Blink_center_getAngry.c", 100);
|
||||||
|
|
||||||
|
|
||||||
/* Serial.println("Animation test ...");
|
/*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(5000);
|
||||||
playBwAnimation(50, eye_blink_r); delay(3000);
|
playBwAnimation(50, eye_blink_r); delay(3000);
|
||||||
|
@ -126,23 +126,8 @@ void loop() {
|
||||||
playBwAnimation(50, eye_blink_c); delay(3000);
|
playBwAnimation(50, eye_blink_c); delay(3000);
|
||||||
playBwAnimation(50, eye_move_cl); delay(3000);
|
playBwAnimation(50, eye_move_cl); delay(3000);
|
||||||
playBwAnimation(50, eye_blink_l); delay(2000);
|
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);*/
|
||||||
/*playMapAnimation(150, terminator);delay(3000);*/
|
|
||||||
|
|
||||||
/* for(int n=0; n<strip.PixelCount(); n++) {
|
|
||||||
strip.SetPixelColor(n, 20 );
|
|
||||||
strip.Show(); delay(100);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* 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);*/
|
|
||||||
|
|
||||||
Serial.println("Loop end ...");
|
Serial.println("Loop end ...");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue