-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(led_strip): Support RGB pixel order
- Loading branch information
Showing
8 changed files
with
134 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include "esp_err.h" | ||
#include "led_strip_types.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define LED_PIXEL_FORMAT_3COLORS_MAX LED_PIXEL_FORMAT_RGB | ||
|
||
/** | ||
* @brief LED strip pixel order index | ||
*/ | ||
typedef enum { | ||
LED_PIXEL_INDEX_RED, /*!< Red pixel index */ | ||
LED_PIXEL_INDEX_GREEN, /*!< Green pixel index */ | ||
LED_PIXEL_INDEX_BLUE, /*!< Blue pixel index */ | ||
LED_PIXEL_INDEX_WHITE, /*!< White pixel index */ | ||
LED_PIXEL_INDEX_MAX /*!< Max pixel index */ | ||
} led_pixel_order_index_t; | ||
|
||
/** | ||
* @brief Config LED pixel order | ||
* | ||
* @param led_pixel_offset Each pixel's offset | ||
* @param led_pixel_format Input LED strip pixel format | ||
* @return | ||
* - ESP_OK: Config LED pixel order successfully | ||
* - ESP_ERR_INVALID_ARG: Config LED pixel order failed because of invalid argument | ||
* - ESP_FAIL: Config LED pixel order failed because some other error | ||
*/ | ||
esp_err_t led_strip_config_pixel_order(uint8_t *led_pixel_offset, led_pixel_format_t led_pixel_format); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <stdbool.h> | ||
#include "esp_log.h" | ||
#include "esp_check.h" | ||
#include "esp_private/led_strip_common.h" | ||
|
||
static const char *TAG = "led_strip_common"; | ||
esp_err_t led_strip_config_pixel_order(uint8_t *led_pixel_offset, led_pixel_format_t led_pixel_format) | ||
{ | ||
ESP_RETURN_ON_FALSE(led_pixel_offset, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); | ||
switch (led_pixel_format) { | ||
case LED_PIXEL_FORMAT_GRB: | ||
led_pixel_offset[0] = 1; | ||
led_pixel_offset[1] = 0; | ||
led_pixel_offset[2] = 2; | ||
break; | ||
case LED_PIXEL_FORMAT_RGB: | ||
led_pixel_offset[0] = 0; | ||
led_pixel_offset[1] = 1; | ||
led_pixel_offset[2] = 2; | ||
break; | ||
case LED_PIXEL_FORMAT_GRBW: | ||
led_pixel_offset[0] = 0; | ||
led_pixel_offset[1] = 2; | ||
led_pixel_offset[2] = 1; | ||
led_pixel_offset[3] = 3; | ||
break; | ||
case LED_PIXEL_FORMAT_RGBW: | ||
led_pixel_offset[0] = 0; | ||
led_pixel_offset[1] = 1; | ||
led_pixel_offset[2] = 2; | ||
led_pixel_offset[3] = 3; | ||
break; | ||
default: | ||
ESP_RETURN_ON_FALSE(false, ESP_ERR_INVALID_ARG, TAG, "invalid pixel format"); | ||
} | ||
return ESP_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters