Tiny-WS2812  1.0.0
A tiny cross-platform WS2812 LED Strip driver
ws2812.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Patrick Pedersen
3 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  *
17  */
18 
55 #pragma once
56 
57 #ifdef WS2812_TARGET_PLATFORM_AVR
58 #ifdef _WS2812_TARGET_PLATFORM_DEFINED
59 #error "Multiple target platforms defined!"
60 #endif
61 #define _WS2812_TARGET_PLATFORM_DEFINED
62 #include "ws2812_avr.h"
63 #endif
64 
65 #ifdef WS2812_TARGET_PLATFORM_ARDUINO_AVR
66 #ifdef _WS2812_TARGET_PLATFORM_DEFINED
67 #error "Multiple target platforms defined!"
68 #endif
69 #define _WS2812_TARGET_PLATFORM_DEFINED
70 #include "ws2812_avr.h"
71 #endif
72 
73 #ifdef WS2812_TARGET_PLATFORM_STM8S
74 #ifdef _WS2812_TARGET_PLATFORM_DEFINED
75 #error "Multiple target platforms defined!"
76 #endif
77 #define _WS2812_TARGET_PLATFORM_DEFINED
78 #include "ws2812_stm8s.h"
79 #endif
80 
81 #ifndef _WS2812_TARGET_PLATFORM_DEFINED
82 #error "No target platform defined!"
83 #endif
84 
85 #include <stddef.h>
86 #include <stdint.h>
87 
88 #include "ws2812_common.h"
89 
99 void _ws2812_get_rgbmap(uint8_t (*rgbmap)[3], ws2812_order order);
100 
108 uint8_t ws2812_config(ws2812 *dev, ws2812_cfg *cfg);
109 
124 void ws2812_prep_tx(ws2812 *dev);
125 
138 void ws2812_tx(ws2812 *dev, ws2812_rgb *pxls, size_t n_pxls);
139 
153 void ws2812_wait_rst(ws2812 *dev);
154 
164 void ws2812_close_tx(ws2812 *dev);
ALL PLATFORMS: Data structure to configure a WS2812 device struct.
Definition: ws2812_avr.h:64
Data structure to hold RGB color values.
Definition: ws2812_common.h:67
ALL PLATFORMS: WS2812 device struct to drive one or more WS2812 devices.
Definition: ws2812_avr.h:107
void ws2812_close_tx(ws2812 *dev)
Closes a WS2812 transmission.
Definition: ws2812_avr.c:275
void ws2812_wait_rst(ws2812 *dev)
Waits for the WS2812 device to reset.
Definition: ws2812_avr.c:168
uint8_t ws2812_config(ws2812 *dev, ws2812_cfg *cfg)
Configures a WS2812 device struct.
Definition: ws2812_avr.c:126
void ws2812_prep_tx(ws2812 *dev)
Prepares the host device for data transmission.
Definition: ws2812_avr.c:159
void _ws2812_get_rgbmap(uint8_t(*rgbmap)[3], ws2812_order order)
Initializes a rgb map for a given color order.
Definition: ws2812_common.c:43
void ws2812_tx(ws2812 *dev, ws2812_rgb *pxls, size_t n_pxls)
Transmits RGB values to the provided WS2812 device.
Definition: ws2812_avr.c:264
Provides AVR platform specific definitions.
Definitions required by all platform specific headers.
ws2812_order
Enum to specify the WS2812 device's color order.
Definition: ws2812_common.h:44
Provides STM8S platform specific definitions.