1 /*
2  * Copyright (c) 2024 Arduino SA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <stdio.h>
8 #include <zephyr/kernel.h>
9 #include <zephyr/drivers/led.h>
10 
11 /* 1000 msec = 1 sec */
12 #define SLEEP_TIME_MS   1000
13 
14 /* Structure describing a color by its component values and name */
15 struct color_data {
16 	uint8_t r, g, b;
17 	const char *name;
18 };
19 
20 /* The sequence of colors the RGB LED will display */
21 static const struct color_data color_sequence[] = {
22 	{ 0xFF, 0x00, 0x00, "Red" },
23 	{ 0x00, 0xFF, 0x00, "Green" },
24 	{ 0x00, 0x00, 0xFF, "Blue" },
25 	{ 0xFF, 0xFF, 0xFF, "White" },
26 	{ 0xFF, 0xFF, 0x00, "Yellow" },
27 	{ 0xFF, 0x00, 0xFF, "Purple" },
28 	{ 0x00, 0xFF, 0xFF, "Cyan" },
29 	{ 0xF4, 0x79, 0x20, "Orange" },
30 };
31 
32 /*
33  * A build error on this line means your board is unsupported.
34  */
35 const struct device *led = DEVICE_DT_GET_ANY(issi_is31fl3194);
36 
main(void)37 int main(void)
38 {
39 	int ret;
40 	int i = 0;
41 
42 	if (!device_is_ready(led)) {
43 		return 0;
44 	}
45 
46 	while (1) {
47 		ret = led_set_color(led, 0, 3, &(color_sequence[i].r));
48 		if (ret < 0) {
49 			return 0;
50 		}
51 
52 		printk("LED color: %s\n", color_sequence[i].name);
53 		k_msleep(SLEEP_TIME_MS);
54 		i = (i + 1) % ARRAY_SIZE(color_sequence);
55 	}
56 
57 	return 0;
58 }
59