Skip to content

Commit 6efca1a

Browse files
committed
samples: led_strip: Make LED brightness configurable
Expose a Kconfig option to adjust max brightness level Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent 11d1a90 commit 6efca1a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

samples/drivers/led/led_strip/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ config SAMPLE_LED_UPDATE_DELAY
99
help
1010
Delay between LED updates in ms.
1111

12+
config SAMPLE_LED_BRIGHTNESS
13+
int "LED brightness"
14+
default 16
15+
range 1 255
16+
help
17+
Brightness level of each LED. Defaults to a low value to make
18+
it easier to distinguish colors.
19+
1220
endmenu
1321

1422
source "Kconfig.zephyr"

samples/drivers/led/led_strip/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Building and Running
6565
The sample updates the LED strip periodically. The update frequency can be
6666
modified by changing the :kconfig:option:`CONFIG_SAMPLE_LED_UPDATE_DELAY`.
6767

68+
The brightness level of each LED can be adjusted by changing the
69+
:kconfig:option:`CONFIG_SAMPLE_LED_BRIGHTNESS` configuration option.
70+
6871
Then build and flash the application:
6972

7073
.. zephyr-app-commands::

samples/drivers/led/led_strip/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ LOG_MODULE_REGISTER(main);
3232
#define RGB(_r, _g, _b) { .r = (_r), .g = (_g), .b = (_b) }
3333

3434
static const struct led_rgb colors[] = {
35-
RGB(0x0f, 0x00, 0x00), /* red */
36-
RGB(0x00, 0x0f, 0x00), /* green */
37-
RGB(0x00, 0x00, 0x0f), /* blue */
35+
RGB(CONFIG_SAMPLE_LED_BRIGHTNESS, 0x00, 0x00), /* red */
36+
RGB(0x00, CONFIG_SAMPLE_LED_BRIGHTNESS, 0x00), /* green */
37+
RGB(0x00, 0x00, CONFIG_SAMPLE_LED_BRIGHTNESS), /* blue */
3838
};
3939

4040
static struct led_rgb pixels[STRIP_NUM_PIXELS];

0 commit comments

Comments
 (0)