MustafaMulla29/wireless-mouse-pcb

A tscircuit package created by MustafaMulla29.

Version
1.0.16
License
unset
Stars
0

firmware/src/status_led.c

/* SPDX-License-Identifier: Apache-2.0 */

#include "status_led.h"

#include <errno.h>
#include <zephyr/device.h>
#include <zephyr/drivers/led_strip.h>

static const struct device *const strip = DEVICE_DT_GET(DT_ALIAS(led_strip));

int status_led_init(void)
{
	if (!device_is_ready(strip)) {
		return -ENODEV;
	}
	status_led_set(0, 0, 0);
	return 0;
}

void status_led_set(uint8_t red, uint8_t green, uint8_t blue)
{
	struct led_rgb pixel = {
		.r = red,
		.g = green,
		.b = blue,
	};

	if (device_is_ready(strip)) {
		(void)led_strip_update_rgb(strip, &pixel, 1);
	}
}