Macros | |
#define | CY_RSLT_RGB_LED_CLK_FAIL (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_RGB_LED , 0)) |
Error code for RGB LED operation: Peripheral clock assignment failure. | |
#define | CY_RSLT_RGB_LED_PWM_FAIL (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_RGB_LED , 1)) |
Error code for RGB LED operation: PWM resource allocation failure. | |
#define | CY_RSLT_RGB_LED_LP_CB_REG_FAIL (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_RGB_LED , 2)) |
Error code for RGB LED operation: Low power callback function registration failure. | |
#define | CY_RSLT_RGB_LED_LP_CB_DEREG_FAIL (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_RGB_LED , 3)) |
Error code for RGB LED operation: Low power callback function deregistration failure. | |
#define | CY_RGB_LED_RED_POS (16u) |
Bit position for Red LED. | |
#define | CY_RGB_LED_GREEN_POS (8u) |
Bit position for Green LED. | |
#define | CY_RGB_LED_BLUE_POS (0u) |
Bit position for Blue LED. | |
#define | CY_RGB_LED_COLOR_RED (0xFF << CY_RGB_LED_RED_POS) |
32-bit encoding for Red Color More... | |
#define | CY_RGB_LED_COLOR_GREEN (0xFF << CY_RGB_LED_GREEN_POS) |
32-bit encoding for Green Color. More... | |
#define | CY_RGB_LED_COLOR_BLUE (0xFF << CY_RGB_LED_BLUE_POS) |
32-bit encoding for Blue Color. More... | |
#define | CY_RGB_LED_COLOR_WHITE |
32-bit encoding for White Color. More... | |
#define | CY_RGB_LED_COLOR_YELLOW (CY_RGB_LED_COLOR_RED | CY_RGB_LED_COLOR_GREEN) |
32-bit encoding for Yellow Color. More... | |
#define | CY_RGB_LED_COLOR_MAGENTA (CY_RGB_LED_COLOR_RED | CY_RGB_LED_COLOR_BLUE) |
32-bit encoding for Magenta Color. More... | |
#define | CY_RGB_LED_COLOR_PURPLE (CY_RGB_LED_COLOR_MAGENTA) |
Deprecated. More... | |
#define | CY_RGB_LED_COLOR_CYAN (CY_RGB_LED_COLOR_GREEN | CY_RGB_LED_COLOR_BLUE) |
32-bit encoding for Cyan Color. More... | |
#define | CY_RGB_LED_COLOR_OFF (0x00000000) |
No Color. More... | |
#define | CY_RGB_LED_MAX_BRIGHTNESS (100u) |
Maximum LED Brightness. | |
#define | CY_RGB_LED_ACTIVE_HIGH (true) |
RGB LED active HIGH logic. | |
#define | CY_RGB_LED_ACTIVE_LOW (false) |
RGB LED active LOW logic. | |
Functions | |
cy_rslt_t | cy_rgb_led_init (cyhal_gpio_t pin_red, cyhal_gpio_t pin_green, cyhal_gpio_t pin_blue, bool led_active_logic) |
Initializes RGB LED on the board. More... | |
void | cy_rgb_led_deinit (void) |
De-initializes the RGB LED on the board. | |
void | cy_rgb_led_on (uint32_t color, uint8_t brightness) |
Turns on RGB LED with specified color and brightness. More... | |
void | cy_rgb_led_off (void) |
Turns off the RGB LED on the board. | |
void | cy_rgb_led_toggle (void) |
Toggles the RGB LED on the board. | |
void | cy_rgb_led_set_color (uint32_t color) |
Sets color of the RGB LED. More... | |
uint32_t | cy_rgb_led_get_color (void) |
Returns the current color of the RGB LED. More... | |
static uint32_t | cy_rgb_led_create_color (uint8_t red, uint8_t green, uint8_t blue) |
Create a custom color code for the RGB LED. More... | |
void | cy_rgb_led_set_brightness (uint8_t brightness) |
Sets brightness of the RGB LED. More... | |
uint8_t | cy_rgb_led_get_brightness (void) |
Returns the current brightness of the RGB LED. More... | |
#define CY_RGB_LED_COLOR_RED (0xFF << CY_RGB_LED_RED_POS) |
32-bit encoding for Red Color
Note: LED Color is encoded as 0x00RRGGBB where RR - byte field for Red color GG - byte field for Green color BB - byte field for Blue color
Each byte represents 256 (0x00 to 0xFF) different brightness level for each LED color (Red, Green, Blue). Colors can be generated varying these byte fields.
For example: 0x00FFFFFF (RR = 0xFF; GG = 0xFF BB = 0xFF) produces white color.
0x00FFFF00 (RR = 0xFF; GG = 0xFF BB = 0x00) produces yellow color.
#define CY_RGB_LED_COLOR_GREEN (0xFF << CY_RGB_LED_GREEN_POS) |
32-bit encoding for Green Color.
Refer to CY_RGB_LED_COLOR_RED for color encoding scheme
#define CY_RGB_LED_COLOR_BLUE (0xFF << CY_RGB_LED_BLUE_POS) |
32-bit encoding for Blue Color.
Refer to CY_RGB_LED_COLOR_RED for color encoding scheme
#define CY_RGB_LED_COLOR_WHITE |
32-bit encoding for White Color.
Refer to CY_RGB_LED_COLOR_RED for color encoding scheme
#define CY_RGB_LED_COLOR_YELLOW (CY_RGB_LED_COLOR_RED | CY_RGB_LED_COLOR_GREEN) |
32-bit encoding for Yellow Color.
Refer to CY_RGB_LED_COLOR_RED for color encoding scheme
#define CY_RGB_LED_COLOR_MAGENTA (CY_RGB_LED_COLOR_RED | CY_RGB_LED_COLOR_BLUE) |
32-bit encoding for Magenta Color.
Refer to CY_RGB_LED_COLOR_RED for color encoding scheme
#define CY_RGB_LED_COLOR_PURPLE (CY_RGB_LED_COLOR_MAGENTA) |
Deprecated.
Use CY_RGB_LED_COLOR_MAGENTA instead
#define CY_RGB_LED_COLOR_CYAN (CY_RGB_LED_COLOR_GREEN | CY_RGB_LED_COLOR_BLUE) |
32-bit encoding for Cyan Color.
Refer to CY_RGB_LED_COLOR_RED for color encoding scheme
#define CY_RGB_LED_COLOR_OFF (0x00000000) |
No Color.
Refer to CY_RGB_LED_COLOR_RED for color encoding scheme
cy_rslt_t cy_rgb_led_init | ( | cyhal_gpio_t | pin_red, |
cyhal_gpio_t | pin_green, | ||
cyhal_gpio_t | pin_blue, | ||
bool | led_active_logic | ||
) |
Initializes RGB LED on the board.
pin_red | GPIO for Red component. |
pin_green | GPIO for Green component. |
pin_blue | GPIO for Blue component. |
led_active_logic | Active logic (low or high) for the RGB LED, all three LEDs must be connected in same active logic. |
void cy_rgb_led_on | ( | uint32_t | color, |
uint8_t | brightness | ||
) |
Turns on RGB LED with specified color and brightness.
color | LED color |
brightness | Brightness of the LED (Valid range: 0 to CY_RGB_LED_MAX_BRIGHTNESS). |
void cy_rgb_led_set_color | ( | uint32_t | color | ) |
Sets color of the RGB LED.
color | LED color |
uint32_t cy_rgb_led_get_color | ( | void | ) |
Returns the current color of the RGB LED.
|
inlinestatic |
Create a custom color code for the RGB LED.
red | 1-byte value for Red component. |
green | 1-byte value for Green component. |
blue | 1-byte value for Blue component. |
void cy_rgb_led_set_brightness | ( | uint8_t | brightness | ) |
Sets brightness of the RGB LED.
brightness | LED brightness (Valid range: 0 to CY_RGB_LED_MAX_BRIGHTNESS) |
uint8_t cy_rgb_led_get_brightness | ( | void | ) |
Returns the current brightness of the RGB LED.