



//#define HALF_POWER        	  		//半功率
#define FULL_POWER       	   		//全功率
#define SWITCH_DIMMER					//开关调光


#define io_pwm1          Pa.0
#define io_pwm2          Pa.4


#define LED_MAX_BRIGHT     	   255      //亮度最大值   



//#define LED_MIN_BRIGHT1     10	 // 4%	//亮度最小值  
#define LED_MIN_BRIGHT2     15	 // 6%	//亮度最小值 
//#define LED_MIN_BRIGHT3     25	 // 10%	//亮度最小值 
//#define LED_MIN_BRIGHT4     50	 // 20%	//亮度最小值 


#define LED_MIN_BRIGHT     	   LED_MIN_BRIGHT2	  



#define LED_FINAL_MIN_BRIGHT     	   LED_MIN_BRIGHT2		//LED_MIN_BRIGHT  * LED_MAX_CT
//LED_MIN_CT

#define LED_MAX_CT         	   100     //色温最大值  
#define LED_MIN_CT         	   0     //色温最大值  
#define LED_HALF_CT         	   50      //色温中间值  
#define LED_HALF_CT1         	   40      //色温中间值 
#define LED_HALF_CT2         	   60      //色温中间值 

#define Blinky_Duty           2   //闪灯时长 250*2ms
#define LED_CTT_STEP   10                         //点按变化级数
#define LED_BRIGHT_STEP   10                         //点按变化级数



#define short_press           1    
#define long_press            0
#define KEY_RELEASE_DATA           100 //150*2ms 按键释放时间    
#define KEY_EFFECT_TIME            200 //200*2ms 短按时间间隔
#define LED_SHORT_CT_STEP          10   //200*2ms 短按色温变化步进值
#define LED_LONG_CT_STEP          6   //200*2ms 长按色温变化步进值


#define pwm_speed           2    //pwm 步进值
#define pwm_slow_speed           1    //pwm 步进值
#define LED_PWM_STEP_INT     	3//  LED_PWM_STEP_INT*2MS中断处理一次
#define LED_PWM_STEP_INT1     	5//  LED_PWM_STEP_INT*2MS中断处理一次

#define blink_pwm_speed           2    //闪灯步进值
#define blink_PWM_STEP_INT     	2//  闪灯


#define	BRIGHT_UP_SHORT_PRESS    1
#define	BRIGHT_UP_LONG_PRESS     2
#define	BRIGHT_DOWN_SHORT_PRESS  3
#define	BRIGHT_DOWN_LONG_PRESS   4
#define	CT_COLD_SHORT_PRESS      5
#define	CT_COLD_LONG_PRESS       6
#define	CT_WARM_SHORT_PRESS      7
#define	CT_WARM_LONG_PRESS       8


extern byte  led_ct_delay;
extern byte led_flag;
#define b_led_on_off_fg      led_flag.0  
#define b_led_press_fg      led_flag.1  
#define b_key_fg      led_flag.2 

#define b_switch_enable      led_flag.3  
#define b_switch_low_cnt      led_flag.4 
#define b_switch_high_cnt      led_flag.5
#define b_dimmer_fg      led_flag.6
#define b_low_power_flg      led_flag.7



extern byte led_bright,led_ct,led_ct_y,led_ct_w;
extern byte yellow_final_val,white_final_val,yellow_current_val,white_current_val;
extern byte tempa,tempb;
extern word sum;
extern byte led_blink,led_blink_time;
extern byte key_press_status;
extern byte pwm_adjust_tick,Led_Tick_Delay,pwm_step;





extern void led_calc_final_pwm_val(void);
extern void led_init(void); 
extern void led_turn_on(void);
extern void led_turn_off(void);
extern void led_turn_bright_up(void);
extern void led_turn_bright_down(void);
extern void led_turn_ct_warm(void);
extern void led_turn_ct_cold(void);
extern void led_cold_max_mode(void);
extern void led_warm_max_mode(void);
extern void led_cold_warm_max_mode(void);
extern void led_sleep_mode(void);
extern void LED_brightness_set(void);
extern void LED_ct_set(void);
extern void LED_brightness_ct_set(void);
extern void led_sta_rd_from_eeporm(void);
extern void led_sta_wr_into_eeprom(void);

extern void LED_Blinky(void);
extern void led_turn_stop(void);
extern void pwm_int(void);
extern void switch_dimmer_process(void);
extern void get_ct_cold_data(void);
extern void get_ct_warm_data(void);










