Led

All boards come with an on-board RGB LED. The RGB LED is able to light up the board in various colors and patterns.

Users can control the LED with the functions in the led.h header file.

Setting Patterns

An led pattern is represented by the MblMwLedPattern struct. Users can configure every part of the pulse or load one of the preset patterns using the mbl_mw_led_load_preset_pattern function. Patterns are written to the board with the mbl_mw_led_write_pattern function.

To remove patterns, call mbl_mw_led_stop__and_clear; this will also stop pattern playback.

#include "metawear/peripheral/led.h"

void set_led_pattern(MblMwMetaWearBoard* board) {
    MblMwLedPattern pattern;

    // Load the blink pattern
    mbl_mw_led_load_preset_pattern(&pattern, MBL_MW_LED_PRESET_BLINK);

    // Write the blink pattern to the blue channel
    mbl_mw_led_write_pattern(board, &pattern, MBL_MW_LED_COLOR_BLUE);
}

Pattern Playback

After writing patterns to the board, you can playback the pattern, similar to playing a music track, using mbl_mw_led_play, mbl_mw_led_pause, and mbl_mw_led_stop.

#include "metawear/peripheral/led.h"

void start_pattern(MblMwMetaWearBoard* board) {
    // Start playing the programmed patterns
    mbl_mw_led_play(board);
}