LEDs
The four RGB LEDs - driven directly, or through the OS pattern engine
The device has 4 RGB LEDs, indexed 0-3. The OS runs its own animations on them, so stop whatever is playing before driving them directly:
os_led_stop_current(); // once, in init() hal_led_set_rgb(0, 100, 70, 20); // then from tick()
Patterns versus direct writes
Writing from tick() is the simple route and costs nothing but the call. For anything that animates on its own clock, hand the OS a led_pattern_t instead: the LED task steps it on its own timer, so the animation keeps running at a steady rate even when the app's tick() is busy, and it survives a skipped frame. See examples/leds/ for a pattern usage example.
Note — When the app exits the firmware blanks the LEDs and re-pushes the pattern that was running before it - there is nothing to restore in deinit().
Set one LED's colour
| const uint8_t | led_num | LED index, 0-3 |
| const uint8_t | red | 0-255 |
| const uint8_t | green | 0-255 |
| const uint8_t | blue | 0-255 |
Note — The driver latches: an LED keeps its last written colour until it is changed (or the app exits - the firmware blanks and restores then).
Stop the OS LED pattern currently playing
Read the step counter from inside a pattern callback
| const os_led_t* | led |
Start a pattern, replacing whatever is currently playing
| led_pattern_t* | pattern | |
| const void* | ctx | becomes the pattern's ctx for this run (NULL clears it) - the callback reads it |
Note — The pattern outlives the call - give it static storage, not a local.