#include "PWM.h"
#include "LED.h"
volatile uint16_t PWM_Timing = 0;
volatile uint8_t PWM_Dutycycle = 100;
volatile uint8_t dutycycle = 0;
void Colour_RGBW(uint8_t RGBW, uint8_t Duty)
{
uint16_t DutyTiming = 0;
if (Duty > MaxDutycycle)
{
return;
}
if (0 == Duty)
{
LightStatus = OFF;
PWM1 = 0;
PWM2 = 0;
PWM3 = 0;
return;
}
else
{
LightStatus = ON;
}
if (PWM_Timing <= Duty)
{
switch (RGBW)
{
case 'R': PWM1 = 1; PWM2 = 0; PWM3 = 0; break;
case 'G': PWM1 = 0; PWM2 = 1; PWM3 = 0; break;
case 'B': PWM1 = 0; PWM2 = 0; PWM3 = 1; break;
case 'W': PWM1 = 1; PWM2 = 1; PWM3 = 1; break;
default:
break;
}
}
else
{
PWM1 = 0;
PWM2 = 0;
PWM3 = 0;
}
}
Keil代码下载:
Dimming.zip
(66.48 KB, 下载次数: 55)
|