Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
led_strip.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Linaro Limited
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
15#ifndef ZEPHYR_INCLUDE_DRIVERS_LED_STRIP_H_
16#define ZEPHYR_INCLUDE_DRIVERS_LED_STRIP_H_
17
25#include <zephyr/types.h>
26#include <device.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
38struct led_rgb {
39#ifdef CONFIG_LED_STRIP_RGB_SCRATCH
40 /*
41 * Pad/scratch space needed by some drivers. Users should
42 * ignore.
43 */
44 uint8_t scratch;
45#endif
52};
53
60typedef int (*led_api_update_rgb)(const struct device *dev,
61 struct led_rgb *pixels,
62 size_t num_pixels);
63
70typedef int (*led_api_update_channels)(const struct device *dev,
71 uint8_t *channels,
72 size_t num_channels);
73
82};
83
99static inline int led_strip_update_rgb(const struct device *dev,
100 struct led_rgb *pixels,
101 size_t num_pixels) {
102 const struct led_strip_driver_api *api =
103 (const struct led_strip_driver_api *)dev->api;
104
105 return api->update_rgb(dev, pixels, num_pixels);
106}
107
125static inline int led_strip_update_channels(const struct device *dev,
126 uint8_t *channels,
127 size_t num_channels) {
128 const struct led_strip_driver_api *api =
129 (const struct led_strip_driver_api *)dev->api;
130
131 return api->update_channels(dev, channels, num_channels);
132}
133
134#ifdef __cplusplus
135}
136#endif
137
142#endif /* ZEPHYR_INCLUDE_DRIVERS_LED_STRIP_H_ */
int(* led_api_update_rgb)(const struct device *dev, struct led_rgb *pixels, size_t num_pixels)
Callback API for updating an RGB LED strip.
Definition: led_strip.h:60
static int led_strip_update_rgb(const struct device *dev, struct led_rgb *pixels, size_t num_pixels)
Update an LED strip made of RGB pixels.
Definition: led_strip.h:99
static int led_strip_update_channels(const struct device *dev, uint8_t *channels, size_t num_channels)
Update an LED strip on a per-channel basis.
Definition: led_strip.h:125
int(* led_api_update_channels)(const struct device *dev, uint8_t *channels, size_t num_channels)
Callback API for updating channels without an RGB interpretation.
Definition: led_strip.h:70
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
Color value for a single RGB LED.
Definition: led_strip.h:38
uint8_t r
Definition: led_strip.h:47
uint8_t g
Definition: led_strip.h:49
uint8_t b
Definition: led_strip.h:51
LED strip driver API.
Definition: led_strip.h:79
led_api_update_channels update_channels
Definition: led_strip.h:81
led_api_update_rgb update_rgb
Definition: led_strip.h:80