/*******************************************************************************
 * @file    led_control.h
 * @brief   Direct LED control driver
 * @date    2026-03-30
 *
 * Controls dual-color LED green(P0.12) + orange(P0.29) via app_timer.
 * On/off timing, color, and repeat pattern managed per state in a table.
 ******************************************************************************/

#ifndef LED_CONTROL_H__
#define LED_CONTROL_H__

#include <stdint.h>
#include <stdbool.h>

/*==============================================================================
 * LED pin definitions
 *============================================================================*/
#define LED_PIN_GREEN       NRF_GPIO_PIN_MAP(0, 12)   /* Green LED */
#define LED_PIN_ORANGE      NRF_GPIO_PIN_MAP(0, 29)   /* Orange LED */
#define LED_ACTIVE_LOW      1                         /* 1 = Active Low (LED on when GPIO LOW) */

/*==============================================================================
 * LED state enumeration
 *============================================================================*/
typedef enum
{
    LED_STATE_OFF = 0,              /* All LEDs off */
    LED_STATE_POWER_ON,             /* 1: Power ON - green on 2s */
    LED_STATE_POWER_OFF,            /* 2: Power OFF - green on 2s then off */
    LED_STATE_ADVERTISING,          /* 3: BLE advertising - green blink 1s interval (repeat) */
    LED_STATE_DETACH_WARNING,       /* 4: Normal operation (detached) - green 1s on / 3s off (repeat) */
    LED_STATE_ALIGN_SEARCHING,      /* 5: Alignment mode (searching) - orange blink 1s interval (repeat) */
    LED_STATE_ALIGN_COMPLETE,       /* 6: Alignment mode (complete) - green 3s on / 1s off */
    LED_STATE_ERROR,                /* 7: Error - orange 3Hz blink x3 / off 1s (repeat) */
    LED_STATE_COUNT                 /* Array size */
} led_state_t;

/*==============================================================================
 * Public functions
 *============================================================================*/

/** @brief Initialize LED GPIO + create timer - call once from main() */
void led_init(void);

/** @brief Change LED state - immediately stops previous pattern and starts new one */
void led_set_state(led_state_t state);

/** @brief Get current LED state */
led_state_t led_get_state(void);

#endif /* LED_CONTROL_H__ */
