Archived
1
0

Initial code for Animation stack

This commit is contained in:
Jacob Alexander 2016-01-03 23:45:13 -08:00
parent b30f8f5e97
commit ad1ea632e4
2 changed files with 113 additions and 2 deletions

View File

@ -32,6 +32,8 @@
// ----- Function Declarations -----
void cliFunc_aniAdd ( char* args );
void cliFunc_aniDel ( char* args );
void cliFunc_chanTest ( char* args );
void cliFunc_pixelList ( char* args );
void cliFunc_pixelTest ( char* args );
@ -53,11 +55,15 @@ typedef enum PixelTest {
// ----- Variables -----
// Macro Module command dictionary
CLIDict_Entry( aniAdd, "Add the given animation id to the stack" );
CLIDict_Entry( aniDel, "Remove the given stack index animation" );
CLIDict_Entry( chanTest, "Channel test. No arg - next pixel. # - pixel, r - roll-through. a - all, s - stop" );
CLIDict_Entry( pixelList, "Prints out pixel:channel mappings." );
CLIDict_Entry( pixelTest, "Pixel test. No arg - next pixel. # - pixel, r - roll-through. a - all, s - stop" );
CLIDict_Def( pixelCLIDict, "Pixel Module Commands" ) = {
CLIDict_Item( aniAdd ),
CLIDict_Item( aniDel ),
CLIDict_Item( chanTest ),
CLIDict_Item( pixelList ),
CLIDict_Item( pixelTest ),
@ -72,6 +78,9 @@ uint16_t Pixel_testPos;
// Indicates to pixel and output modules current state of the buffer
FrameState Pixel_FrameState;
// Animation Stack
AnimationStack Pixel_AnimationStack;
@ -225,6 +234,47 @@ const uint8_t testani_frame2[] = {
Pixel_ModRGB(0, Set, 60, 90, 140),
};
// Rainbow Animation - Hardcoded
const uint8_t rainbow_frame0[] = {
// Set 1
Pixel_ModRGB(84, Set, 127,0,255),
};
const uint8_t rainbow_frame1[] = {
// Set 1
Pixel_ModRGB(84, Set, 127,0,255),
// Set 2
Pixel_ModRGB(16, Set, 127,0,255),
Pixel_ModRGB(35, Set, 127,0,255),
Pixel_ModRGB(53, Set, 127,0,255),
Pixel_ModRGB(68, Set, 127,0,255),
Pixel_ModRGB(85, Set, 127,0,255),
};
const uint8_t rainbow_frame2[] = {
// Set 1
Pixel_ModRGB(84, Set, 127,0,255),
// Set 2
Pixel_ModRGB(16, Set, 127,0,255),
Pixel_ModRGB(35, Set, 127,0,255),
Pixel_ModRGB(53, Set, 127,0,255),
Pixel_ModRGB(68, Set, 127,0,255),
Pixel_ModRGB(85, Set, 127,0,255),
// Set 3
Pixel_ModRGB(0, Set, 127,0,255),
Pixel_ModRGB(17, Set, 127,0,255),
Pixel_ModRGB(36, Set, 127,0,255),
Pixel_ModRGB(54, Set, 127,0,255),
Pixel_ModRGB(70, Set, 127,0,255),
Pixel_ModRGB(86, Set, 127,0,255),
};
// Index of frames for animations
// uint8_t *<animation>_frames[] = { <animation>_frame<num>, ... }
const uint8_t *testani_frames[] = {
@ -233,10 +283,20 @@ const uint8_t *testani_frames[] = {
testani_frame2,
};
// Rainbow frame index
const uint8_t *rainbow_frames[] = {
rainbow_frame0,
rainbow_frame1,
rainbow_frame2,
};
// Index of animations
// uint8_t *Pixel_Animations[] = { <animation>_frames, ... }
const uint8_t **Pixel_Animations[] = {
testani_frames,
rainbow_frames,
};
// -------------------------------
@ -391,6 +451,9 @@ inline void Pixel_process()
break;
}
// Start from the top of the Animation Stack
// TODO
pixel_process_done:
// Frame is now ready to send
@ -408,6 +471,9 @@ inline void Pixel_setup()
// Disable test modes by default, start at position 0
Pixel_testMode = PixelTest_Off;
// Clear animation stack
Pixel_AnimationStack.size = 0;
}
@ -592,3 +658,25 @@ void cliFunc_chanTest( char* args )
Pixel_testPos = 0;
}
void cliFunc_aniAdd( char* args )
{
print( NL ); // No \r\n by default after the command is entered
// TODO
uint16_t index = Pixel_AnimationStack.size;
Pixel_AnimationStack.stack[index].index = 1;
Pixel_AnimationStack.stack[index].pos = 1;
Pixel_AnimationStack.stack[index].loops = 1;
Pixel_AnimationStack.stack[index].divider = 0;
Pixel_AnimationStack.stack[index].modifier = AnimationModifier_None;
Pixel_AnimationStack.size++;
}
void cliFunc_aniDel( char* args )
{
print( NL ); // No \r\n by default after the command is entered
// TODO
Pixel_AnimationStack.size--;
}

View File

@ -44,7 +44,7 @@ typedef enum FrameState {
// * Add no-rollover
// * Subtract no-rollover
typedef enum PixelChange {
PixelChange_Set = 0, // <no op>
PixelChange_Set = 0, // =
PixelChange_Add, // +
PixelChange_Subtract, // -
PixelChange_NoRoll_Add, // +:
@ -54,6 +54,13 @@ typedef enum PixelChange {
} PixelChange;
// Animation modifiers
typedef enum AnimationModifier {
AnimationModifier_None = 0x00,
AnimationModifier_Fallthrough = 0x01, // Process lower animation first
} AnimationModifier;
// ----- Structs -----
@ -74,7 +81,7 @@ typedef struct PixelBuf {
typedef struct PixelElement {
uint8_t width; // Number of bits in a channel
uint8_t channels; // Number of channels
// Hardware indices for each channel
// Hardware indices for each channel
uint16_t indices[Pixel_MaxChannelPerPixel];
} PixelElement;
#define Pixel_RGBChannel(r,g,b) { 8, 3, { r, g, b } }
@ -89,6 +96,22 @@ typedef struct PixelMod {
uint8_t data[0]; // Data size depends on PixelElement definition
} PixelMod;
// Animation stack element
typedef struct AnimationElement {
uint16_t index; // Animation id
uint16_t pos; // Current frame
uint8_t loops; // # of loops to run animation, 0 indicates infinite
uint8_t divider; // # of times to repeat each frame
AnimationModifier modifier; // Modifier applied to the entire animation
} AnimationElement;
// Animation stack
#define Pixel_AnimationStackSize 16
typedef struct AnimationStack {
uint16_t size;
AnimationElement stack[Pixel_AnimationStackSize];
} AnimationStack;
// ----- Variables -----