Skip to content

Commit 2df905d

Browse files
Emil Dahl Juhlkartben
authored andcommitted
samples: led: lp5569: demo write_channels
Add a simple demonstration of the led_write_channels api on the lp5569 driver sample. The demonstration simply turns on all of the channels with a single call to led_write_channels. Then the same is done for turning off the channels. Thus, it doesn't add much visually, but it shows the usage of the api. Signed-off-by: Emil Dahl Juhl <[email protected]>
1 parent d6ac9e8 commit 2df905d

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

doc/releases/release-notes-4.1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Drivers and Sensors
142142
* Added a new set of devicetree based LED APIs, see :c:struct:`led_dt_spec`.
143143
* lp5569: added use of auto-increment functionality.
144144
* lp5569: implemented ``write_channels`` api.
145+
* lp5569: demonstrate ``led_write_channels`` in the sample.
145146

146147
* LED Strip
147148

samples/drivers/led/lp5569/README.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ Overview
88
********
99

1010
This sample controls 9 LEDs connected to an LP5569 driver. The sample turns
11-
all LEDs on and switches all LEDs off again within a one second interval.
11+
all LEDs on one by one with a 1 second delay between each. Then it fades all
12+
LEDs until they are off again. Afterwards, it turns them all on at once, waits
13+
a second, and turns them all back off.
14+
This pattern then repeats indefinitely.
1215

1316
Building and Running
1417
********************

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(app, CONFIG_LED_LOG_LEVEL);
1818
int main(void)
1919
{
2020
const struct device *const led_dev = DEVICE_DT_GET_ANY(ti_lp5569);
21+
uint8_t ch_buf[9] = {0};
2122
int i, ret;
2223

2324
if (!led_dev) {
@@ -32,7 +33,8 @@ int main(void)
3233

3334
/*
3435
* Display a continuous pattern that turns on 9 LEDs at 1 s one by
35-
* one until it reaches the end and turns off LEDs in reverse order.
36+
* one until it reaches the end and fades off all LEDs.
37+
* Afterwards, all LEDs get blinked once at the same time.
3638
*/
3739

3840
LOG_INF("Testing 9 LEDs ..");
@@ -59,6 +61,26 @@ int main(void)
5961

6062
k_sleep(DELAY_TIME_BREATHING);
6163
}
64+
65+
k_sleep(DELAY_TIME_ON);
66+
67+
/* Turn on all LEDs at once to demonstrate write_channels */
68+
memset(ch_buf, 255, ARRAY_SIZE(ch_buf));
69+
ret = led_write_channels(led_dev, 0, ARRAY_SIZE(ch_buf), ch_buf);
70+
if (ret) {
71+
return ret;
72+
}
73+
74+
k_sleep(DELAY_TIME_ON);
75+
76+
/* Turn off all LEDs at once to demonstrate write_channels */
77+
memset(ch_buf, 0, ARRAY_SIZE(ch_buf));
78+
ret = led_write_channels(led_dev, 0, ARRAY_SIZE(ch_buf), ch_buf);
79+
if (ret) {
80+
return ret;
81+
}
82+
83+
k_sleep(DELAY_TIME_ON);
6284
}
6385
return 0;
6486
}

0 commit comments

Comments
 (0)