13 #define version "1.0 beta"
26 #include "animation_codes.h"
33 int ask_for_slow_down_factor(
void);
35 uint8_t ask_for_pwm(
char c_color);
46 void write_frame(uint8_t (*p_fb_data_virtual)[5][5][5],
48 uint16_t (*p_commands),
54 char *p_animation_name);
65 void clear_real_framebuffer(uint16_t (*p_anim_stream)[max_size_anim_stream]);
67 void show_preview(uint8_t (*p_fb_data_virtual)[5][5][5],
68 uint32_t i_frame_counter,
75 float f_virtual_time);
87 int i_slowdown_factor;
96 i_slowdown_factor = ask_for_slow_down_factor();
133 "+---------------------------------------------------------------------------+"
135 "| Hello and welcome! This is simple animation maker for RGB 5x5x5 LED cube. |"
137 "| First i need to know name for your animation, so please type animation |"
139 "| name. Please DO NOT USE spaces! |"
141 "+---------------------------------------------------------------------------+"
142 "\n| Animation name: ");
147 status = scanf(
"%s", p_animation_name );
152 "| !! Sorry, this can not be used as animation name :( |"
154 "+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+"
161 "+---------------------------------------------------------------------------+"
170 int ask_for_slow_down_factor(
void)
172 int i_slowdown_factor = 0;
175 "| OK, now we need slowdown factor. Normally LED cube produce 25 fps. That |"
177 "| means we need 25 frames for 1 second. However, sometimes is not need to |"
179 "| have 25 fps. And for this is slowdown factor. If is set to 1, then LED |"
181 "| cube produce 25 fps. If is set to 2, then 12.5 fps and so on. Maximum |"
183 "| value should not exceed 255. So please type slowdown factor. |"
185 "+---------------------------------------------------------------------------+"
186 "\n| Slowdown factor: "
197 status = scanf(
"%s", c_input_data);
207 if( c_input_data[i] ==
'\0' )
217 if( (c_input_data[i]<
'0') || (c_input_data[i]>
'9'))
226 "| !! Sorry. this is not valid number. Please type number from 1 to 255 |"
228 "| Slowdown factor: ");
233 i_slowdown_factor = 0;
238 for(i=i-1 ; i>=0 ; i--)
243 i_slowdown_factor = i_slowdown_factor +
244 i_mul * ((c_input_data[i])-
'0');
256 if( i_slowdown_factor <= 0 )
258 i_slowdown_factor = 1;
260 "| ! Warning: Slowdown factor can not be smaller than 1 -> set to 1. |"
268 if( i_slowdown_factor > 255 )
270 i_slowdown_factor = 255;
272 "| ! Warning: Slowdown factor can not be greater than 255 -> set to 255. |"
277 return i_slowdown_factor;
288 uint8_t ask_for_pwm(
char c_color)
290 uint8_t i_pwm_value = 0;
298 case 'R': printf(
"| PWM - RED - value: ");
break;
299 case 'r': printf(
"| PWM - RED - value: ");
break;
300 case 'G': printf(
"| PWM - GREEN - value: ");
break;
301 case 'g': printf(
"| PWM - GREEN - value: ");
break;
302 case 'B': printf(
"| PWM - BLUE - value: ");
break;
303 case 'b': printf(
"| PWM - BLUE - value: ");
break;
304 default: printf(
"| PWM - value: ");
314 status = scanf(
"%s", c_value);
317 printf(
"\nPruser\n");
327 if( (c_value[0]>=
'0' || c_value[0]<=
'9') &&
328 (c_value[1]>=
'0' || c_value[1]<=
'9') &&
329 (c_value[2]>=
'0' || c_value[2]<=
'9') )
336 i_pwm_value = (c_value[0]-
'0');
339 else if(c_value[2]==
'\0')
341 i_pwm_value = 10 * (c_value[0]-
'0');
342 i_pwm_value = i_pwm_value + (c_value[1]-
'0');
347 i_pwm_value = 100 * (c_value[0]-
'0');
348 i_pwm_value = i_pwm_value + 10 * (c_value[1]-
'0');
349 i_pwm_value = i_pwm_value + (c_value[2]-
'0');
352 if(i_pwm_value > 255)
355 "| ! Warning: PWM value can not be greater than 255 -> set 255. |"
364 "| !! Sorry. this is not valid number. Please type number from 1 to 255 |"
371 case 'R': printf(
"\n| PWM - RED - value: ");
break;
372 case 'r': printf(
"\n| PWM - RED - value: ");
break;
373 case 'G': printf(
"\n| PWM - GREEN - value: ");
break;
374 case 'g': printf(
"\n| PWM - GREEN - value: ");
break;
375 case 'B': printf(
"\n| PWM - BLUE - value: ");
break;
376 case 'b': printf(
"\n| PWM - BLUE - value: ");
break;
377 default: printf(
"\n| PWM - value: ");
408 strcpy(c_file_and_path, generated_anime_folder);
410 strcat(c_file_and_path,
"/anim_");
412 strcat(c_file_and_path, p_animation_name);
414 strcat(c_file_and_path,
".h");
417 file = fopen( c_file_and_path,
"w+");
419 char c_file_content[3000];
422 strcpy(c_file_content,
"\\n\
441 strcat(c_file_content, p_animation_name);
442 strcat(c_file_content,
"_library_\n#define _anim_");
443 strcat(c_file_content, p_animation_name);
444 strcat(c_file_content,
"_library_\n\n"
445 "/*-----------------------------------------*\n"
447 " *-----------------------------------------*/\n"
448 "#include <avr/pgmspace.h> // For operations with flash memory\n"
449 "#include <inttypes.h> // Data types\n"
451 "#include \"animation_codes.h\" // For more \"human read\" animation code\n"
453 "extern const uint16_t bin_anim_");
454 strcat(c_file_content, p_animation_name);
455 strcat(c_file_content,
"[];\n"
460 fprintf(file,
"%s", c_file_content);
471 strcpy(c_file_and_path, generated_anime_folder);
473 strcat(c_file_and_path,
"/anim_");
475 strcat(c_file_and_path, p_animation_name);
477 strcat(c_file_and_path,
".c");
480 file = fopen( c_file_and_path,
"w+");
483 strcpy(c_file_content,
"\\n"
502 strcat(c_file_content, p_animation_name);
503 strcat(c_file_content,
".h\"\n"
505 "/* Data format (binary data for framebuffer)\n"
506 " * |MSB| |LSB|MSB| |LSB|MSB| |LSB|\n"
507 " * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"
508 " * | 0 | R | R | R | R | R | G | G | G | G | G | B | B | B | B | B |\n"
509 " * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"
511 " * Instruction format (if MSB is 1, then it is possible change some settings)"
512 "\n * |MSB| |LSB|MSB| |LSB|MSB| |LSB|\n"
513 " * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"
514 " * | 1 | C | C | C | C | C | C | C | V | V | V | V | V | V | V | V |\n"
515 " * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"
516 " * C - command (0~127)\n"
517 " * V - value (0~255)\n"
520 "const uint16_t bin_anim_");
522 strcat(c_file_content, p_animation_name);
523 strcat(c_file_content,
"[] PROGMEM =\n { // Serial stream of data\n");
526 fprintf(file,
"%s", c_file_content);
543 if( (i_slowdown_factor > 255) || (i_slowdown_factor < 0))
545 i_slowdown_factor = 0;
547 "| ! Warning: i_slowdown_factor out of range. Set to 0 (default) |"
560 strcpy(c_file_and_path, generated_anime_folder);
562 strcat(c_file_and_path,
"/anim_");
564 strcat(c_file_and_path, p_animation_name);
566 strcat(c_file_and_path,
".c");
569 file = fopen( c_file_and_path,
"a+");
571 char c_file_content[256];
573 strcpy(c_file_content,
""
574 " // Command start of animation + value (slowdown factor)\n"
579 char c_number_as_text[4];
580 sprintf( c_number_as_text,
"%d", i_slowdown_factor);
582 strcat(c_file_content, c_number_as_text);
583 strcat(c_file_content,
",\n //Data + other commands (body)\n");
586 fprintf(file,
"%s", c_file_content);
603 "+---------------------------------------------------------------------------+"
605 "| So, now i enable creative mode ;) There you can build your own animation. |"
607 "| Ready? If yes, then enter |"
609 "+---------------------------------------------------------------------------+"
616 char c_pressed_key =
'\0';
619 while( c_pressed_key ==
'\0')
621 c_pressed_key = getchar();
626 uint32_t i_frame_counter = 0;
628 uint8_t i_column = 0;
630 uint8_t i_pwm_r = 255;
631 uint8_t i_pwm_g = 255;
632 uint8_t i_pwm_b = 255;
634 float f_virtual_time = 0;
636 uint8_t i_led_level = 4;
640 uint8_t i_fb_data_virtual[5][5][5];
649 clear_real_framebuffer( &i_anim_stream );
658 uint8_t i_command_index = 0;
667 int animation_done = 0;
669 while( animation_done == 0 )
674 show_preview( &i_fb_data_virtual,
690 status = scanf(
"%s", c_cmd);
695 if( (strcmp(c_cmd,
"exit")==0) ||
696 (strcmp(c_cmd,
"Exit")==0) ||
697 (strcmp(c_cmd,
"EXIT")==0) ||
698 (strcmp(c_cmd,
"e") ==0) )
704 if( (strcmp(c_cmd,
"zeros")==0) ||
705 (strcmp(c_cmd,
"Zeros")==0) ||
706 (strcmp(c_cmd,
"ZEROS")==0) )
708 status = pressed_button;
709 for(
int j=0 ; j<5 ; j++)
711 for(
int k=0 ; k<5 ; k++)
713 i_fb_data_virtual[i_wall][j][k] = 0;
719 if( (strcmp(c_cmd,
"ones")==0) ||
720 (strcmp(c_cmd,
"Ones")==0) ||
721 (strcmp(c_cmd,
"ONES")==0) )
723 status = pressed_button;
724 for(
int j=0 ; j<5 ; j++)
726 for(
int k=0 ; k<5 ; k++)
728 i_fb_data_virtual[i_wall][j][k] = (1<<
red_shift)|
736 if( (strcmp(c_cmd,
"pwmr")==0) ||
737 (strcmp(c_cmd,
"Pwmr")==0) ||
738 (strcmp(c_cmd,
"PWMR")==0) )
740 i_pwm_r = ask_for_pwm(
'R');
746 if( (strcmp(c_cmd,
"pwmg")==0) ||
747 (strcmp(c_cmd,
"Pwmg")==0) ||
748 (strcmp(c_cmd,
"PWMG")==0) )
750 i_pwm_g = ask_for_pwm(
'G');
756 if( (strcmp(c_cmd,
"pwmb")==0) ||
757 (strcmp(c_cmd,
"Pwmb")==0) ||
758 (strcmp(c_cmd,
"PWMB")==0) )
760 i_pwm_b = ask_for_pwm(
'B');
766 if( (strcmp(c_cmd,
"line")==0) ||
767 (strcmp(c_cmd,
"Line")==0) ||
768 (strcmp(c_cmd,
"LINE")==0) ||
769 (strcmp(c_cmd,
"l") ==0) )
771 status = pressed_button;
774 uint8_t i_segment = i_fb_data_virtual[i_wall][i_led_level][i_column];
776 for(
int i=0 ; i<5 ; i++)
778 i_fb_data_virtual[i_wall][i_led_level][i] = i_segment;
783 if( (strcmp(c_cmd,
"column")==0) ||
784 (strcmp(c_cmd,
"Column")==0) ||
785 (strcmp(c_cmd,
"COLUMN")==0) ||
786 (strcmp(c_cmd,
"c") ==0) )
788 status = pressed_button;
791 uint8_t i_segment = i_fb_data_virtual[i_wall][i_led_level][i_column];
793 for(
int i=0 ; i<5 ; i++)
795 i_fb_data_virtual[i_wall][i][i_column] = i_segment;
801 if( c_cmd[0]==27 && c_cmd[1]==91 && c_cmd[2]==65 && c_cmd[3]==0)
804 status = pressed_button;
814 if( c_cmd[0]==27 && c_cmd[1]==91 && c_cmd[2]==66 && c_cmd[3]==0)
817 status = pressed_button;
827 if( c_cmd[0]==27 && c_cmd[1]==91 && c_cmd[2]==67 && c_cmd[3]==0)
830 status = pressed_button;
840 if( c_cmd[0]==27 && c_cmd[1]==91 && c_cmd[2]==68 && c_cmd[3]==0)
843 status = pressed_button;
853 if( (strcmp(c_cmd,
"next")==0) ||
854 (strcmp(c_cmd,
"Next")==0) ||
855 (strcmp(c_cmd,
"NEXT")==0) ||
856 (strcmp(c_cmd,
"n") ==0) )
859 status = pressed_button;
867 i_commands[i_command_index] = 0;
878 f_virtual_time = f_virtual_time + (
frame_period*i_slowdown_factor);
883 if( (strcmp(c_cmd,
"back")==0) ||
884 (strcmp(c_cmd,
"Back")==0) ||
885 (strcmp(c_cmd,
"BACK")==0) ||
886 (strcmp(c_cmd,
"m") ==0) )
889 status = pressed_button;
916 if(((c_cmd[0]==
'A' || c_cmd[0]==
'a' || c_cmd[0]==
'1' ||
917 c_cmd[0]==
'R' || c_cmd[0]==
'G' || c_cmd[0]==
'B' ||
918 c_cmd[0]==
'r' || c_cmd[0]==
'g' || c_cmd[0]==
'b' ||
919 c_cmd[0]==
'0' || c_cmd[0]==
'-') ||
922 c_cmd[1]==
'R' || c_cmd[1]==
'G' || c_cmd[1]==
'B' ||
923 c_cmd[1]==
'r' || c_cmd[1]==
'g' || c_cmd[1]==
'b' ||
924 c_cmd[1]==
'0' || c_cmd[1]==
'-') ||
927 c_cmd[2]==
'R' || c_cmd[2]==
'G' || c_cmd[2]==
'B' ||
928 c_cmd[2]==
'r' || c_cmd[2]==
'g' || c_cmd[2]==
'b' ||
929 c_cmd[2]==
'0' || c_cmd[2]==
'-')) &&
932 ( status != pressed_button ) &&
933 ( c_cmd[0]!=27 ) && (c_cmd[1]!=91) && (c_cmd[3]!=27) && (c_cmd[4]!=91)
938 i_fb_data_virtual[i_wall][i_led_level][i_column] = 0;
942 if( c_cmd[0]==
'r' || c_cmd[0]==
'R' || c_cmd[0]==
'a' || c_cmd[0]==
'A' ||
943 c_cmd[1]==
'r' || c_cmd[1]==
'R' || c_cmd[0]==
'1' ||
944 c_cmd[2]==
'r' || c_cmd[2]==
'R' )
946 i_fb_data_virtual[i_wall][i_led_level][i_column] |= (1<<
red_shift);
950 if( c_cmd[0]==
'g' || c_cmd[0]==
'G' || c_cmd[0]==
'a' || c_cmd[0]==
'A' ||
951 c_cmd[1]==
'g' || c_cmd[1]==
'G' || c_cmd[1]==
'1' ||
952 c_cmd[2]==
'g' || c_cmd[2]==
'G' )
954 i_fb_data_virtual[i_wall][i_led_level][i_column] |= (1<<green_shift);
957 if( c_cmd[0]==
'b' || c_cmd[0]==
'B' || c_cmd[0]==
'a' || c_cmd[0]==
'A' ||
958 c_cmd[1]==
'b' || c_cmd[1]==
'B' || c_cmd[2]==
'1' ||
959 c_cmd[2]==
'b' || c_cmd[2]==
'B' )
961 i_fb_data_virtual[i_wall][i_led_level][i_column] |= (1<<blue_shift);
969 if( status != pressed_button )
988 i_commands[i_command_index] = 0;
1001 f_virtual_time = f_virtual_time + (
frame_period*i_slowdown_factor);
1020 strcpy(c_file_and_path, generated_anime_folder);
1022 strcat(c_file_and_path,
"/anim_");
1024 strcat(c_file_and_path, p_animation_name);
1028 "+---------------------------------------------------------------------------+"
1030 "| Your animation files are: |"
1032 "| ./%s.c\n| ./%s.h\n"
1033 "+---------------------------------------------------------------------------+"
1036 ,c_file_and_path, c_file_and_path);
1053 uint16_t (*p_anim_stream)[max_size_anim_stream],
1054 uint16_t (*p_commands),
1058 uint8_t i_column_cnt = 0;
1061 uint32_t i_actual_frame = 0;
1064 uint64_t i_index_cnt = 0;
1067 uint16_t i_anime_word;
1070 while( (i_actual_frame < i_frame) & (i_frame != 0) )
1073 i_anime_word = (*p_anim_stream)[i_index_cnt];
1079 if( (i_anime_word & 0x8000)==0 )
1084 if(i_column_cnt == 25)
1098 i_anime_word = (*p_commands);
1102 while( (i_anime_word & 0x8000) != 0 )
1104 (*p_anim_stream)[i_index_cnt] = i_anime_word;
1110 i_anime_word = (*p_commands);
1114 for(
int i=0 ; i<5 ; i++)
1116 for(
int j=0 ; j<5 ; j++)
1121 for(
int k=0 ; k<5 ; k++)
1125 (((*p_fb_data_virtual)[i][k][j]) & (0b100))
1130 (((*p_fb_data_virtual)[i][k][j]) & (0b010))
1131 <<((green_shift*5)+k-green_shift);
1135 (((*p_fb_data_virtual)[i][k][j]) & (0b001))
1136 <<((blue_shift*5)+k-blue_shift);
1140 (*p_anim_stream)[i_index_cnt++] = i_anime_word;
1156 char *p_animation_name)
1165 strcpy(c_file_and_path, generated_anime_folder);
1167 strcat(c_file_and_path,
"/anim_");
1169 strcat(c_file_and_path, p_animation_name);
1171 strcat(c_file_and_path,
".c");
1174 file = fopen( c_file_and_path,
"a+");
1178 char c_tmp_txt[512];
1180 fprintf(file,
" // Frame 0\n ");
1187 uint32_t i_actual_frame = 0;
1190 uint8_t i_actual_wall = 0;
1193 uint8_t i_actual_column = 0;
1196 uint64_t i_word_index = 0;
1199 uint16_t i_anime_word;
1204 uint8_t i_command_created = 0;
1209 while( i_actual_frame < i_frame )
1212 i_anime_word = (*p_anim_stream)[i_word_index];
1215 i_command_created = 0;
1220 if( (*p_anim_stream)[i_word_index+ 0] == 0 &&
1221 (*p_anim_stream)[i_word_index+ 1] == 0 &&
1222 (*p_anim_stream)[i_word_index+ 2] == 0 &&
1223 (*p_anim_stream)[i_word_index+ 3] == 0 &&
1224 (*p_anim_stream)[i_word_index+ 4] == 0 &&
1225 (*p_anim_stream)[i_word_index+ 5] == 0 &&
1226 (*p_anim_stream)[i_word_index+ 6] == 0 &&
1227 (*p_anim_stream)[i_word_index+ 7] == 0 &&
1228 (*p_anim_stream)[i_word_index+ 8] == 0 &&
1229 (*p_anim_stream)[i_word_index+ 9] == 0 &&
1230 (*p_anim_stream)[i_word_index+10] == 0 &&
1231 (*p_anim_stream)[i_word_index+11] == 0 &&
1232 (*p_anim_stream)[i_word_index+12] == 0 &&
1233 (*p_anim_stream)[i_word_index+13] == 0 &&
1234 (*p_anim_stream)[i_word_index+14] == 0 &&
1235 (*p_anim_stream)[i_word_index+15] == 0 &&
1236 (*p_anim_stream)[i_word_index+16] == 0 &&
1237 (*p_anim_stream)[i_word_index+17] == 0 &&
1238 (*p_anim_stream)[i_word_index+18] == 0 &&
1239 (*p_anim_stream)[i_word_index+19] == 0 &&
1240 (*p_anim_stream)[i_word_index+20] == 0 &&
1241 (*p_anim_stream)[i_word_index+21] == 0 &&
1242 (*p_anim_stream)[i_word_index+22] == 0 &&
1243 (*p_anim_stream)[i_word_index+23] == 0 &&
1244 (*p_anim_stream)[i_word_index+24] == 0 &&
1246 (i_actual_column == 0) && (i_actual_wall == 0) &&
1247 (i_command_created == 0))
1250 i_word_index = i_word_index +24;
1255 i_command_created = 1;
1262 if( (*p_anim_stream)[i_word_index+ 0] == 0x7FFF &&
1263 (*p_anim_stream)[i_word_index+ 1] == 0x7FFF &&
1264 (*p_anim_stream)[i_word_index+ 2] == 0x7FFF &&
1265 (*p_anim_stream)[i_word_index+ 3] == 0x7FFF &&
1266 (*p_anim_stream)[i_word_index+ 4] == 0x7FFF &&
1267 (*p_anim_stream)[i_word_index+ 5] == 0x7FFF &&
1268 (*p_anim_stream)[i_word_index+ 6] == 0x7FFF &&
1269 (*p_anim_stream)[i_word_index+ 7] == 0x7FFF &&
1270 (*p_anim_stream)[i_word_index+ 8] == 0x7FFF &&
1271 (*p_anim_stream)[i_word_index+ 9] == 0x7FFF &&
1272 (*p_anim_stream)[i_word_index+10] == 0x7FFF &&
1273 (*p_anim_stream)[i_word_index+11] == 0x7FFF &&
1274 (*p_anim_stream)[i_word_index+12] == 0x7FFF &&
1275 (*p_anim_stream)[i_word_index+13] == 0x7FFF &&
1276 (*p_anim_stream)[i_word_index+14] == 0x7FFF &&
1277 (*p_anim_stream)[i_word_index+15] == 0x7FFF &&
1278 (*p_anim_stream)[i_word_index+16] == 0x7FFF &&
1279 (*p_anim_stream)[i_word_index+17] == 0x7FFF &&
1280 (*p_anim_stream)[i_word_index+18] == 0x7FFF &&
1281 (*p_anim_stream)[i_word_index+19] == 0x7FFF &&
1282 (*p_anim_stream)[i_word_index+20] == 0x7FFF &&
1283 (*p_anim_stream)[i_word_index+21] == 0x7FFF &&
1284 (*p_anim_stream)[i_word_index+22] == 0x7FFF &&
1285 (*p_anim_stream)[i_word_index+23] == 0x7FFF &&
1286 (*p_anim_stream)[i_word_index+24] == 0x7FFF &&
1288 (i_actual_column == 0) && (i_actual_wall == 0) &&
1289 (i_command_created == 0))
1292 i_word_index = i_word_index +24;
1296 i_command_created = 1;
1304 (*p_anim_stream)[i_word_index+ 0] == (*p_anim_stream)[i_word_index-25] &&
1305 (*p_anim_stream)[i_word_index+ 1] == (*p_anim_stream)[i_word_index-24] &&
1306 (*p_anim_stream)[i_word_index+ 2] == (*p_anim_stream)[i_word_index-23] &&
1307 (*p_anim_stream)[i_word_index+ 3] == (*p_anim_stream)[i_word_index-22] &&
1308 (*p_anim_stream)[i_word_index+ 4] == (*p_anim_stream)[i_word_index-21] &&
1309 (*p_anim_stream)[i_word_index+ 5] == (*p_anim_stream)[i_word_index-20] &&
1310 (*p_anim_stream)[i_word_index+ 6] == (*p_anim_stream)[i_word_index-19] &&
1311 (*p_anim_stream)[i_word_index+ 7] == (*p_anim_stream)[i_word_index-18] &&
1312 (*p_anim_stream)[i_word_index+ 8] == (*p_anim_stream)[i_word_index-17] &&
1313 (*p_anim_stream)[i_word_index+ 9] == (*p_anim_stream)[i_word_index-16] &&
1314 (*p_anim_stream)[i_word_index+10] == (*p_anim_stream)[i_word_index-15] &&
1315 (*p_anim_stream)[i_word_index+11] == (*p_anim_stream)[i_word_index-14] &&
1316 (*p_anim_stream)[i_word_index+12] == (*p_anim_stream)[i_word_index-13] &&
1317 (*p_anim_stream)[i_word_index+13] == (*p_anim_stream)[i_word_index-12] &&
1318 (*p_anim_stream)[i_word_index+14] == (*p_anim_stream)[i_word_index-11] &&
1319 (*p_anim_stream)[i_word_index+15] == (*p_anim_stream)[i_word_index-10] &&
1320 (*p_anim_stream)[i_word_index+16] == (*p_anim_stream)[i_word_index- 9] &&
1321 (*p_anim_stream)[i_word_index+17] == (*p_anim_stream)[i_word_index- 8] &&
1322 (*p_anim_stream)[i_word_index+18] == (*p_anim_stream)[i_word_index- 7] &&
1323 (*p_anim_stream)[i_word_index+19] == (*p_anim_stream)[i_word_index- 6] &&
1324 (*p_anim_stream)[i_word_index+20] == (*p_anim_stream)[i_word_index- 5] &&
1325 (*p_anim_stream)[i_word_index+21] == (*p_anim_stream)[i_word_index- 4] &&
1326 (*p_anim_stream)[i_word_index+22] == (*p_anim_stream)[i_word_index- 3] &&
1327 (*p_anim_stream)[i_word_index+23] == (*p_anim_stream)[i_word_index- 2] &&
1328 (*p_anim_stream)[i_word_index+24] == (*p_anim_stream)[i_word_index- 1] &&
1330 (i_actual_column == 0) && (i_actual_wall == 0) && (i_actual_frame > 0))
1333 i_word_index = i_word_index +24;
1337 i_command_created = 1;
1352 if( (*p_anim_stream)[i_word_index+0] == 0x0000 &&
1353 (*p_anim_stream)[i_word_index+1] == 0x0000 &&
1354 (*p_anim_stream)[i_word_index+2] == 0x0000 &&
1355 (*p_anim_stream)[i_word_index+3] == 0x0000 &&
1356 (*p_anim_stream)[i_word_index+4] == 0x0000 &&
1357 (i_actual_column == 0) &&
1358 (i_command_created == 0))
1361 i_word_index = i_word_index +4;
1366 i_command_created = 1;
1373 if( (*p_anim_stream)[i_word_index+0] == 0x7FFF &&
1374 (*p_anim_stream)[i_word_index+1] == 0x7FFF &&
1375 (*p_anim_stream)[i_word_index+2] == 0x7FFF &&
1376 (*p_anim_stream)[i_word_index+3] == 0x7FFF &&
1377 (*p_anim_stream)[i_word_index+4] == 0x7FFF &&
1378 (i_actual_column == 0) &&
1379 (i_command_created == 0))
1382 i_word_index = i_word_index +4;
1387 i_command_created = 1;
1395 if( (*p_anim_stream)[i_word_index-5] == (*p_anim_stream)[i_word_index+0] &&
1396 (*p_anim_stream)[i_word_index-4] == (*p_anim_stream)[i_word_index+1] &&
1397 (*p_anim_stream)[i_word_index-3] == (*p_anim_stream)[i_word_index+2] &&
1398 (*p_anim_stream)[i_word_index-2] == (*p_anim_stream)[i_word_index+3] &&
1399 (*p_anim_stream)[i_word_index-1] == (*p_anim_stream)[i_word_index+4] &&
1401 (i_actual_column == 0) && (i_actual_wall > 0) &&
1402 (i_command_created == 0))
1405 i_word_index = i_word_index +4;
1410 i_command_created = 1;
1416 if( ( i_anime_word & (0x8000) ) == 0 )
1419 sprintf( c_tmp_num,
"0x%04X,", i_anime_word);
1422 fprintf(file,
"%s", c_tmp_num);
1427 if(i_actual_column > 4)
1429 fprintf(file,
"\n ");
1431 i_actual_column = 0;
1436 if(i_actual_wall > 4)
1442 fprintf(file,
"\n\n // Frame %d\n ", i_actual_frame);
1449 switch( ((i_anime_word) & 0xFF00) )
1451 case cmd_set_pwm_r: strcpy( c_tmp_txt,
"cmd_set_pwm_r");
break;
1452 case cmd_set_pwm_g: strcpy( c_tmp_txt,
"cmd_set_pwm_g");
break;
1453 case cmd_set_pwm_b: strcpy( c_tmp_txt,
"cmd_set_pwm_b");
break;
1460 default: strcpy( c_tmp_txt,
"0x8000");
1468 fprintf(file,
"%s + %d,\n ", c_tmp_txt, (i_anime_word)&(0xFF) );
1473 if(i_actual_wall > 4)
1479 fprintf(file,
"\n\n // Frame %d\n ", i_actual_frame);
1513 if( (i_options > 255) || (i_options < 0))
1517 "| ! Warning: End of animation option out of range. Set to 0 (default) |"
1530 strcpy(c_file_and_path, generated_anime_folder);
1532 strcat(c_file_and_path,
"/anim_");
1534 strcat(c_file_and_path, p_animation_name);
1536 strcat(c_file_and_path,
".c");
1539 file = fopen( c_file_and_path,
"a+");
1541 char c_file_content[128];
1543 strcpy(c_file_content,
""
1544 " // End of animation + option\n"
1548 char c_number_as_text[4];
1549 sprintf( c_number_as_text,
"%d", i_options);
1552 strcat(c_file_content, c_number_as_text);
1553 strcat(c_file_content,
"\n };");
1556 fprintf(file,
"%s", c_file_content);
1574 printf(
"\n\n\n\n\n\n\n\n\n\n");
1585 for(
int i=0 ; i<5 ; i++)
1587 for(
int j=0 ; j<5 ; j++)
1589 for(
int k=0 ; k<5 ; k++)
1591 (*p_fb_data_vitual)[i][j][k] = 0;
1603 for(
int i=0 ; i<5 ; i++)
1605 for(
int j=0 ; j<5 ; j++)
1607 for(
int k=0 ; k<5 ; k++)
1609 (*p_fb_data_virtual)[i][j][k] = (1<<
red_shift)|
1622 void clear_real_framebuffer(uint16_t (*p_anim_stream)[max_size_anim_stream])
1626 (*p_anim_stream)[i] = 0;
1633 void show_preview(uint8_t (*p_fb_data_virtual)[5][5][5],
1634 uint32_t i_frame_counter,
1637 uint8_t i_led_level,
1641 float f_virtual_time)
1645 "+---------------------------------------------------------------------------+"
1647 "| Frame: %9d | Wall: %d/4 | Column: %d/4 | Time: %7.2f s |\n"
1648 "+--------------+---+-----------++------------+--+---------------------------+"
1650 "| PWM red: %3d | PWM green: %3d | PWM blue: %3d | |"
1652 "+--------------+----------------+---------------+---------------------------+"
1654 "| | C0 | | C1 | | C2 | | C3 | | C4 | |"
1658 , i_frame_counter, i_wall, i_column, f_virtual_time,
1659 i_pwm_r, i_pwm_g, i_pwm_b
1662 for(
int i=4 ; i>=0 ; i--)
1664 printf(
"| LED %d > ", i);
1666 for(
int j=0 ; j<5 ; j++)
1669 if( (i==i_led_level) && (j==i_column))
1679 if( (*p_fb_data_virtual)[i_wall][i][j] & (1<<
red_shift) )
1688 if( (*p_fb_data_virtual)[i_wall][i][j] & (1<<green_shift) )
1697 if( (*p_fb_data_virtual)[i_wall][i][j] & (1<<blue_shift) )
1707 if( (i==i_led_level) && (j==i_column))
1724 "+---------------------------------------------------------------------------+"
1726 "| Type command or data. Aviable commands: |"
1728 "| exit - save data (to actual frame) and exit from application |"
1730 "| zeros - clear actual frame - turn off all LEDs on actual frame |"
1732 "| ones - set actual frame - turn on all LEDs on acutal frame |"
1734 "| next - move to next wall. Actual 2D frame will be saved |"
1736 "| back - move to previous wall. Actual 2D frame will be saved |"
1738 "| pwmr - set PWM on channel with RED LEDs. pwmg is for green and pwmb for |"
1740 "| blue channel. Value of PWM is same for whole frame. |"
1742 "| line - copy actual segment thru line |"
1744 "| column - copy actual segment thru column |"
1753 "+---------------------------------------------------------------------------+"
1755 "| Howto type data (examples): |"
1757 "| rgb -> turn on all LEDs in segment |"
1759 "| r-- -> just turn on red LED |"
1761 "| 011 -> turn green and blue LED |"
1763 "| A -> turn on all LEDs in segment |"
1765 "| g -> turn on green LED |"
1771 "+---------------------------------------------------------------------------+"