##总程序
int main(void)
{
uint8_t red = 0,green = 0,bull = 0;
uint8_t value1 = 0,value2 = 0,value3 = 0;
uint8_t key = -1;//0表示选中颜色,1表示选中PWM
uint8_t i = 10;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6,ENABLE);
KEY_GPIO_Config();
delay_init();
OLED_Cofing();
caidan_display(00,00,00);
COLOR_TIMx_LED_Init();
while(1)
{
if(Key_Scan(KEY1_GPIO_PORT,KEY1_GPIO_PIN))//按下按键1,用于改变选中目标
{
OLED_Clear();
key++;
key = key % 3;
key_RGB_chang(key);
}
if(Key_Scan(KEY2_GPIO_PORT,KEY2_GPIO_PIN))//按下按键2,用于改变值
{
OLED_Clear();
if(key==0)
{
red = red + 25;
red = red % 250;
value1 = (++value1) %10;
}
else if(key==1)
{
green = green + 25;
green = green % 250;
value2 = (++value2) %10;
}
else if(key==2)
{
bull = bull + 25;
bull = bull % 250;
value3 = (++value3) %10;
}
//key_RGB_chang(key);
}
caidan_display(value1,value2,value3);
SetColorValue(red,green,bull);
OLED_Refresh();
}
}
|