WIP: Animations now use only three bytes per color instead of four.

This commit is contained in:
Fabian Schlenz 2019-05-24 23:51:50 +02:00
parent 959024ede8
commit d39e4975a1
2 changed files with 158 additions and 151 deletions

View File

@ -1,37 +1,38 @@
/**
* Animations are structured in AnimationData as follows:
*
* .colors contains .color_count 3-byte-color values. Color #0 is transparent - keep the
* color from the previous frame. Color #1 is the background color of "behind the gif".
*
*
* .offsets contains the frame start offsets within .data + the length of the data. (So
* you can always do something like `for (int i=anim.offsets[i]; i<anim.offsets[i+1]; i++)`.
* Accordingly it has a length of .frame_count+1.
*
* .data contains all frames data with a run-length compression with escape char 255.
* This data references the index of one or multiple pixels in .colors. It starts at the
* top left pixel and walks each row to the right before starting the next row.
* To decode it: Start at a frame (indicated by .offsets). Get one byte as x.
* If x is 0: This is a transparent pixel. On frame 0 this means "show the background
* color", on every other frame "keep the pixel from the previous frame".
* If x is >0 and <255: This pixel has the color indicated by .colors[x].
* if x is 255: Run-length-encoding. The next byte indicates of often the byte after that
* will be repeated. So, {255, 4, 10} is equal to {10, 10, 10, 10}.
* A special case that may happen in larger GIFs is that there are more than 255 repetitions
* of a color. Those will be split, so 355*color #10 will be: {255, 255, 10, 255, 100, 10},
* e.g. 255*10 + 100*10. Usually this shouldn't need special handling within a decoder.
*
* .individual_delays contains either 1 or .frame_count delays. They are given in ms and
* indicate how long the matching frame should be displayed. If all times are equal, then
* it contains only one entry and .individual_delays will be false.
*
* .w and .h contain the dimensions of the image.
Animations are structured in AnimationData as follows:
.colors contains .color_count*3 uint8_t values for R, G and B.
.offsets contains the frame start offsets within .data + the length of the data. (So
you can always do something like `for (int i=anim.offsets[i]; i<anim.offsets[i+1]; i++)`.
Accordingly it has a length of .frame_count+1.
.data contains all frames data with a run-length compression with escape char 255.
This data references the index of one or multiple pixels in .colors. It starts at the
top left pixel and walks each row to the right before starting the next row.
To decode it: Start at a frame (indicated by .offsets). Get one byte as x.
If x is <255: This is a single pixel of color x.
if x is 255: Run-length-encoding. The next byte indicates of often the byte after that
will be repeated. So, {255, 4, 10} is equal to {10, 10, 10, 10}.
A special case that may happen in larger GIFs is that there are more than 255 repetitions
of a color. Those will be split, so 355*color #10 will be: {255, 255, 10, 255, 100, 10},
e.g. 255*10 + 100*10. Usually this shouldn't need special handling within a decoder.
Regarding colors in .data:
Color 0 means "keep the color from the previous frame". This color should never appear on frame #0.
Color 1 means "show the background color".
All other color values point to a color in .colors - with an offset of 2.
So if in .data there's a color 3, paint this pixel in .colors[1].
.individual_delays contains either 1 or .frame_count delays. They are given in ms and
indicate how long the matching frame should be displayed. If all times are equal, then
it contains only one entry and .individual_delays will be false.
.w and .h contain the dimensions of the image.
**/
typedef struct {
uint32_t *colors;
uint8_t *colors;
uint8_t *data;
uint16_t *offsets;
uint16_t *delays;
@ -43,8 +44,8 @@ typedef struct {
} AnimationData;
uint32_t koopa_colors[] = {0x000000, 0x000000, 0xB69A11, 0x000000, 0x303030, 0x8E0406, 0xFEFCFF, 0x03018A, 0x11EF12};
uint8_t koopa_data[] PROGMEM = {
uint8_t animation_koopa_colors[] PROGMEM = {182, 154, 17, 0, 0, 0, 48, 48, 48, 142, 4, 6, 254, 252, 255, 3, 1, 138, 17, 239, 18};
uint8_t animation_koopa_data[] PROGMEM = {
255, 4, 1, 6, 255, 14, 1, 6, 6, 6, 255, 12, 1, 2, 6, 6, 6, 255, 11, 1, 2, 2, 3, 6, 6, 2, 255, 10, 1, 2, 2, 3, 6, 6, 2, 1, 1, 8, 8, 8, 6, 1, 1, 1, 2, 3, 2, 6, 6, 2, 2, 1, 8, 3, 8, 8, 3, 6, 1, 1, 255, 7, 2, 1, 8, 8, 3, 3, 8, 8, 6, 1, 2, 2, 2, 4, 2, 2, 4, 8, 8, 3, 8, 8, 3, 8, 6, 1, 2, 2, 4, 2, 2, 2, 7, 8, 3, 255, 4, 8, 3, 8, 1, 1, 1, 255, 4, 2, 7, 3, 8, 3, 8, 8, 3, 8, 3, 2, 1, 1, 1, 2, 2, 2, 7, 8, 8, 8, 3, 3, 8, 8, 8, 255, 5, 1, 2, 2, 7, 7, 8, 3, 8, 8, 3, 8, 7, 7, 1, 1, 1, 255, 4, 5, 7, 7, 255, 4, 8, 7, 7, 1, 1, 1, 5, 5, 5, 4, 2, 2, 255, 6, 7, 2, 255, 6, 1, 255, 4, 2, 1, 5, 5, 5, 2, 2, 255, 6, 1, 2, 2, 2, 255, 4, 1, 2, 2, 2, 1,
255, 4, 0, 1, 255, 14, 0, 1, 0, 1, 255, 12, 0, 1, 255, 14, 0, 1, 0, 6, 0, 0, 1, 255, 18, 0, 255, 4, 1, 0, 0, 0, 1, 2, 0, 3, 0, 6, 0, 0, 1, 8, 0, 0, 6, 1, 0, 0, 0, 3, 0, 6, 6, 255, 4, 0, 3, 8, 8, 3, 6, 1, 255, 4, 0, 2, 0, 0, 2, 1, 0, 8, 3, 3, 8, 255, 5, 0, 2, 4, 0, 0, 4, 0, 8, 3, 0, 0, 3, 8, 6, 0, 2, 2, 4, 255, 4, 0, 8, 3, 8, 0, 0, 8, 3, 8, 1, 0, 0, 2, 255, 4, 0, 3, 0, 3, 8, 8, 3, 0, 3, 2, 0, 0, 0, 2, 0, 0, 0, 8, 0, 8, 3, 3, 8, 0, 8, 1, 0, 0, 0, 1, 2, 2, 7, 0, 8, 3, 0, 0, 3, 8, 0, 7, 0, 0, 255, 4, 1, 5, 7, 0, 255, 4, 8, 0, 7, 255, 6, 0, 5, 0, 0, 255, 6, 7, 255, 6, 0, 5, 5, 0, 0, 2, 2, 0, 5, 5, 0, 0, 2,
255, 4, 0, 6, 255, 14, 0, 6, 0, 6, 255, 12, 0, 2, 255, 14, 0, 2, 0, 3, 0, 0, 2, 255, 25, 0, 2, 3, 0, 6, 0, 2, 255, 11, 0, 2, 0, 2, 2, 255, 17, 0, 1, 255, 11, 0, 1, 1, 0, 0, 1, 255, 9, 0, 255, 4, 1, 255, 14, 0, 1, 1, 255, 14, 0, 2, 255, 35, 0, 2, 255, 14, 0, 2, 255, 14, 0, 2, 2, 0, 0, 1, 1, 0, 1, 1, 255, 3, 0,
@ -52,13 +53,13 @@ uint8_t koopa_data[] PROGMEM = {
255, 4, 0, 1, 255, 14, 0, 1, 0, 1, 255, 12, 0, 1, 255, 14, 0, 1, 0, 6, 0, 0, 1, 255, 18, 0, 255, 4, 1, 0, 0, 0, 1, 2, 0, 3, 0, 6, 0, 0, 1, 8, 0, 0, 6, 1, 0, 0, 0, 3, 0, 6, 6, 255, 4, 0, 3, 8, 8, 3, 6, 1, 255, 4, 0, 2, 0, 0, 2, 1, 0, 8, 3, 3, 8, 255, 5, 0, 2, 4, 0, 0, 4, 0, 8, 3, 0, 0, 3, 8, 6, 0, 2, 2, 4, 255, 4, 0, 8, 3, 8, 0, 0, 8, 3, 8, 1, 0, 0, 2, 255, 4, 0, 3, 0, 3, 8, 8, 3, 0, 3, 2, 0, 0, 0, 2, 0, 0, 0, 8, 0, 8, 3, 3, 8, 0, 8, 8, 255, 4, 0, 2, 2, 7, 0, 8, 3, 0, 0, 3, 8, 0, 7, 255, 4, 0, 1, 1, 0, 7, 0, 255, 4, 8, 0, 7, 255, 4, 0, 1, 0, 0, 0, 2, 255, 6, 7, 2, 255, 4, 0, 255, 4, 2, 255, 4, 0, 2, 2, 2, 0, 0,
255, 4, 0, 6, 255, 14, 0, 6, 0, 6, 255, 12, 0, 2, 255, 14, 0, 2, 0, 3, 0, 0, 2, 255, 25, 0, 2, 3, 0, 6, 0, 2, 255, 11, 0, 2, 0, 2, 2, 255, 17, 0, 1, 255, 11, 0, 1, 1, 0, 0, 1, 255, 9, 0, 255, 4, 1, 255, 14, 0, 1, 1, 255, 14, 0, 2, 255, 12, 0, 1, 255, 36, 0, 1, 255, 10, 0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 1, 0, 0, 1, 1, 0, 2, 2
};
uint16_t koopa_delays[] = {100,100,100,100,100,100};
uint16_t koopa_offsets[] = {0,199,390,479,640,832,926};
AnimationData koopa = {&koopa_colors[0], &koopa_data[0], &koopa_offsets[0], &koopa_delays[0], false, 9, 6, 16, 16};
uint16_t animation_koopa_delays[] = {100, 100, 100, 100, 100, 100};
uint16_t animation_koopa_offsets[] = {0, 199, 390, 479, 640, 832, 926};
AnimationData animation_koopa = {&animation_koopa_colors[0], &animation_koopa_data[0], &animation_koopa_offsets[0], &animation_koopa_delays[0], false, 7, 6, 16, 16};
uint32_t couple_rain_colors[] = {0x000000, 0x000000, 0x000000, 0x028BDA, 0xB5ABFF, 0xFFFFFF, 0xFF4C0B, 0xDCCEB4, 0x313131, 0x1501AF, 0x641B00, 0x514225, 0x3319FD, 0x2E0C00, 0xDA0256, 0x25AFFD, 0x80683C};
uint8_t couple_rain_data[] PROGMEM = {
uint8_t animation_couple_rain_colors[] PROGMEM = {0, 0, 0, 2, 139, 218, 181, 171, 255, 255, 255, 255, 255, 76, 11, 220, 206, 180, 49, 49, 49, 21, 1, 175, 100, 27, 0, 81, 66, 37, 51, 25, 253, 46, 12, 0, 218, 2, 86, 37, 175, 253, 128, 104, 60};
uint8_t animation_couple_rain_data[] PROGMEM = {
255, 6, 2, 3, 255, 7, 2, 3, 255, 14, 2, 3, 255, 8, 2, 3, 255, 7, 2, 3, 255, 14, 2, 3, 255, 25, 2, 3, 255, 5, 2, 3, 255, 12, 2, 3, 255, 12, 2, 3, 255, 18, 2, 3, 255, 12, 2, 3, 255, 18, 2, 3, 255, 12, 2, 3, 255, 18, 2, 3, 255, 12, 2, 3, 255, 10, 2, 3, 255, 7, 2, 3, 255, 23, 2, 3, 255, 11, 2, 3, 255, 19, 2, 3, 255, 11, 2, 3, 255, 15, 2, 3, 2, 2, 2, 3, 255, 11, 2, 3, 255, 5, 2, 15, 255, 9, 2, 3, 2, 2, 2, 3, 255, 11, 2, 3, 2, 2, 2, 3, 255, 11, 2, 3, 255, 15, 2, 3, 5, 2, 15, 3, 255, 7, 2, 3, 2, 2, 2, 3, 255, 8, 2, 3, 255, 4, 2, 255, 7, 5, 255, 7, 2, 3, 2, 2, 2, 3, 255, 8, 2, 3, 2, 2, 2, 5, 5, 12, 12, 5, 12, 12, 5, 5, 255, 6, 2, 3, 255, 12, 2, 3, 2, 2, 5, 5, 12, 12, 5, 5, 5, 12, 12, 5, 5, 255, 5, 2, 3, 255, 12, 2, 3, 2, 4, 4, 9, 9, 12, 5, 5, 5, 12, 9, 9, 4, 4, 255, 4, 2, 3, 255, 8, 2, 3, 2, 2, 2, 3, 2, 4, 4, 9, 9, 9, 4, 4, 4, 9, 9, 9, 4, 4, 255, 13, 2, 3, 255, 11, 2, 9, 255, 6, 2, 3, 255, 12, 2, 3, 255, 7, 2, 6, 6, 6, 2, 9, 255, 6, 2, 3, 255, 12, 2, 3, 255, 7, 2, 6, 6, 6, 2, 9, 2, 10, 10, 10, 2, 2, 3, 255, 12, 2, 3, 255, 7, 2, 10, 10, 10, 2, 9, 255, 5, 10, 2, 3, 255, 19, 2, 255, 5, 6, 12, 10, 7, 7, 7, 10, 2, 3, 255, 6, 2, 3, 255, 13, 2, 11, 7, 11, 2, 12, 10, 11, 7, 11, 10, 255, 8, 2, 3, 255, 13, 2, 7, 7, 7, 2, 7, 10, 7, 7, 7, 10, 255, 8, 2, 3, 255, 6, 2, 3, 255, 6, 2, 255, 5, 6, 13, 13, 16, 13, 13, 255, 8, 2, 3, 255, 6, 2, 3, 255, 5, 2, 255, 4, 6, 2, 2, 2, 14, 14, 14, 255, 9, 2, 3, 255, 6, 2, 3, 255, 5, 2, 7, 10, 10, 10, 2, 2, 7, 14, 14, 14, 7, 255, 15, 2, 3, 255, 6, 2, 6, 6, 6, 2, 2, 255, 5, 14, 2, 2, 2, 15, 255, 11, 2, 3, 255, 6, 2, 6, 2, 6, 2, 2, 2, 7, 2, 7, 255, 6, 2, 15, 255, 15, 2, 8, 8, 2, 8, 8, 2, 2, 8, 2, 8, 255, 6, 2, 3, 255, 37, 2,
255, 19, 0, 3, 255, 31, 0, 3, 255, 18, 0, 3, 255, 7, 0, 3, 255, 8, 0, 2, 255, 14, 0, 3, 0, 0, 0, 2, 0, 0, 0, 3, 255, 8, 0, 2, 255, 5, 0, 3, 255, 12, 0, 2, 255, 18, 0, 3, 255, 68, 0, 2, 255, 20, 0, 3, 255, 10, 0, 2, 255, 7, 0, 3, 0, 0, 0, 2, 255, 8, 0, 3, 255, 18, 0, 3, 0, 0, 0, 2, 255, 15, 0, 2, 255, 21, 0, 2, 15, 255, 8, 0, 2, 255, 14, 0, 15, 0, 0, 0, 15, 2, 255, 15, 0, 3, 255, 14, 0, 2, 2, 255, 7, 0, 2, 255, 7, 0, 3, 255, 4, 0, 2, 255, 18, 0, 2, 255, 12, 0, 2, 255, 22, 0, 3, 255, 31, 0, 3, 255, 36, 0, 2, 255, 22, 0, 3, 255, 8, 0, 2, 0, 0, 0, 3, 255, 14, 0, 2, 0, 0, 0, 3, 255, 12, 0, 3, 255, 14, 0, 2, 255, 76, 0, 3, 255, 25, 0, 2, 255, 5, 0, 3, 255, 18, 0, 3, 255, 6, 0, 2, 255, 24, 0, 3, 255, 13, 0, 2, 255, 31, 0, 2, 255, 50, 0, 15, 255, 5, 0, 3, 255, 5, 0, 15, 255, 20, 0, 2, 0, 15, 0, 0, 3, 255, 7, 0, 15, 255, 20, 0, 2, 255, 9, 0, 3, 255, 21, 0, 2, 255, 37, 0,
255, 6, 0, 2, 255, 7, 0, 2, 255, 14, 0, 2, 255, 31, 0, 2, 255, 21, 0, 3, 255, 31, 0, 3, 255, 18, 0, 3, 255, 7, 0, 3, 255, 8, 0, 2, 255, 14, 0, 3, 0, 0, 0, 2, 0, 0, 0, 3, 255, 8, 0, 2, 255, 5, 0, 3, 255, 12, 0, 2, 255, 18, 0, 3, 255, 68, 0, 2, 255, 20, 0, 3, 255, 10, 0, 2, 255, 7, 0, 3, 0, 15, 0, 2, 15, 0, 15, 0, 0, 0, 2, 0, 3, 255, 18, 0, 3, 0, 0, 2, 2, 0, 0, 2, 255, 4, 0, 15, 255, 7, 0, 2, 255, 31, 0, 2, 255, 35, 0, 3, 255, 23, 0, 2, 255, 7, 0, 3, 255, 4, 0, 2, 255, 18, 0, 2, 255, 12, 0, 2, 255, 22, 0, 3, 255, 31, 0, 3, 255, 36, 0, 2, 255, 22, 0, 3, 255, 8, 0, 2, 0, 0, 0, 3, 255, 14, 0, 2, 0, 0, 0, 3, 255, 12, 0, 3, 255, 14, 0, 2, 255, 76, 0, 3, 255, 25, 0, 2, 255, 5, 0, 3, 255, 18, 0, 3, 255, 6, 0, 2, 255, 24, 0, 3, 255, 11, 0, 15, 0, 2, 255, 18, 0, 2, 0, 0, 15, 255, 8, 0, 2, 2, 0, 15, 255, 19, 0, 2, 255, 10, 0, 2, 255, 23, 0, 3, 255, 31, 0, 3, 255, 34, 0,
@ -92,13 +93,13 @@ uint8_t couple_rain_data[] PROGMEM = {
255, 34, 0, 2, 255, 20, 0, 3, 255, 10, 0, 2, 255, 7, 0, 3, 0, 0, 0, 2, 255, 8, 0, 3, 255, 18, 0, 3, 0, 0, 0, 2, 255, 15, 0, 2, 255, 31, 0, 2, 255, 19, 0, 2, 255, 15, 0, 3, 255, 15, 0, 2, 255, 7, 0, 2, 255, 7, 0, 3, 255, 4, 0, 2, 255, 6, 0, 3, 255, 11, 0, 2, 255, 12, 0, 2, 255, 6, 0, 3, 255, 15, 0, 3, 255, 13, 0, 15, 255, 17, 0, 3, 255, 10, 0, 15, 2, 0, 2, 255, 5, 0, 3, 255, 16, 0, 2, 255, 8, 0, 2, 15, 255, 4, 0, 3, 255, 7, 0, 3, 255, 8, 0, 2, 0, 0, 0, 3, 255, 4, 0, 2, 255, 9, 0, 2, 0, 0, 0, 3, 255, 12, 0, 3, 255, 14, 0, 2, 255, 76, 0, 3, 255, 25, 0, 2, 255, 5, 0, 3, 255, 18, 0, 3, 255, 6, 0, 2, 255, 24, 0, 3, 255, 13, 0, 2, 255, 31, 0, 2, 255, 56, 0, 3, 255, 31, 0, 3, 255, 38, 0, 3, 255, 21, 0, 2, 255, 9, 0, 3, 255, 21, 0, 2, 255, 44, 0, 15, 255, 25, 0, 2, 0, 0, 15, 2, 0, 2, 255, 21, 0, 15, 0, 2, 0, 2, 255, 5, 0, 2, 255, 18, 0, 3, 0, 0, 0, 2, 255, 8, 0, 2, 255, 18, 0, 3, 0, 0, 0, 2, 255, 33, 0,
255, 10, 0, 2, 255, 18, 0, 3, 255, 68, 0, 2, 255, 20, 0, 3, 255, 10, 0, 2, 255, 7, 0, 3, 0, 0, 0, 2, 255, 8, 0, 3, 255, 18, 0, 3, 0, 0, 0, 2, 255, 15, 0, 2, 255, 31, 0, 2, 255, 19, 0, 2, 255, 15, 0, 3, 255, 8, 0, 15, 255, 6, 0, 2, 255, 7, 0, 2, 255, 7, 0, 3, 255, 4, 0, 2, 255, 4, 0, 2, 0, 3, 255, 11, 0, 2, 255, 12, 0, 2, 0, 2, 255, 4, 0, 15, 255, 15, 0, 3, 255, 14, 0, 2, 255, 5, 0, 15, 255, 10, 0, 3, 255, 19, 0, 3, 255, 16, 0, 2, 255, 22, 0, 3, 255, 8, 0, 2, 0, 0, 0, 3, 255, 14, 0, 2, 0, 0, 0, 3, 255, 12, 0, 3, 255, 14, 0, 2, 255, 76, 0, 3, 255, 25, 0, 2, 255, 5, 0, 3, 255, 18, 0, 3, 255, 6, 0, 2, 255, 24, 0, 3, 255, 13, 0, 2, 255, 31, 0, 2, 255, 56, 0, 3, 255, 31, 0, 3, 255, 38, 0, 3, 0, 0, 15, 255, 18, 0, 2, 255, 9, 0, 3, 0, 0, 2, 255, 18, 0, 2, 255, 9, 0, 2, 255, 23, 0, 15, 2, 255, 5, 0, 15, 255, 21, 0, 15, 255, 7, 0, 2, 255, 62, 0
};
uint16_t couple_rain_delays[] = {60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60};
uint16_t couple_rain_offsets[] = {0,475,718,961,1222,1476,1734,2002,2276,2528,2787,3050,3304,3567,3824,4106,4382,4650,4916,5208,5459,5731,5988,6243,6497,6769,7004,7263,7543,7790,8035,8288,8522};
AnimationData couple_rain = {&couple_rain_colors[0], &couple_rain_data[0], &couple_rain_offsets[0], &couple_rain_delays[0], false, 17, 32, 32, 32};
uint16_t animation_couple_rain_delays[] = {60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60};
uint16_t animation_couple_rain_offsets[] = {0, 475, 718, 961, 1222, 1476, 1734, 2002, 2276, 2528, 2787, 3050, 3304, 3567, 3824, 4106, 4382, 4650, 4916, 5208, 5459, 5731, 5988, 6243, 6497, 6769, 7004, 7263, 7543, 7790, 8035, 8288, 8522};
AnimationData animation_couple_rain = {&animation_couple_rain_colors[0], &animation_couple_rain_data[0], &animation_couple_rain_offsets[0], &animation_couple_rain_delays[0], false, 15, 32, 32, 32};
uint32_t couple_snow_colors[] = {0x000000, 0x000000, 0x000000, 0xFFFFFF, 0xFF3C00, 0xF8E6C4, 0x432F09, 0x22B20A, 0x008EF6, 0xF60049, 0x5C0000, 0x1B00FF};
uint8_t couple_snow_data[] PROGMEM = {
uint8_t animation_couple_snow_colors[] PROGMEM = {0, 0, 0, 255, 255, 255, 255, 60, 0, 248, 230, 196, 67, 47, 9, 34, 178, 10, 0, 142, 246, 246, 0, 73, 92, 0, 0, 27, 0, 255};
uint8_t animation_couple_snow_data[] PROGMEM = {
2, 3, 255, 39, 2, 3, 255, 14, 2, 3, 255, 11, 2, 3, 255, 10, 2, 3, 255, 45, 2, 3, 255, 24, 2, 3, 255, 47, 2, 3, 255, 6, 2, 3, 255, 36, 2, 3, 255, 10, 2, 3, 255, 4, 2, 3, 255, 21, 2, 3, 255, 16, 2, 3, 255, 84, 2, 3, 255, 20, 2, 3, 255, 18, 2, 3, 255, 7, 2, 3, 255, 40, 2, 3, 255, 42, 2, 3, 255, 25, 2, 3, 255, 12, 2, 3, 255, 9, 2, 3, 255, 27, 2, 3, 255, 8, 2, 3, 255, 6, 2, 3, 2, 2, 2, 3, 255, 9, 2, 5, 2, 2, 2, 5, 255, 25, 2, 4, 4, 4, 2, 2, 2, 9, 9, 9, 255, 22, 2, 255, 5, 4, 2, 255, 5, 9, 255, 4, 2, 3, 255, 16, 2, 255, 5, 4, 2, 9, 10, 10, 5, 9, 255, 16, 2, 3, 255, 4, 2, 4, 6, 5, 6, 4, 2, 9, 6, 5, 6, 9, 255, 12, 2, 3, 255, 9, 2, 5, 5, 5, 2, 2, 10, 5, 5, 5, 10, 255, 7, 2, 3, 255, 14, 2, 7, 7, 7, 2, 2, 2, 11, 11, 11, 255, 22, 2, 4, 4, 7, 4, 4, 2, 9, 9, 11, 9, 255, 4, 2, 3, 255, 17, 2, 4, 4, 7, 4, 4, 9, 9, 9, 11, 9, 9, 255, 8, 2, 3, 2, 2, 2, 3, 255, 8, 2, 5, 8, 8, 8, 2, 5, 2, 9, 9, 9, 5, 255, 18, 2, 3, 2, 2, 2, 8, 2, 8, 2, 2, 2, 8, 2, 8, 255, 22, 2, 6, 6, 2, 6, 6, 2, 2, 6, 2, 6, 255, 12, 2, 255, 32, 3,
0, 2, 255, 13, 0, 3, 255, 10, 0, 3, 255, 6, 0, 3, 255, 7, 0, 2, 255, 14, 0, 2, 255, 11, 0, 2, 255, 4, 0, 3, 255, 5, 0, 2, 255, 8, 0, 3, 255, 11, 0, 3, 255, 10, 0, 3, 255, 13, 0, 2, 255, 24, 0, 2, 255, 6, 0, 3, 255, 24, 0, 3, 255, 15, 0, 2, 255, 6, 0, 2, 255, 24, 0, 3, 255, 6, 0, 3, 255, 4, 0, 2, 255, 10, 0, 2, 255, 4, 0, 2, 255, 15, 0, 3, 255, 5, 0, 2, 255, 4, 0, 3, 255, 4, 0, 3, 255, 6, 0, 2, 255, 14, 0, 3, 255, 16, 0, 3, 255, 52, 0, 2, 255, 20, 0, 2, 255, 10, 0, 3, 255, 7, 0, 2, 255, 7, 0, 2, 255, 4, 0, 3, 255, 18, 0, 3, 255, 7, 0, 3, 255, 8, 0, 2, 255, 31, 0, 3, 255, 10, 0, 2, 255, 25, 0, 2, 255, 5, 0, 3, 255, 6, 0, 2, 255, 9, 0, 2, 255, 8, 0, 3, 255, 12, 0, 3, 255, 5, 0, 2, 0, 0, 0, 3, 255, 4, 0, 2, 255, 6, 0, 2, 0, 0, 0, 2, 255, 11, 0, 3, 255, 8, 0, 3, 255, 6, 0, 3, 0, 0, 0, 3, 255, 53, 0, 2, 255, 31, 0, 3, 255, 11, 0, 2, 255, 27, 0, 2, 0, 0, 0, 3, 255, 22, 0, 2, 255, 4, 0, 3, 255, 26, 0, 3, 255, 27, 0, 2, 255, 31, 0, 3, 255, 4, 0, 2, 0, 0, 0, 2, 255, 27, 0, 3, 0, 0, 0, 3, 255, 5, 0, 2, 255, 31, 0, 3, 255, 56, 0,
255, 15, 0, 2, 255, 4, 0, 3, 255, 5, 0, 2, 255, 6, 0, 2, 255, 13, 0, 3, 255, 10, 0, 3, 255, 6, 0, 3, 255, 7, 0, 2, 255, 14, 0, 2, 255, 11, 0, 2, 255, 4, 0, 3, 255, 5, 0, 2, 255, 8, 0, 3, 255, 11, 0, 3, 255, 10, 0, 3, 255, 13, 0, 2, 255, 24, 0, 2, 255, 6, 0, 3, 255, 24, 0, 3, 255, 15, 0, 2, 255, 6, 0, 2, 255, 24, 0, 3, 255, 6, 0, 3, 255, 4, 0, 2, 255, 10, 0, 2, 255, 4, 0, 2, 255, 15, 0, 3, 255, 5, 0, 2, 255, 4, 0, 3, 255, 4, 0, 3, 255, 6, 0, 2, 255, 14, 0, 3, 255, 16, 0, 3, 255, 52, 0, 2, 255, 20, 0, 2, 255, 10, 0, 3, 255, 7, 0, 2, 255, 7, 0, 2, 255, 4, 0, 3, 255, 18, 0, 3, 255, 7, 0, 3, 255, 8, 0, 2, 255, 31, 0, 3, 255, 10, 0, 2, 255, 25, 0, 2, 255, 5, 0, 3, 255, 6, 0, 2, 255, 9, 0, 2, 255, 8, 0, 3, 255, 12, 0, 3, 255, 5, 0, 2, 0, 0, 0, 3, 255, 4, 0, 2, 255, 6, 0, 2, 0, 0, 0, 2, 255, 20, 0, 3, 255, 6, 0, 3, 0, 0, 0, 3, 255, 53, 0, 2, 255, 31, 0, 3, 255, 11, 0, 2, 255, 27, 0, 2, 0, 0, 0, 3, 255, 22, 0, 2, 255, 4, 0, 3, 255, 26, 0, 3, 255, 27, 0, 2, 255, 31, 0, 3, 255, 4, 0, 2, 0, 0, 0, 2, 255, 27, 0, 3, 0, 0, 0, 3, 255, 5, 0, 2, 255, 56, 0,
@ -132,13 +133,13 @@ uint8_t couple_snow_data[] PROGMEM = {
255, 4, 0, 3, 255, 10, 0, 3, 255, 13, 0, 2, 255, 24, 0, 2, 255, 6, 0, 3, 255, 24, 0, 3, 255, 15, 0, 2, 255, 6, 0, 2, 255, 24, 0, 3, 255, 6, 0, 3, 255, 4, 0, 2, 255, 10, 0, 2, 255, 4, 0, 2, 255, 15, 0, 3, 255, 5, 0, 2, 255, 4, 0, 3, 255, 4, 0, 3, 255, 6, 0, 2, 255, 14, 0, 3, 255, 16, 0, 3, 255, 52, 0, 2, 255, 20, 0, 2, 255, 10, 0, 3, 255, 7, 0, 2, 255, 7, 0, 2, 255, 4, 0, 3, 255, 18, 0, 3, 255, 7, 0, 3, 255, 8, 0, 2, 255, 31, 0, 3, 255, 10, 0, 2, 255, 25, 0, 2, 255, 5, 0, 3, 255, 6, 0, 2, 255, 9, 0, 2, 255, 8, 0, 3, 255, 12, 0, 3, 255, 5, 0, 2, 0, 0, 0, 3, 255, 4, 0, 2, 255, 6, 0, 2, 0, 0, 0, 2, 255, 11, 0, 3, 255, 8, 0, 3, 255, 6, 0, 3, 0, 0, 0, 3, 255, 39, 0, 2, 0, 0, 2, 255, 10, 0, 2, 255, 17, 0, 3, 0, 0, 3, 255, 10, 0, 3, 255, 11, 0, 2, 255, 27, 0, 2, 0, 0, 0, 3, 255, 22, 0, 2, 255, 4, 0, 3, 255, 26, 0, 3, 255, 27, 0, 2, 255, 31, 0, 3, 255, 4, 0, 2, 0, 0, 0, 2, 255, 27, 0, 3, 0, 0, 0, 3, 255, 5, 0, 2, 255, 31, 0, 3, 255, 50, 0, 2, 255, 6, 0, 2, 255, 24, 0, 3, 255, 6, 0, 3, 255, 7, 0, 2, 255, 14, 0, 2, 255, 39, 0,
255, 4, 0, 2, 255, 4, 0, 3, 255, 5, 0, 2, 255, 8, 0, 3, 255, 11, 0, 3, 255, 10, 0, 3, 255, 13, 0, 2, 255, 24, 0, 2, 255, 6, 0, 3, 255, 24, 0, 3, 255, 15, 0, 2, 255, 6, 0, 2, 255, 24, 0, 3, 255, 6, 0, 3, 255, 4, 0, 2, 255, 10, 0, 2, 255, 4, 0, 2, 255, 15, 0, 3, 255, 5, 0, 2, 255, 4, 0, 3, 255, 4, 0, 3, 255, 6, 0, 2, 255, 14, 0, 3, 255, 16, 0, 3, 255, 52, 0, 2, 255, 20, 0, 2, 255, 10, 0, 3, 255, 7, 0, 2, 255, 7, 0, 2, 255, 4, 0, 3, 255, 18, 0, 3, 255, 7, 0, 3, 255, 8, 0, 2, 255, 31, 0, 3, 255, 10, 0, 2, 255, 25, 0, 2, 255, 5, 0, 3, 255, 6, 0, 2, 255, 9, 0, 2, 255, 8, 0, 3, 255, 12, 0, 3, 255, 5, 0, 2, 0, 0, 0, 3, 255, 4, 0, 2, 255, 6, 0, 2, 0, 0, 0, 2, 255, 11, 0, 3, 255, 8, 0, 3, 255, 6, 0, 3, 0, 0, 0, 3, 255, 39, 0, 2, 0, 0, 2, 255, 10, 0, 2, 255, 31, 0, 3, 255, 11, 0, 2, 255, 27, 0, 2, 0, 0, 0, 3, 255, 22, 0, 2, 255, 4, 0, 3, 255, 26, 0, 3, 255, 27, 0, 2, 255, 31, 0, 3, 255, 4, 0, 2, 0, 0, 0, 2, 255, 27, 0, 3, 0, 0, 0, 3, 255, 5, 0, 2, 255, 31, 0, 3, 255, 50, 0, 2, 255, 6, 0, 2, 255, 24, 0, 3, 255, 37, 0
};
uint16_t couple_snow_delays[] = {110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110};
uint16_t couple_snow_offsets[] = {0,291,580,875,1162,1443,1728,2023,2310,2583,2864,3151,3445,3746,4035,4320,4609,4905,5205,5502,5803,6108,6417,6722,7011,7295,7583,7884,8189,8486,8779,9068,9354};
AnimationData couple_snow = {&couple_snow_colors[0], &couple_snow_data[0], &couple_snow_offsets[0], &couple_snow_delays[0], false, 12, 32, 32, 32};
uint16_t animation_couple_snow_delays[] = {110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110};
uint16_t animation_couple_snow_offsets[] = {0, 291, 580, 875, 1162, 1443, 1728, 2023, 2310, 2583, 2864, 3151, 3445, 3746, 4035, 4320, 4609, 4905, 5205, 5502, 5803, 6108, 6417, 6722, 7011, 7295, 7583, 7884, 8189, 8486, 8779, 9068, 9354};
AnimationData animation_couple_snow = {&animation_couple_snow_colors[0], &animation_couple_snow_data[0], &animation_couple_snow_offsets[0], &animation_couple_snow_delays[0], false, 10, 32, 32, 32};
uint32_t heart_colors[] = {0x000000, 0x000000, 0x000000, 0xAB2121, 0xFF1E00, 0xFF6A07};
uint8_t heart_data[] PROGMEM = {
uint8_t animation_heart_colors[] PROGMEM = {0, 0, 0, 171, 33, 33, 255, 30, 0, 255, 106, 7};
uint8_t animation_heart_data[] PROGMEM = {
255, 167, 2, 3, 255, 5, 4, 3, 255, 4, 2, 3, 255, 5, 4, 3, 255, 13, 2, 255, 9, 4, 2, 2, 255, 9, 4, 255, 11, 2, 4, 4, 4, 5, 5, 255, 17, 4, 255, 9, 2, 3, 4, 4, 255, 4, 5, 255, 16, 4, 3, 255, 8, 2, 4, 4, 4, 255, 4, 5, 255, 17, 4, 255, 7, 2, 3, 4, 4, 4, 255, 4, 5, 255, 17, 4, 3, 255, 6, 2, 3, 255, 4, 4, 5, 5, 255, 18, 4, 3, 255, 6, 2, 3, 255, 24, 4, 3, 255, 6, 2, 3, 255, 24, 4, 3, 255, 7, 2, 255, 24, 4, 255, 8, 2, 3, 255, 22, 4, 3, 255, 9, 2, 3, 255, 20, 4, 3, 255, 11, 2, 255, 20, 4, 255, 13, 2, 255, 18, 4, 255, 15, 2, 255, 16, 4, 255, 17, 2, 255, 14, 4, 255, 19, 2, 255, 12, 4, 255, 21, 2, 255, 10, 4, 255, 23, 2, 255, 8, 4, 255, 25, 2, 255, 6, 4, 255, 27, 2, 255, 4, 4, 255, 29, 2, 4, 4, 255, 175, 2,
255, 136, 0, 255, 5, 3, 255, 6, 0, 255, 5, 3, 255, 15, 0, 4, 255, 5, 0, 4, 255, 4, 0, 4, 255, 5, 0, 4, 255, 75, 0, 4, 255, 22, 0, 4, 255, 39, 0, 4, 255, 24, 0, 4, 255, 6, 0, 4, 255, 24, 0, 4, 255, 6, 0, 4, 255, 24, 0, 4, 255, 6, 0, 4, 255, 24, 0, 4, 255, 62, 0, 4, 255, 30, 0, 4, 255, 10, 0, 3, 255, 32, 0, 3, 255, 18, 0, 3, 255, 13, 0, 3, 255, 16, 0, 3, 255, 15, 0, 3, 255, 14, 0, 3, 255, 17, 0, 3, 255, 12, 0, 3, 255, 19, 0, 3, 255, 10, 0, 3, 255, 21, 0, 3, 255, 8, 0, 3, 255, 23, 0, 3, 255, 6, 0, 3, 255, 25, 0, 3, 255, 4, 0, 3, 255, 27, 0, 3, 0, 0, 3, 255, 174, 0,
255, 103, 0, 255, 6, 3, 255, 6, 0, 255, 6, 3, 255, 13, 0, 255, 7, 4, 3, 255, 4, 0, 3, 255, 6, 4, 3, 255, 11, 0, 4, 4, 255, 7, 0, 3, 0, 0, 3, 255, 7, 0, 4, 3, 255, 9, 0, 4, 4, 255, 9, 0, 4, 4, 255, 9, 0, 4, 3, 255, 8, 0, 4, 0, 0, 5, 0, 4, 255, 17, 0, 4, 255, 7, 0, 3, 0, 0, 5, 0, 0, 0, 4, 255, 17, 0, 3, 255, 6, 0, 4, 0, 0, 5, 0, 0, 0, 4, 255, 17, 0, 4, 255, 9, 0, 5, 0, 0, 0, 4, 255, 28, 0, 5, 0, 4, 255, 89, 0, 4, 255, 24, 0, 4, 255, 6, 0, 3, 4, 255, 23, 0, 3, 255, 7, 0, 4, 4, 255, 21, 0, 4, 255, 9, 0, 4, 255, 20, 0, 4, 255, 10, 0, 4, 4, 255, 18, 0, 4, 4, 255, 11, 0, 4, 4, 255, 16, 0, 4, 4, 255, 12, 0, 4, 4, 4, 255, 14, 0, 4, 4, 4, 255, 13, 0, 4, 4, 4, 255, 12, 0, 4, 4, 4, 255, 15, 0, 4, 4, 4, 255, 10, 0, 4, 4, 4, 255, 17, 0, 4, 4, 4, 255, 8, 0, 4, 4, 4, 255, 19, 0, 4, 4, 4, 255, 6, 0, 4, 4, 4, 255, 21, 0, 4, 4, 4, 255, 4, 0, 4, 4, 4, 255, 23, 0, 4, 4, 4, 0, 0, 4, 4, 4, 255, 25, 0, 3, 255, 4, 4, 3, 255, 141, 0,
@ -155,6 +156,6 @@ uint8_t heart_data[] PROGMEM = {
255, 135, 0, 255, 7, 2, 255, 4, 0, 255, 7, 2, 255, 13, 0, 2, 2, 255, 6, 3, 2, 0, 0, 2, 2, 255, 5, 3, 2, 2, 255, 11, 0, 2, 3, 255, 7, 0, 3, 2, 2, 3, 255, 7, 0, 2, 2, 255, 9, 0, 2, 3, 0, 4, 0, 5, 255, 5, 0, 3, 3, 255, 9, 0, 2, 2, 255, 7, 0, 2, 2, 0, 4, 0, 0, 0, 5, 255, 16, 0, 2, 2, 255, 6, 0, 2, 3, 0, 4, 0, 0, 0, 5, 255, 16, 0, 3, 2, 255, 6, 0, 2, 3, 0, 4, 0, 0, 0, 5, 255, 16, 0, 3, 2, 255, 6, 0, 2, 3, 0, 0, 4, 0, 5, 255, 17, 0, 3, 2, 255, 6, 0, 2, 3, 255, 22, 0, 3, 2, 255, 6, 0, 2, 3, 255, 22, 0, 3, 2, 255, 6, 0, 2, 2, 255, 22, 0, 2, 2, 255, 6, 0, 2, 2, 255, 22, 0, 2, 2, 255, 7, 0, 2, 2, 255, 20, 0, 2, 2, 255, 9, 0, 2, 3, 255, 18, 0, 3, 2, 255, 11, 0, 2, 3, 255, 16, 0, 3, 2, 255, 12, 0, 2, 2, 3, 255, 14, 0, 3, 2, 2, 255, 13, 0, 2, 2, 3, 255, 12, 0, 3, 2, 2, 255, 15, 0, 2, 2, 3, 255, 10, 0, 3, 2, 2, 255, 17, 0, 2, 2, 3, 255, 8, 0, 3, 2, 2, 255, 19, 0, 2, 2, 3, 255, 6, 0, 3, 2, 2, 255, 21, 0, 2, 2, 3, 255, 4, 0, 3, 2, 2, 255, 23, 0, 2, 2, 3, 0, 0, 3, 2, 2, 255, 26, 0, 2, 3, 3, 2, 255, 29, 0, 2, 2, 255, 143, 0,
255, 167, 0, 3, 255, 5, 4, 255, 5, 0, 3, 255, 5, 4, 3, 255, 13, 0, 4, 255, 7, 0, 4, 0, 0, 4, 255, 7, 0, 4, 255, 11, 0, 4, 255, 9, 0, 4, 4, 255, 9, 0, 4, 255, 9, 0, 3, 255, 22, 0, 3, 255, 8, 0, 4, 255, 22, 0, 4, 255, 7, 0, 3, 4, 255, 22, 0, 4, 3, 255, 6, 0, 3, 4, 255, 22, 0, 4, 3, 255, 6, 0, 3, 4, 255, 22, 0, 4, 3, 255, 6, 0, 3, 4, 255, 22, 0, 4, 3, 255, 7, 0, 4, 255, 22, 0, 4, 255, 8, 0, 3, 255, 22, 0, 3, 255, 9, 0, 3, 255, 20, 0, 3, 255, 11, 0, 4, 255, 18, 0, 4, 255, 13, 0, 4, 255, 16, 0, 4, 255, 15, 0, 4, 255, 14, 0, 4, 255, 17, 0, 4, 255, 12, 0, 4, 255, 19, 0, 4, 255, 10, 0, 4, 255, 21, 0, 4, 255, 8, 0, 4, 255, 23, 0, 4, 255, 6, 0, 4, 255, 25, 0, 4, 255, 4, 0, 4, 255, 27, 0, 4, 0, 0, 4, 255, 29, 0, 4, 4, 255, 175, 0
};
uint16_t heart_delays[] = {100,100,100,100,100,100,100,400,100,100,100,100,100,100,200};
uint16_t heart_offsets[] = {0,190,344,608,875,1025,1291,1588,1790,1944,2208,2473,2627,2893,3190,3392};
AnimationData heart = {&heart_colors[0], &heart_data[0], &heart_offsets[0], &heart_delays[0], false, 6, 15, 32, 32};
uint16_t animation_heart_delays[] = {100, 100, 100, 100, 100, 100, 100, 400, 100, 100, 100, 100, 100, 100, 200};
uint16_t animation_heart_offsets[] = {0, 190, 344, 608, 875, 1025, 1291, 1588, 1790, 1944, 2208, 2473, 2627, 2893, 3190, 3392};
AnimationData animation_heart = {&animation_heart_colors[0], &animation_heart_data[0], &animation_heart_offsets[0], &animation_heart_delays[0], false, 4, 15, 32, 32};

View File

@ -230,31 +230,37 @@ class Animation : public Effect {
Serial.printf("Animation.loop. Animation is %p.", (void *)animation);
CRGB colors[animation->color_count];
int led_index = 0;
for (int i = 0; i < animation->color_count; i++) colors[i] = CRGB(animation->colors[i]);
uint8_t *color_data = new uint8_t[animation->color_count * 3];
memcpy_P(color_data, animation->colors, animation->color_count * 3);
for (int i = 0; i < animation->color_count; i++) colors[i] = CRGB(color_data[i * 3], color_data[i * 3 + 1], color_data[i * 3 + 2]);
free(color_data);
// Data is stored in progmem, so get it from there.
int length = animation->offsets[frame + 1] - animation->offsets[frame];
uint8_t *data = new uint8_t[length];
memcpy_P(data, animation->data + animation->offsets[frame], length);
for (int i = 0; i < length; i++) {
uint8_t color_index;
uint8_t count;
if (data[i] == 255) { // Run-length encoded data
uint8_t color = data[i + 2];
for (int j = 0; j < data[i + 1]; j++) {
if (color > 1) {
set(led_index, colors[data[i + 2]]);
} else if (color==1) {
set(led_index, background_color);
}
led_index++;
}
color_index = data[i + 2];
count = data[i + 1];
i += 2;
} else {
uint8_t color = data[i];
if (color > 1) {
set(led_index, colors[data[i]]);
} else if (color == 1) {
set(led_index, background_color);
color_index = data[i];
count = 1;
}
led_index++;
if (color_index == 0) { // color #0 = skip this pixels
led_index += count;
} else {
CRGB* color;
if (color_index == 1) {
color = &background_color;
} else if (color_index >= 2) {
color = &colors[color_index - 2];
}
for (int j = 0; j < count; j++) set(led_index++, color);
}
}
free(data);