11static const char *
TAG =
"led_strip";
15 ESP_RETURN_ON_FALSE(strip, ESP_ERR_INVALID_ARG,
TAG,
"invalid argument");
16 return strip->
set_pixel(strip, index, red, green, blue);
21 ESP_RETURN_ON_FALSE(strip, ESP_ERR_INVALID_ARG,
TAG,
"invalid argument");
27 uint32_t rgb_max = value;
28 uint32_t rgb_min = rgb_max * (255 - saturation) / 255.0f;
30 uint32_t i = hue / 60;
31 uint32_t diff = hue % 60;
34 uint32_t rgb_adj = (rgb_max - rgb_min) * diff / 60;
39 green = rgb_min + rgb_adj;
43 red = rgb_max - rgb_adj;
50 blue = rgb_min + rgb_adj;
54 green = rgb_max - rgb_adj;
58 red = rgb_min + rgb_adj;
65 blue = rgb_max - rgb_adj;
69 return strip->
set_pixel(strip, index, red, green, blue);
74 ESP_RETURN_ON_FALSE(strip, ESP_ERR_INVALID_ARG,
TAG,
"invalid argument");
75 return strip->
set_pixel_rgbw(strip, index, red, green, blue, white);
80 ESP_RETURN_ON_FALSE(strip, ESP_ERR_INVALID_ARG,
TAG,
"invalid argument");
86 ESP_RETURN_ON_FALSE(strip, ESP_ERR_INVALID_ARG,
TAG,
"invalid argument");
87 return strip->
clear(strip);
92 ESP_RETURN_ON_FALSE(strip, ESP_ERR_INVALID_ARG,
TAG,
"invalid argument");
93 return strip->
del(strip);
esp_err_t led_strip_clear(led_strip_handle_t strip)
Clear LED strip (turn off all LEDs).
esp_err_t led_strip_set_pixel_rgbw(led_strip_handle_t strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue, uint32_t white)
Set RGBW for a specific pixel.
esp_err_t led_strip_set_pixel_hsv(led_strip_handle_t strip, uint32_t index, uint16_t hue, uint8_t saturation, uint8_t value)
Set HSV for a specific pixel.
esp_err_t led_strip_refresh(led_strip_handle_t strip)
Refresh memory colors to LEDs.
esp_err_t led_strip_del(led_strip_handle_t strip)
Free LED strip resources.
esp_err_t led_strip_set_pixel(led_strip_handle_t strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue)
Set RGB for a specific pixel.
struct led_strip_t * led_strip_handle_t
LED strip handle.
esp_err_t(* refresh)(led_strip_t *strip)
Refresh memory colors to LEDs.
esp_err_t(* set_pixel)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue)
Set RGB for a specific pixel.
esp_err_t(* del)(led_strip_t *strip)
Free LED strip resources.
esp_err_t(* set_pixel_rgbw)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue, uint32_t white)
Set RGBW for a specific pixel. Similar to set_pixel but also set the white component.
esp_err_t(* clear)(led_strip_t *strip)
Clear LED strip (turn off all LEDs).