123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- #include "led.h"
- #include "key.h"
- #include "HT16C22.h"
- #include "FreeRTOS.h"
- #include "task.h"
- #include "pwm.h"
- #include "All_define.h"
- int Is_blink=0;
- Led_struct led_struct;
- void Set_LCD_lum(u16 lum)
- {
- switch(lum)
- {
- /* case 1:TIM_SetCompare1(TIM5,400);break;
- case 2:TIM_SetCompare1(TIM5,500);break;
- case 3:TIM_SetCompare1(TIM5,600);break;
- case 4:TIM_SetCompare1(TIM5,700);break;
- case 5:TIM_SetCompare1(TIM5,800);break;
- case 6:TIM_SetCompare1(TIM5,900);break;
- case 7:TIM_SetCompare1(TIM5,1000);break;*/
- case 1:timer_channel_output_pulse_value_config(TIMER4, TIMER_CH_0, 400);break;
- case 2:timer_channel_output_pulse_value_config(TIMER4, TIMER_CH_0, 500);break;
- case 3:timer_channel_output_pulse_value_config(TIMER4, TIMER_CH_0, 600);break;
- case 4:timer_channel_output_pulse_value_config(TIMER4, TIMER_CH_0, 700);break;
- case 5:timer_channel_output_pulse_value_config(TIMER4, TIMER_CH_0, 800);break;
- case 6:timer_channel_output_pulse_value_config(TIMER4, TIMER_CH_0, 900);break;
- case 7:timer_channel_output_pulse_value_config(TIMER4, TIMER_CH_0, 1000);break;
- default:break;
- }
- }
- void delay_led_sec(uint32_t sec)
- {
- for(int i=0;i<sec;i++)
- {
- for(int j=0;j<10;j++)
- Delay_SS();
- }
- }
- void Zigbee_led_blink(void)
- {
- uint16_t Low_value = dis_page_param.face_plate_param.Led_Brightness & 0x0f00;
-
- int i=0;
- for(i=0;i<90;i++)
- {
-
- //vTaskDelay(1000);
- if(Is_blink==1)
- {
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_3, 0);//
-
- timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_0, 0);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, 0);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, 0);//
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, 0);
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_0, 0);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_1, 0);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_2, 0);
- //delay_led_sec(1);
- vTaskDelay(1000);
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_3, 650);//
-
- timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_0, 650);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, 650);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, 650);//
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, 650);
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_0, 650);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_1, 650);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_2, 650);
-
-
- /*timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_3, 650);//
-
- timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_0, 650);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, 650);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, 650);//
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, 650);
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_0, 650);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_1, 650);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_2, 650);*/
- //delay_led_sec(1);
- vTaskDelay(1000);
-
- //timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, 0);
-
-
- }
- else
- {
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_3, 0);//
-
- timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_0, 0);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, 0);
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, 0);//
-
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, 0);
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_0, 0);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_1, 0);//
-
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_2, 0);
-
-
- // if(led_open==1)
- // dis_page_param.face_plate_param.Led_Brightness |= 0x0100;
- break;
- }
-
-
- }
- }
- void Press_Key_Set(u8 key)
- {
- u16 light = 0;
- if(led_struct.led_pwm_value <1) led_struct.led_pwm_value = 1;
- switch(led_struct.led_pwm_value)
- {
- case 1:light = 350;break;
- case 2:light = 450;break;
- case 3:light = 550;break;
- case 4:light = 650;break;
- case 5:light = 750;break;
- case 6:light = 850;break;
- default:break;
- }
- if(Is_blink==0)
- {
- switch(key)
- {
- case 6:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_3, light);//
- break;
- case 4:
- timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_0, light);
- break;
- case 3:
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, light);
- break;
- case 0:
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, light);//
- break;
- case 2:
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, light);
- break;
- case 7:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_0, light);//
- break;
- case 1:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_1, light);//
- break;
- case 5:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_2, light);
- break;
- default:break;
- }
- }
-
- }
- void Press_Key_up_Set(u8 key)
- {
- u16 light = 0;
- if(led_struct.led_low_off_flag == 1)
- {
- light = 0;
- }
- else if(led_struct.led_low_off_flag == 0)
- {
- light = 100;
- }
- if(Is_blink==0)
- {
- switch(key)
- {
- case 6:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_3, light);//
- break;
- case 4:
- timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_0, light);
- break;
- case 3:
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, light);
- break;
- case 0:
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, light);//
- break;
- case 2:
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, light);
- break;
- case 7:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_0, light);//
- break;
- case 1:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_1, light);//
- break;
- case 5:
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_2, light);
- break;
- default:break;
- }
- }
- }
- void Press_Key_Lum(void)
- {
- u8 i;
- uint8_t temp = 0;
- temp = KEY_GET;
- for(i=0; i<8; i++)
- {
- if((~temp&0x01<<i) != 0)
- Press_Key_Set(i+1);
- }
- }
- void Set_led_lum(u16 lum)
- {
- /*TIM_SetCompare4(TIM8,lum);//key1
- TIM_SetCompare1(TIM1,lum);//key2
- TIM_SetCompare2(TIM3,lum);//key3
- TIM_SetCompare3(TIM3,lum);//key4
- TIM_SetCompare4(TIM3,lum);//key5
- TIM_SetCompare1(TIM8,lum);//key6
- TIM_SetCompare2(TIM8,lum);//key7
- TIM_SetCompare3(TIM8,lum);//key8*/
- if(Is_blink==0)
- {
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_3, lum);
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_2, lum);
- timer_channel_output_pulse_value_config(TIMER0, TIMER_CH_0, lum);
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_1, lum);
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_1, lum);
- timer_channel_output_pulse_value_config(TIMER7, TIMER_CH_0, lum);
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_2, lum);
- timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_3, lum);
- }
-
- }
|