void led_breath_g(void)
{
gCount_20us++;
if (gCount_20us >= CONST_PWM_TIME) {
gCount_20us = 0;
if (gBreathFlag == 0) {
gPwmCnt++;
if (gPwmCnt == CONST_PWM_TIME) {
gPwmCnt = 255;
gBreathFlag = 1;
}
}
else {
gPwmCnt--;
if (gPwmCnt == CONST_PWM_START_DUTY) {
gBreathFlag = 0;
gCount = 1;
}
}
}
if (gCount_20us >= gPwmCnt) {
G_LED_OFF();
R_LED_OFF();
B_LED_OFF();
} else {
G_LED_ON();
R_LED_OFF();
B_LED_OFF();
}
}
上面的是很久以前写的一个共阳RGB的一种颜色的呼吸灯,你可以参考一下 |