Add brightness setting
This commit is contained in:
71
README.md
71
README.md
@@ -141,6 +141,22 @@ void rgb_demo(void) {
|
||||
}
|
||||
```
|
||||
|
||||
### HSV + Global Brightness
|
||||
|
||||
```c
|
||||
#include "led_manager.h"
|
||||
|
||||
void hsv_demo(void) {
|
||||
led_manager_init(GPIO_NUM_8);
|
||||
|
||||
// Set a teal color using HSV
|
||||
led_manager_set_hsv(180, 255, 200);
|
||||
|
||||
// Dim the LED globally without changing hue/saturation
|
||||
led_manager_set_brightness(64);
|
||||
}
|
||||
```
|
||||
|
||||
## 📚 API Reference
|
||||
|
||||
### Data Types
|
||||
@@ -354,6 +370,61 @@ led_manager_set_rgb(255, 165, 0); // Orange variant
|
||||
led_manager_set_rgb(75, 0, 130); // Indigo
|
||||
```
|
||||
|
||||
##### `esp_err_t led_manager_set_hsv(uint16_t hue, uint8_t saturation, uint8_t value)`
|
||||
|
||||
Set LED color using HSV values.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `hue`: Hue component (0-360)
|
||||
- `saturation`: Saturation component (0-255)
|
||||
- `value`: Value/brightness component (0-255)
|
||||
|
||||
**Returns:**
|
||||
|
||||
- `ESP_OK`: Color set successfully
|
||||
- `ESP_ERR_INVALID_STATE`: LED manager not initialized
|
||||
- Hardware error codes on failure
|
||||
|
||||
**Technical Details:**
|
||||
|
||||
- Stores HSV as the current color for blinking
|
||||
- Global brightness scales the `value` component
|
||||
- If blinking is active, color updates take effect on the next blink cycle
|
||||
|
||||
**Example:**
|
||||
|
||||
```c
|
||||
// Teal-ish color
|
||||
led_manager_set_hsv(180, 255, 200);
|
||||
```
|
||||
|
||||
##### `esp_err_t led_manager_set_brightness(uint8_t brightness)`
|
||||
|
||||
Set global brightness without changing the current hue/saturation.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `brightness`: Brightness value (0-255)
|
||||
|
||||
**Returns:**
|
||||
|
||||
- `ESP_OK`: Brightness updated successfully
|
||||
- `ESP_ERR_INVALID_STATE`: LED manager not initialized
|
||||
- Hardware error codes on failure
|
||||
|
||||
**Technical Details:**
|
||||
|
||||
- Scales the current HSV value when pushing to the LED
|
||||
- If blinking is active, brightness applies to subsequent blink updates
|
||||
|
||||
**Example:**
|
||||
|
||||
```c
|
||||
// Dim to 25%
|
||||
led_manager_set_brightness(64);
|
||||
```
|
||||
|
||||
#### Control Functions
|
||||
|
||||
##### `esp_err_t led_manager_clear(void)`
|
||||
|
||||
Reference in New Issue
Block a user