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 <emdj@bang-olufsen.dk>
This commit is contained in:
parent
d6ac9e8424
commit
2df905dc2c
3 changed files with 28 additions and 2 deletions
|
@ -142,6 +142,7 @@ Drivers and Sensors
|
|||
* Added a new set of devicetree based LED APIs, see :c:struct:`led_dt_spec`.
|
||||
* lp5569: added use of auto-increment functionality.
|
||||
* lp5569: implemented ``write_channels`` api.
|
||||
* lp5569: demonstrate ``led_write_channels`` in the sample.
|
||||
|
||||
* LED Strip
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ Overview
|
|||
********
|
||||
|
||||
This sample controls 9 LEDs connected to an LP5569 driver. The sample turns
|
||||
all LEDs on and switches all LEDs off again within a one second interval.
|
||||
all LEDs on one by one with a 1 second delay between each. Then it fades all
|
||||
LEDs until they are off again. Afterwards, it turns them all on at once, waits
|
||||
a second, and turns them all back off.
|
||||
This pattern then repeats indefinitely.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
|
|
@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(app, CONFIG_LED_LOG_LEVEL);
|
|||
int main(void)
|
||||
{
|
||||
const struct device *const led_dev = DEVICE_DT_GET_ANY(ti_lp5569);
|
||||
uint8_t ch_buf[9] = {0};
|
||||
int i, ret;
|
||||
|
||||
if (!led_dev) {
|
||||
|
@ -32,7 +33,8 @@ int main(void)
|
|||
|
||||
/*
|
||||
* Display a continuous pattern that turns on 9 LEDs at 1 s one by
|
||||
* one until it reaches the end and turns off LEDs in reverse order.
|
||||
* one until it reaches the end and fades off all LEDs.
|
||||
* Afterwards, all LEDs get blinked once at the same time.
|
||||
*/
|
||||
|
||||
LOG_INF("Testing 9 LEDs ..");
|
||||
|
@ -59,6 +61,26 @@ int main(void)
|
|||
|
||||
k_sleep(DELAY_TIME_BREATHING);
|
||||
}
|
||||
|
||||
k_sleep(DELAY_TIME_ON);
|
||||
|
||||
/* Turn on all LEDs at once to demonstrate write_channels */
|
||||
memset(ch_buf, 255, ARRAY_SIZE(ch_buf));
|
||||
ret = led_write_channels(led_dev, 0, ARRAY_SIZE(ch_buf), ch_buf);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
k_sleep(DELAY_TIME_ON);
|
||||
|
||||
/* Turn off all LEDs at once to demonstrate write_channels */
|
||||
memset(ch_buf, 0, ARRAY_SIZE(ch_buf));
|
||||
ret = led_write_channels(led_dev, 0, ARRAY_SIZE(ch_buf), ch_buf);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
k_sleep(DELAY_TIME_ON);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue