Skip to content

bi-zone/badge_led

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OFFZONE Badge Led Sequence Compiler

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.

How does it work?

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.

How to write programs

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).

Available functions

LED_FRAMES_DEF(n)

Define the number of frames (n) in the sequence. 65535 is the maximum value.

LED_FRAME_START(tick)

Start instruction block at the specified frame (tick).

LED_SELECT(...)

Select LEDs for the next command. You can select up to 4 LEDs at once.

LED_RESET_SELECTION()

Reset all selected LEDs.

LED_SET_COLOR_RGB(r, g, b, length)

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.

LED_SET_COLOR_HSV(h, s, v, length)

Set LED to the specified HSV color (defined by h (hue), s (saturation), v (value)) for the next length frames. When using HSV:

  • h has a range from 0 to 359 (including 0 and 359)
  • s and v have a range from 0 to 100 (including 0 and 100)

LED_ANIMATE_RGB(r1, g1, b1, r2, g2, b2, length)

Set LED to the first color and gradually transform it to the second color within the length frames. RGB version.

LED_ANIMATE_HSV(h1, s1, v1, h2, s2, v2, length)

Set LED to the first color and gradually transform it to the second color within the length frames. HSV version.

LED_BLINK_RGB(r, g, b, length, period)

Every period frames, change from the specified color to black and vice-versa. RGB version.

LED_BLINK_HSV(h, s, v, length, period)

Every period frames, change from the specified color to black and vice-versa. HSV version.

About

The utility to compile custom LED sequences for OFFZONE badges

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages