MetaWear C++ API  0.18.0
C++ implementation of the MetaWear protocol
Enumerations | Functions
neopixel.h File Reference

Interacts with NeoPixel strands. More...

#include "peripheral_common.h"

Go to the source code of this file.

Enumerations

enum  MblMwNeoPixelColorOrdering { MBL_MW_NP_WS2811_RGB = 0, MBL_MW_NP_WS2811_RBG, MBL_MW_NP_WS2811_GRB, MBL_MW_NP_WS2811_GBR }
 Color ordering for the NeoPixel color values. More...
 
enum  MblMwNeoPixelRotDirection { MBL_MW_NP_ROT_DIR_TOWARDS, MBL_MW_NP_ROT_DIR_AWAY }
 Enumeration of rotation directions. More...
 

Functions

METAWEAR_API void mbl_mw_neopixel_init_slow_strand (const MblMwMetaWearBoard *board, uint8_t strand, uint8_t gpio_pin, uint8_t n_pixels, MblMwNeoPixelColorOrdering ordering)
 Initializes memory on the MetaWear board for a NeoPixel strand with a slow operating speed (400 KHz) More...
 
METAWEAR_API void mbl_mw_neopixel_init_fast_strand (const MblMwMetaWearBoard *board, uint8_t strand, uint8_t gpio_pin, uint8_t n_pixels, MblMwNeoPixelColorOrdering ordering)
 Initializes memory on the MetaWear board for a NeoPixel strand with a fast operating speed (800 KHz) More...
 
METAWEAR_API void mbl_mw_neopixel_free_strand (const MblMwMetaWearBoard *board, uint8_t strand)
 Frees NeoPixel resources on the MetaWeard board for a specific strand. More...
 
METAWEAR_API void mbl_mw_neopixel_enable_hold (const MblMwMetaWearBoard *board, uint8_t strand)
 Enables strand holding which will not refresh with any LED changes until the hold is disabled. More...
 
METAWEAR_API void mbl_mw_neopixel_disable_hold (const MblMwMetaWearBoard *board, uint8_t strand)
 Disables strand holding. More...
 
METAWEAR_API void mbl_mw_neopixel_clear (const MblMwMetaWearBoard *board, uint8_t strand, uint8_t start, uint8_t end)
 Clears pixel states on a strand. More...
 
METAWEAR_API void mbl_mw_neopixel_set_color (const MblMwMetaWearBoard *board, uint8_t strand, uint8_t pixel, uint8_t red, uint8_t green, uint8_t blue)
 Sets pixel color. More...
 
METAWEAR_API void mbl_mw_neopixel_rotate (const MblMwMetaWearBoard *board, uint8_t strand, uint8_t count, uint16_t period_ms, MblMwNeoPixelRotDirection direction)
 Rotates the pixels on a strand. More...
 
METAWEAR_API void mbl_mw_neopixel_rotate_indefinitely (const MblMwMetaWearBoard *board, uint8_t strand, uint8_t period_ms, MblMwNeoPixelRotDirection direction)
 Rotates the pixels on a strand indefinitely. More...
 
METAWEAR_API void mbl_mw_neopixel_stop_rotation (const MblMwMetaWearBoard *board, uint8_t strand)
 Stops the pixel rotation. More...
 

Detailed Description

Interacts with NeoPixel strands.

Enumeration Type Documentation

◆ MblMwNeoPixelColorOrdering

Color ordering for the NeoPixel color values.

Enumerator
MBL_MW_NP_WS2811_RGB 

Red, green, blue order.

MBL_MW_NP_WS2811_RBG 

Red, blue, green order.

MBL_MW_NP_WS2811_GRB 

Green, red, blue order.

MBL_MW_NP_WS2811_GBR 

Green, blue, red order.

◆ MblMwNeoPixelRotDirection

Enumeration of rotation directions.

Enumerator
MBL_MW_NP_ROT_DIR_TOWARDS 

Pixels move towards the board.

MBL_MW_NP_ROT_DIR_AWAY 

Pixels move away from the board.

Function Documentation

◆ mbl_mw_neopixel_clear()

METAWEAR_API void mbl_mw_neopixel_clear ( const MblMwMetaWearBoard board,
uint8_t  strand,
uint8_t  start,
uint8_t  end 
)

Clears pixel states on a strand.

