This is a tiny compiler to create different LED sequences. It uses C macros to create the bytecode that will be interpreted by the badge for a colorful experience.
Refer to template.c for the template.
Basically, you want to write your program in the compiling_sequence array. For example programs, please check the examples folder.
Compile with gcc template.c and launch the resulting binary. It will output both the length and the sequence in hex. Simply paste it in the led load command.
First of all, you should define the sequence length. Sequence size is measured in frames.
The frame counter ticks at the speed of the fps configuration in the badge. For example, if fps=30, a sequence with the length of 150 frames will last 5 seconds.
To define the sequence length, use the macro LED_FRAMES_DEF.
Now, you need to create instructions. Instructions are grouped in a block and executed ON A SPECIFIC FRAME.
Consider this example: On frame 50, set LEDs 1 and 3 to color #F00F00 for the next 100 frames.
This translates to:
LED_FRAME_START(50),
LED_SELECT(1, 3),
LED_SET_COLOR_RGB(0xf0, 0x0f, 0x00, 100);
LED_FRAME_END(),
Frame descriptions can overlap (consider examples/overlap.c for an example).
Define the number of frames (n) in the sequence. 65535 is the maximum value.
Start instruction block at the specified frame (tick).
Select LEDs for the next command. You can select up to 4 LEDs at once.
Reset all selected LEDs.
Set LED to the specified RGB color (defined by r, g, and b as #rrggbb) for the next length frames.
When using RGB, the maximum values for r, g, and b are 255.
Set LED to the specified HSV color (defined by h (hue), s (saturation), v (value)) for the next length frames.
When using HSV:
hhas a range from 0 to 359 (including 0 and 359)sandvhave a range from 0 to 100 (including 0 and 100)
Set LED to the first color and gradually transform it to the second color within the length frames. RGB version.
Set LED to the first color and gradually transform it to the second color within the length frames. HSV version.
Every period frames, change from the specified color to black and vice-versa. RGB version.
Every period frames, change from the specified color to black and vice-versa. HSV version.