From 4024970f801ef152af8dbdca7282f6535278e14e Mon Sep 17 00:00:00 2001 From: Stefan Heinrichsen Date: Sat, 29 Dec 2018 13:59:19 +0100 Subject: [PATCH] Adjusted animation play method to read only one frame to display in advance --- UNHB-Esel/Defaults.ino | 622 ------------------------------------- UNHB-Esel/FileHandling.ino | 20 +- UNHB-Esel/UNHB-Esel.ino | 19 +- 3 files changed, 29 insertions(+), 632 deletions(-) delete mode 100644 UNHB-Esel/Defaults.ino diff --git a/UNHB-Esel/Defaults.ino b/UNHB-Esel/Defaults.ino deleted file mode 100644 index 8988ff8..0000000 --- a/UNHB-Esel/Defaults.ino +++ /dev/null @@ -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 -} -}; diff --git a/UNHB-Esel/FileHandling.ino b/UNHB-Esel/FileHandling.ino index 7791e9f..0f73027 100644 --- a/UNHB-Esel/FileHandling.ino +++ b/UNHB-Esel/FileHandling.ino @@ -1,4 +1,3 @@ - int getFileFrames(char* file) { File f = SPIFFS.open(file, "r"); String line; @@ -27,7 +26,7 @@ int getFileFrames(char* file) { void playFile(char* file, int framespeed) { int frameNumber = getFileFrames(file); int n = -1; - RgbColor *anim[frameNumber][64];; + RgbColor *anim[64];; //uint8_t anim[frameNumber][64*3]; File f = SPIFFS.open(file, "r"); @@ -49,16 +48,23 @@ void playFile(char* file, int framespeed) { for(int i=0; i<8; i++) { String rgbStr=line.substring(4+i*12,4+i*12+6); 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'); } + strip.Show(); + delay(framespeed); line = f.readStringUntil('\n'); line = f.readStringUntil('\n'); + for(int i=0; i<64; i++) { + delete anim[i]; + } } } f.close(); - Serial.println(frameNumber); + /*Serial.println(frameNumber); for(int frame=0; frame #include #include -#include "defaults.h" #include +#include "defaults.h" -char* filename = "/Terminator2.c"; +char* filename = "/Blink_center_getAngry.c"; RgbColor *c[16]; RgbColor black(0); @@ -100,7 +100,20 @@ void loop() { strip.ClearTo(black); 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 ...");