Select Git revision
Forked from
card10 / firmware
Source project has a limited visibility.
-
rahix authored
Signed-off-by:
Rahix <rahix@rahix.de>
rahix authoredSigned-off-by:
Rahix <rahix@rahix.de>
leds.c 5.09 KiB
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/queue.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "esp_system.h"
#include "badge23/leds.h"
#include "badge23_hwconfig.h"
#if defined(CONFIG_BADGE23_HW_GEN_P1)
#define LED_SPI_PORT
#elif defined(CONFIG_BADGE23_HW_GEN_P3) || defined(CONFIG_BADGE23_HW_GEN_P4)
#define LED_ASYNC_PORT
#else
#error "leds not implemented for this badge generation"
#endif
typedef struct leds_cfg {
int leaf;
size_t size;
size_t position;
size_t slot;
int timer;
} leds_cfg_t;
static leds_cfg_t active_leds[11];
struct RGB
{
unsigned char R;
unsigned char G;
unsigned char B;
};
struct HSV
{
double H;
double S;
double V;
};
struct RGB HSVToRGB(struct HSV hsv) {
double r = 0, g = 0, b = 0;
if (hsv.S == 0)
{
r = hsv.V;
g = hsv.V;
b = hsv.V;
}
else
{
int i;
double f, p, q, t;
if (hsv.H == 360)
hsv.H = 0;
else
hsv.H = hsv.H / 60;
i = (int)trunc(hsv.H);
f = hsv.H - i;
p = hsv.V * (1.0 - hsv.S);
q = hsv.V * (1.0 - (hsv.S * f));
t = hsv.V * (1.0 - (hsv.S * (1.0 - f)));