Tiny-WS2812  1.0.0
A tiny cross-platform WS2812 LED Strip driver
Macros | Functions | Variables
blink_array.c File Reference

Blinks one or more WS2812 devices using a RGB array. More...

#include <stm8s.h>
#include <ws2812.h>
Include dependency graph for blink_array.c:

Go to the source code of this file.

Macros

#define N_LEDS   8
 Number of LEDs in the strip.
 
#define DATA_PORT_BASE   GPIOD_BaseAddress
 Port base address of the data pin.
 
#define DATA_PINS   {GPIO_PIN_4}
 Data pin(s) of the strip.
 
#define RESET_TIME   30
 Reset time in µs.
 
#define COLOR_ORDER   grb
 Color order of the strip.
 
#define WAIT_LOOPS   1000000
 

Functions

void init_16mhz_clk ()
 
void main ()
 

Variables

uint8_t pins [] = DATA_PINS
 
ws2812_rgb leds [N_LEDS]
 
ws2812 ws2812_dev
 

Detailed Description

Blinks one or more WS2812 devices using a RGB array.

Author
Patrick Pedersen
Date
2022-10-26

The following example showcases how the Tiny-WS2812 library can be used on STM8S platforms to blink an entire WS2812 device in red. In this rather memory expensive example, we achieve this by simply creating a rgb array equal to the number of LEDs on the WS2812 device, whose values we then transmit to the device using the ws2812_tx() function.

For a more memory efficient method, take a look at the blink_loop.c example.

Note
Please ensure that the WS2812_TARGET_PLATFORM_STM8S macro is defined during compilation. This can either be done by specifying -DWS2812_TARGET_PLATFORM_STM8S in the build flags, or by uncommenting the define WS2812_TARGET_PLATFORM_STM8S directive below.

Definition in file blink_array.c.