Tiny-WS2812  1.0.0
A tiny cross-platform WS2812 LED Strip driver
Functions
ws2812_common.c File Reference

Common code shared accross all supported platforms. More...

#include <stdio.h>
#include <string.h>
#include <ws2812.h>
Include dependency graph for ws2812_common.c:

Go to the source code of this file.

Functions

void _ws2812_get_rgbmap (uint8_t(*rgbmap)[3], ws2812_order order)
 Initializes a rgb map for a given color order. More...
 

Detailed Description

Common code shared accross all supported platforms.

Author
Patrick Pedersen
Date
2021-04-09

The following file holds the Tiny-WS2812 code used throughout all platforms.

Definition in file ws2812_common.c.

Function Documentation

◆ _ws2812_get_rgbmap()

void _ws2812_get_rgbmap ( uint8_t(*)  rgbmap[3],
ws2812_order  order 
)

Initializes a rgb map for a given color order.

The following function is intended only to be used for internal library code, hence the _ prefix. It fills a 3 element byte array with the necessary offsets to map/convert RGB values to a different color order. For example, setting the order to rgb fills the rgb map with 0, 1, 2 and bgr fill the rgb map with 2, 1, 0, etc.

Definition at line 43 of file ws2812_common.c.

44 {
45  switch (order) {
46  case rbg:
47  memcpy(rgbmap, ws2812_order_rbg, 3);
48  break;
49  case brg:
50  memcpy(rgbmap, ws2812_order_brg, 3);
51  break;
52  case bgr:
53  memcpy(rgbmap, ws2812_order_bgr, 3);
54  break;
55  case grb:
56  memcpy(rgbmap, ws2812_order_grb, 3);
57  break;
58  case gbr:
59  memcpy(rgbmap, ws2812_order_gbr, 3);
60  break;
61  default: // rgb
62  memcpy(rgbmap, ws2812_order_rgb, 3);
63  break;
64  }
65 }