呼吸灯LED线性化控制软件代码生成 PC

admin 27天前 87



uint8_t led_huxi_time_num=0;  //定时器10MS   累计加
uint8_t table_num=0;                //累计加 用来判断 数组
uint8_t led_huxi_run_step=0;        //判断 变亮 还是变暗
const u16 LED_Table[]={
1,2,2,2,3,4,5,6,7,9,
11,13,17,21,25,32,39,49,60,75,
93,115,143,178,221,274,340,421,523,649,
805,999};
//呼吸灯效果
void led_huxi_dispose(void)
{
        led_huxi_time_num+=1;
        
        if(led_huxi_time_num>=6)    //60MS 数组 加一次
        {
                led_huxi_time_num=0;
                switch(led_huxi_run_step)
                {
                        case 0:           //变亮
                                TIM4->CCR1 =LED_Table[table_num];
                                
                                table_num+=1;
                                
                                if(table_num>=32)
                                {
                                        //table_num=0;
                                        led_huxi_run_step=1;
                                }
                                
                        break;
                        case 1:          //变暗
                                table_num-=1;
                                TIM4->CCR1 =LED_Table[table_num];
                                
                                if(table_num<=0)
                                {
                                        table_num=0;
                                        led_huxi_run_step=0;
                                }
                        break;
                }//end switch(led_huxi_run_step)
        }        
}


链接: https://pan.baidu.com/s/1Jnxw-pFqLbrC-I13hWDtxA 提取码: rjvm

最新回复 [0]
返回