Parameters
boardPointer to the board to send the command to
strandStrand number to clear
startPixel index to start clearing from
endPixel index to clear to, inclusive

◆ mbl_mw_neopixel_disable_hold()

METAWEAR_API void mbl_mw_neopixel_disable_hold ( const MblMwMetaWearBoard board,
uint8_t  strand 
)

Disables strand holding.

The strand will be refreshed with any LED changes programmed while the hold was active

Parameters
boardPointer to the board to send the command to
strandStrand number (id) to release

◆ mbl_mw_neopixel_enable_hold()

METAWEAR_API void mbl_mw_neopixel_enable_hold ( const MblMwMetaWearBoard board,
uint8_t  strand 
)

Enables strand holding which will not refresh with any LED changes until the hold is disabled.

This let you to form complex LED patterns without having the strand refresh with partial changes.

Parameters
boardPointer to the board to send the command to
strandStrand number (id) to hold

◆ mbl_mw_neopixel_free_strand()

METAWEAR_API void mbl_mw_neopixel_free_strand ( const MblMwMetaWearBoard board,
uint8_t  strand 
)

Frees NeoPixel resources on the MetaWeard board for a specific strand.

Parameters
boardPointer to the board to send the command to
strandStrand index to free

◆ mbl_mw_neopixel_init_fast_strand()

METAWEAR_API void mbl_mw_neopixel_init_fast_strand ( const MblMwMetaWearBoard board,
uint8_t  strand,
uint8_t  gpio_pin,
uint8_t  n_pixels,
MblMwNeoPixelColorOrdering  ordering 
)

Initializes memory on the MetaWear board for a NeoPixel strand with a fast operating speed (800 KHz)

Parameters
boardPointer to the board to send the command to
strandStrand number (id) to initialize, can be in the range [0, 2]
orderingColor ordering format
gpio_pinGPIO pin the strand's data pin is connected to
n_pixelsNumber of pixels to allocate memory for

◆ mbl_mw_neopixel_init_slow_strand()

METAWEAR_API void mbl_mw_neopixel_init_slow_strand ( const MblMwMetaWearBoard board,
uint8_t  strand,
uint8_t  gpio_pin,
uint8_t  n_pixels,
MblMwNeoPixelColorOrdering  ordering 
)

Initializes memory on the MetaWear board for a NeoPixel strand with a slow operating speed (400 KHz)

Parameters
boardPointer to the board to send the command to
strandStrand number (id) to initialize, can be in the range [0, 2]
orderingColor ordering format
gpio_pinGPIO pin the strand's data pin is connected to
n_pixelsNumber of pixels to allocate memory for

◆ mbl_mw_neopixel_rotate()

METAWEAR_API void mbl_mw_neopixel_rotate ( const MblMwMetaWearBoard board,
uint8_t  strand,
uint8_t  count,
uint16_t  period_ms,
MblMwNeoPixelRotDirection  direction 
)

Rotates the pixels on a strand.

Parameters
boardPointer to the board to send the command to
strandStrand to rotate
directionRotation direction
countNumber of times to repeat the rotation
period_msAmount of time, in milliseconds, between rotations

◆ mbl_mw_neopixel_rotate_indefinitely()

METAWEAR_API void mbl_mw_neopixel_rotate_indefinitely ( const MblMwMetaWearBoard board,
uint8_t  strand,
uint8_t  period_ms,
MblMwNeoPixelRotDirection  direction 
)

Rotates the pixels on a strand indefinitely.

Parameters
boardPointer to the board to send the command to
strandStrand to rotate
directionRotation direction
period_msAmount of time, in milliseconds, between rotations

◆ mbl_mw_neopixel_set_color()

METAWEAR_API void mbl_mw_neopixel_set_color ( const MblMwMetaWearBoard board,
uint8_t  strand,
uint8_t  pixel,
uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

Sets pixel color.

Parameters
boardPointer to the board to send the command to
strandStrand number the pixel is on
pixelIndex of the pixel
redRed value, between [0, 255]
greenGreen value, between [0, 255]
blueBlue value, between [0, 255]

◆ mbl_mw_neopixel_stop_rotation()

METAWEAR_API void mbl_mw_neopixel_stop_rotation ( const MblMwMetaWearBoard board,
uint8_t  strand 
)

Stops the pixel rotation.

Parameters
boardPointer to the board to send the command to
strandStrand to stop LED rotation