我分辨率4095,频率1.5KHZ,低亮度还是抖,下面是我循环呼吸的代码,都这么用,应该不会是BUG吧。void fade(u8 speed)
{
static u8 sta=1;
static u32 r_temp=0,g_temp=0,b_temp=0,w_temp=0;
if(fade_speed_count>=speed)
{
fade_speed_count=0;
switch(sta)
{
case 1:
g_temp+=1;
if(g_temp>=4095)
{
g_temp=4095;
sta=2;
}
break;
case 2:
g_temp-=1;
b_temp+=1;
if(g_temp<=1)
{
g_temp=0;
b_temp=4095;
sta=3;
}
break;
case 3:
b_temp-=1;
w_temp+=1;
if(b_temp<=1)
{
b_temp=0;
w_temp=4095;
sta=4;
}
break;
case 4:
w_temp-=1;
g_temp+=1;
if(w_temp<=1)
{
w_temp=0;
g_temp=4095;
sta=2;
}
break;
}
}
r=r_temp;g=g_temp;b=b_temp;w=w_temp;
PWM_CMR_Set_fade(r,g,b,w);
}
|