basic/display_animation/animation.c

See examples/basic/display-animation

/*
* ZentriOS SDK LICENSE AGREEMENT | Zentri.com, 2015.
*
* Use of source code and/or libraries contained in the ZentriOS SDK is
* subject to the Zentri Operating System SDK license agreement and
* applicable open source license agreements.
*
*/
#include "zos.h"
#include "utilities/zos_binary_helpers.h"
// COURTESY: Adafruit
// https://learn.adafruit.com/trinket-slash-gemma-space-invader-pendant/animation
//
// Animation data for Trinket/Gemma + LED matrix backpack jewelry.
// Edit this file to change the animation; it's unlikely you'll need
// to edit the source code.
RO_MEM uint8_t animation[] =
{
// Animation bitmaps. Each frame of animation MUST contain
// 8 lines of graphics data (there is no error checking for
// length). Each line should be prefixed with the letter 'BYTE('),
// followed by exactly 8 binary digits (0 or 1)), no more),
// no less (again), no error checking). '0' represents an
// 'off' pixel), '1' an 'on' pixel. End line with a comma.
BYTE(0001,1000), // This is the first frame for alien #1
BYTE(0011,1100), // If you squint you can kind of see the
BYTE(0111,1110), // image in the 0's and 1's.
BYTE(1101,1011),
BYTE(1111,1111),
BYTE(0010,0100),
BYTE(0101,1010),
BYTE(1010,0101),
// The 9th line (required) is the time to display this frame),
// in 1/100ths of a second (e.g. 100 = 1 sec), 25 = 1/4 sec),
// etc.). Range is 0 (no delay) to 255 (2.55 seconds). If
// longer delays are needed), make duplicate frames.
(uint8_t)250, // 0.25 seconds
BYTE(0001,1000), // This is the second frame for alien #1
BYTE(0011,1100),
BYTE(0111,1110),
BYTE(1101,1011),
BYTE(1111,1111),
BYTE(0010,0100),
BYTE(0101,1010),
BYTE(0100,0010),
(uint8_t)250, // 0.25 second delay
// Frames 3 & 4 for alien #1 are duplicates of frames 1 & 2.
// Rather than list them 'the tall way' again), the lines are merged here...
BYTE(0001,1000), BYTE(0011,1100), BYTE(0111,1110), BYTE(1101,1011), BYTE(1111,1111), BYTE(0010,0100), BYTE(0101,1010), BYTE(1010,0101), (uint8_t)250,
BYTE(0001,1000), BYTE(0011,1100), BYTE(0111,1110), BYTE(1101,1011), BYTE(1111,1111), BYTE(0010,0100), BYTE(0101,1010), BYTE(0100,0010), (uint8_t)250,
BYTE(0000,0000), // First frame for alien #2
BYTE(0011,1100),
BYTE(0111,1110),
BYTE(1101,1011),
BYTE(1101,1011),
BYTE(0111,1110),
BYTE(0010,0100),
BYTE(1100,0011),
(uint8_t)250, // 0.25 second delay
BYTE(0011,1100), // Second frame for alien #2
BYTE(0111,1110),
BYTE(1101,1011),
BYTE(1101,1011),
BYTE(0111,1110),
BYTE(0010,0100),
BYTE(0010,0100),
BYTE(0010,0100),
(uint8_t)250,
// Frames 3 & 4 for alien #2 are duplicates of frames 1 & 2
BYTE(0000,0000), BYTE(0011,1100), BYTE(0111,1110), BYTE(1101,1011), BYTE(1101,1011), BYTE(0111,1110), BYTE(0010,0100), BYTE(1100,0011), (uint8_t)250,
BYTE(0011,1100), BYTE(0111,1110), BYTE(1101,1011), BYTE(1101,1011), BYTE(0111,1110), BYTE(0010,0100), BYTE(0010,0100), BYTE(0010,0100), (uint8_t)250,
BYTE(0010,0100), // First frame for alien #3
BYTE(0010,0100),
BYTE(0111,1110),
BYTE(1101,1011),
BYTE(1111,1111),
BYTE(1111,1111),
BYTE(1010,0101),
BYTE(0010,0100),
(uint8_t)250,
BYTE(0010,0100), // Second frame for alien #3
BYTE(1010,0101),
BYTE(1111,1111),
BYTE(1101,1011),
BYTE(1111,1111),
BYTE(0111,1110),
BYTE(0010,0100),
BYTE(0100,0010),
(uint8_t)250,
// Frames are duplicated as with prior aliens
BYTE(0010,0100), BYTE(0010,0100), BYTE(0111,1110), BYTE(1101,1011), BYTE(1111,1111), BYTE(1111,1111), BYTE(1010,0101), BYTE(0010,0100), (uint8_t)250,
BYTE(0010,0100), BYTE(1010,0101), BYTE(1111,1111), BYTE(1101,1011), BYTE(1111,1111), BYTE(0111,1110), BYTE(0010,0100), BYTE(0100,0010), (uint8_t)250,
BYTE(0011,1100), // First frame for alien #4
BYTE(0111,1110),
BYTE(0011,0011),
BYTE(0111,1110),
BYTE(0011,1100),
BYTE(0000,0000),
BYTE(0000,1000),
BYTE(0000,0000),
(uint8_t)120, // ~1/8 second delay
BYTE(0011,1100), // Second frame for alien #4
BYTE(0111,1110),
BYTE(1001,1001),
BYTE(0111,1110),
BYTE(0011,1100),
BYTE(0000,0000),
BYTE(0000,1000),
BYTE(0000,1000),
(uint8_t)120,
BYTE(0011,1100), // Third frame for alien #4 (NOT a repeat of frame 1)
BYTE(0111,1110),
BYTE(1100,1100),
BYTE(0111,1110),
BYTE(0011,1100),
BYTE(0000,0000),
BYTE(0000,0000),
BYTE(0000,1000),
(uint8_t)120,
BYTE(0011,1100), // Fourth frame for alien #4 (NOT a repeat of frame 2)
BYTE(0111,1110),
BYTE(0110,0110),
BYTE(0111,1110),
BYTE(0011,1100),
BYTE(0000,0000),
BYTE(0000,0000),
BYTE(0000,0000),
(uint8_t)120,
// Frames 5-8 are duplicates of 1-4), lines merged for brevity
BYTE(0011,1100), BYTE(0111,1110), BYTE(0011,0011), BYTE(0111,1110), BYTE(0011,1100), BYTE(0000,0000), BYTE(0000,1000), BYTE(0000,0000), (uint8_t)120,
BYTE(0011,1100), BYTE(0111,1110), BYTE(1001,1001), BYTE(0111,1110), BYTE(0011,1100), BYTE(0000,0000), BYTE(0000,1000), BYTE(0000,1000), (uint8_t)120,
BYTE(0011,1100), BYTE(0111,1110), BYTE(1100,1100), BYTE(0111,1110), BYTE(0011,1100), BYTE(0000,0000), BYTE(0000,0000), BYTE(0000,1000), (uint8_t)120,
BYTE(0011,1100), BYTE(0111,1110), BYTE(0110,0110), BYTE(0111,1110), BYTE(0011,1100), BYTE(0000,0000), BYTE(0000,0000), BYTE(0000,0000), (uint8_t)120,
};