Skip to content

drivers: led: support variable brightness granularity #87737

@jeppenodgaard

Description

@jeppenodgaard

Is your enhancement proposal related to a problem? Please describe.
Some LED drivers, e.g. LED PWM, supports a higher granularity than the current 0-100 range.

Increase the supported range to allow adjusting the light level with a finer granularity.

This is useful for delicate devices that needs a constant and precise lumen output from an LED.

Describe the solution you'd like

  1. Increase led_set_brightness's value type to uint16_t to allow using full granularity for all LED drivers. Maybe even uint32_t.
    Return an errno if the value is above maximum supported.

or

  1. To prevent modifying a lot of the LED code base it might be worth adding a new optional API function that allows full range and keep the existing led_set_brightness. This also allows having a brightness function that is simple to use from an application point of view. Function name and prototype suggestion:
    int led_set_brightness_raw(const struct device *dev, uint32_t led, uint32_t value)

Describe alternatives you've considered
Using DAC or PWM API directly to control an LED device.

Additional context
Discord discussion:
https://discord.com/channels/720317445772017664/1352646386113314846

Metadata

Metadata

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: LEDLabel to identify LED subsystem

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions