#ifndef LEDS_H
#define LEDS_H

#include <stdint.h>

#define LED_COUNT 21
#define NEOPIXEL_PIN GPIO_NUM_0
// 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define LED_STRIP_RMT_RES_HZ  (10 * 1000 * 1000)

enum LEDColor: uint32_t {
    LED_COLOR_OFF = 0x00'00'00,
    LED_COLOR_RED = 0x17'00'00,
    LED_COLOR_RED_STRONG = 0xFF'00'00,
    LED_COLOR_ORANGE = 0x17'02'00,
    LED_COLOR_ORANGE_STRONG = 0xFF'20'00,
    LED_COLOR_YELLOW = 0x07'07'00,
    LED_COLOR_YELLOW_STRONG = 0xFF'FF'00,
    LED_COLOR_GREEN = 0x00'07'00,
    LED_COLOR_GREEN_STRONG = 0x00'FF'00,
    LED_COLOR_BLUE = 0x00'00'17,
    LED_COLOR_BLUE_STRONG = 0x00'00'FF,
    LED_COLOR_PINK = 0x10'00'04,
    LED_COLOR_PINK_STRONG = 0xFF'00'80,
    LED_COLOR_WHITE = 0x04'04'04,
    LED_COLOR_WHITE_STRONG = 0xFF'FF'FF,
};

// TODO: sepperate the indicator leds from the shape display.
enum IndicatorLED {
    LED_SHAPE1 = 0u,
    LED_SHAPE2 = 1u,
    LED_SHAPE3 = 2u,
    LED_SHAPE4 = 3u,
    LED_MODULE_SSEG = 4u,
    LED_GAME_SSEG = 5u,
    LED_TFT = 6u,
    LED_MIC = 7u,
    LED_IR_LED = 8u,
    LED_SPEAKER = 9u,
    LED_RFID = 10u,
    LED_KEYPAD = 11u,
    LED_LCD = 12u,
    LED_S4 = 13u,
    LED_S3 = 14u,
    LED_S2 = 15u,
    LED_S1 = 16u,
    LED_B4 = 17u,
    LED_B3 = 18u,
    LED_B2 = 19u,
    LED_B1 = 20u,
    LED_MAX = 20u,
};

/// @brief Initializes the indicator LEDs
void init_leds();

/// Sets the color of an LED.
///
/// Call `flush_leds()` to send the data to the LEDs.
void led_set(uint32_t led, uint32_t color);

/// Sets the color of an LED with rgb.
///
/// Call `flush_leds()` to send the data to the LEDs.
void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b);

/// Outputs the data to the leds.
void leds_flush();

/// Clears the LEDs
void leds_clear();

#endif /* LEDS_H */