Commit 2df905dc authored by Emil Dahl Juhl's avatar Emil Dahl Juhl Committed by Benjamin Cabé
Browse files

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: default avatarEmil Dahl Juhl <emdj@bang-olufsen.dk>
parent d6ac9e84
Loading
Loading
Loading
Loading
+1 −0
Changes for doc/releases/release-notes-4.1.rst: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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

+4 −1
Changes for samples/drivers/led/lp5569/README.rst: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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
********************
+23 −1
Changes for samples/drivers/led/lp5569/src/main.c: 23 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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;
}