#ifndef _LED_H__
#define _LED_H__

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

#ifdef __cplusplus
extern "C" {
#endif

#define LED_INTERVAL						            10

#define WS2812B_NORMAL_RGB                              0x0000FF00
#define WS2812B_RST_RGB                                 0x00FFFFCC
#define WS2812B_BLE_RGB                                 0x0000FF40
#define WS2812B_CANID_ERROR_RGB                         0x00FFD700
#define WS2812B_OFFLINE_RGB                             0x00FFEC8B

#define LED_VIEW_ALARM_COLOR                            0x00FF9900                         //报警
#define LED_VIEW_WARN_COLOR                             0x00FFFF00                         //警告
#define LED_VIEW_LOCK_ELECT_COLOR                       0x00FF0000                         //有挂锁并上锁
#define LED_VIEW_NOLOCK_ELECT_COLOR                     0x00FF0000                         //无挂锁并上锁
#define LED_VIEW_LOCK_NOELECT_COLOR                     0x0000FF00                         //有挂锁没上锁
#define LED_VIEW_NOLOCK_NOELECT_COLOR                   0x0000FF00                         //无挂锁没上锁

#define FLICKER_DELAYTIME_DEFAULT                       100 / USER_WS2812B_INTERVAL
#define ID_ERROR_FLICKER_DEFAULT                        1000 / USER_WS2812B_INTERVAL
#define OFFLINE_FLICKER_DEFAULT                         200 / USER_WS2812B_INTERVAL
#define BREATH_SPEED_DEFAULT                            2000 / USER_WS2812B_INTERVAL

typedef enum
{
    LED_QUEUE_TIME	= 0,
}LED_QUEUE_TYPE;

typedef enum{
    DEV_LED 		= 0,
    LED_01 		    = 1,
    LED_02 		    = 2,
    LED_03 		    = 3,
    LED_04 		    = 4,
    LED_05 		    = 5,
    LED_TYPE_MAX	= 6,
}LED_TYPE;

typedef struct{
    uint8_t red;
    uint8_t green;
    uint8_t blue;
}led_color_s;

typedef enum{
    LED_STAT_OFF 	= 0,
    LED_STAT_ON		= 1
}LED_STAT;

typedef enum{
    LED_WORK_OFF 	    = 0,            //暗
    LED_WORK_ON 	    = 1,            //亮
    LED_WORK_INVERT 	= 2,            //闪烁
    LED_WORK_BREATHE    = 4,            //呼吸模式
    LED_WORK_MAX 	    = 5,
}LED_WORK_STAT;

typedef enum{
    LED_VIEW_NULL = 0,
    LED_VIEW_ENTER_OTA, 
    LED_VIEW_OTA,       
}led_view_stat_e;

typedef struct{
    const uint8_t idx;
    LED_STAT stat;                        
    led_color_s color;
    LED_WORK_STAT workStat;
    led_view_stat_e viewStat;
    uint32_t single_flicker_period;
    uint32_t flicker_period ;
    uint32_t flicker_onperiod;
    uint32_t flicker_count;
    uint8_t duty_value;
    uint32_t single_on_durationTime;		//PWM变化结束后持续时间，单位：ms
    uint32_t on_durationTime;			    //PWM变化结束后持续时间，单位：ms
    uint32_t single_off_durationTime;		//PWM变化结束后持续时间，单位：ms
    uint32_t off_durationTime;			    //PWM变化结束后持续时间，单位：ms
}led_work_s;

void led_task_init(void);
void led_task_start(void);
bool set_led_indication(LED_TYPE type, uint32_t color, LED_WORK_STAT work_stat, ...);
void vUser_led_set_view_stat(led_view_stat_e stat);

extern tmosTaskID led_task_id;

#ifdef __cplusplus
}
#endif

#endif // LED_H__

/** @} */
