这段代码的这几个按键具体用了会怎么样
while(1)
{
flag=0;
flag5=1;
flag2_1=0;
num=0;
setlong=0;
setang=0;
setR=0;
resetmot();
Write_LCD_Command(0x01); //ÇåÆÁ
delay_ms(2);
Write_LCD_Command(0x30); //±ØÐëÔٴδò¿ª»ù±¾Ö¸ÁÒòΪ»æͼ¿ªÁËÀ©³äÖ¸Áî
Display_LCD_String(0 , " »ù±¾²¿·Ö ",
time12864);
Display_LCD_String(1 , " ģʽһ ",time12864);
Display_LCD_String(2, " ģʽ¶þ ",time12864);
Display_LCD_String(3, " ģʽÈý ",time12864);
while(Key_Scan(GPIOB,GPIO_Pin_1) !=0)
{
if(Key_Scan(GPIOB,GPIO_Pin_12) == 0)
{
if(num<7)
num++;
else
num=7;
}
if(Key_Scan(GPIOB,GPIO_Pin_13) == 0)
{
if(num>0)
num--;
else
num=1;
}
switch(num)
{
case 0:break;
case 1: Display_LCD_String(0 , " »ù±¾²¿·Ö ",time12864);
Display_LCD_String(1, "ģʽһ ",time12864);
Display_LCD_String(2, " ģʽ¶þ ",time12864);
Display_LCD_String(3, " ģʽÈý ",time12864); break;
case 2: Display_LCD_String(0 , " »ù±¾²¿·Ö ",time12864);
Display_LCD_String(1 ," ģʽһ ",time12864);
Display_LCD_String(2, "ģʽ¶þ ",time12864);
Display_LCD_String(3, " ģʽÈý ",time12864); break;
case 3: Display_LCD_String(0 , " »ù±¾²¿·Ö ",time12864);
Display_LCD_String(0 , " »ù±¾²¿·Ö ",time12864);
Display_LCD_String(1 ," ģʽһ ",time12864);
Display_LCD_String(2, " ģʽ¶þ ",time12864);
Display_LCD_String(3, "ģʽÈý ",time12864); break;
case 4: Display_LCD_String(0 , " »ù±¾²¿·Ö ",time12864);
Display_LCD_String(1 , " ģʽ¶þ ",time12864);
Display_LCD_String(2, " ģʽÈý ",time12864);
Display_LCD_String(3, "ģʽËÄ ",time12864); break;
case 5: Display_LCD_String(0 , " ·¢»Ó²¿·Ö ",time12864);
Display_LCD_String(1 , "ģʽһ ",time12864);
Display_LCD_String(2, " ģʽ¶þ ",time12864);
Display_LCD_String(3, " ģʽÈý ",time12864); break;
case 6: Display_LCD_String(0 , " ·¢»Ó²¿·Ö ",time12864);
Display_LCD_String(1 , " ģʽһ ",time12864);
Display_LCD_String(2, "ģʽ¶þ ",time12864);
Display_LCD_String(3, " ģʽÈý ",time12864); break;
case 7: Display_LCD_String(0 , " ·¢»Ó²¿·Ö ",time12864);
Display_LCD_String(1 , " ģʽһ ",time12864);
Display_LCD_String(2, " ģʽ¶þ ",time12864);
Display_LCD_String(3, "ģʽÈý ",time12864); break;
}
}
while(Key_Scan(GPIOA,GPIO_Pin_4) != 0)
{
switch(num)
{
case 0:break;
case 1:
Display_LCD_String(0 , " ģʽһ²ÎÊý ",time12864);
Display_LCD_String(1, "ÎÞ²ÎÊýÉèÖà ",time12864);
Display_LCD_String(2, " ",time12864);
Display_LCD_String(3, " ",time12864); break;
case 2:
if(Key_Scan(GPIOB,GPIO_Pin_12) == 0)
{
setlong+=5;
}
if(Key_Scan(GPIOB,GPIO_Pin_13) == 0)
{
if(setlong>0)
setlong-=5;
else
setlong=0;
}
Table2[12]=shuzi[setlong/10];
Table2[13]=shuzi[setlong%10];
Display_LCD_String(0 , " ģʽ¶þ²ÎÊý ",time12864);
Display_LCD_String(2,Table2,time12864);
Display_LCD_String(3, " ",time12864);
Display_LCD_String(1, " ",time12864); break;
case 3: if(Key_Scan(GPIOB,GPIO_Pin_12) == 0)
{
setang+=5;
}
if(Key_Scan(GPIOB,GPIO_Pin_13) == 0)
{
if(setang>0)
setang-=5;
else
setang=0;
}
Table3[10]=shuzi[(unsigned int)setang/100];
Table3[12]=shuzi[(unsigned int)setang%100/10];
Table3[13]=shuzi[(unsigned int)setang%10];
Display_LCD_String(0 , " ģʽÈý²ÎÊý ",time12864);
Display_LCD_String(2,Table3,time12864);
Display_LCD_String(3, " ",time12864);
Display_LCD_String(1, " ",time12864); break;
case 4: Display_LCD_String(0 , " ģʽËIJÎÊý ",time12864);
Display_LCD_String(1, "ÎÞ²ÎÊýÉèÖà ",time12864);
Display_LCD_String(2, " ",time12864);
Display_LCD_String(3, " ",time12864); break;
case 5: if(Key_Scan(GPIOB,GPIO_Pin_12) == 0)
{
setR+=5;
}
if(Key_Scan(GPIOB,GPIO_Pin_13) == 0)
{
if(setR>0)
setR-=5;
else
setR=0;
}
Table5[12]=shuzi[setR/10];
Table5[13]=shuzi[setR%10];
Display_LCD_String(0 , " ģʽÎå²ÎÊý ",time12864);
Display_LCD_String(2,Table5,time12864);
Display_LCD_String(3, " ",time12864);
Display_LCD_String(1, " ",time12864); break;
case 6: if(Key_Scan(GPIOB,GPIO_Pin_12) == 0)
{
setR+=5;
}
if(Key_Scan(GPIOB,GPIO_Pin_13) == 0)
{
if(setR>0)
setR-=5;
else
setR=0;
}
Table5[12]=shuzi[setR/10];
Table5[13]=shuzi[setR%10];
Display_LCD_String(0 , " ģʽÁù²ÎÊý ",time12864);
Display_LCD_String(2,Table5,time12864);
Display_LCD_String(3, " ",time12864);
Display_LCD_String(1, " ",time12864); break;
case 7:
flag7=1;
Display_LCD_String(0 , " ģʽÈý²ÎÊý ",time12864);
Display_LCD_String(1, " ºº×ÖÊéд ",time12864);
Display_LCD_String(2, " ",time12864);
Display_LCD_String(3, " ",time12864); break;
}
}
while(Key_Scan(GPIOB,GPIO_Pin_0) != 0)
{
switch(num)
{
case 0: break;
case 1: mode1();break;
case 2: mode2();break;
case 3: mode3();break;
case 4:flag=4;break;
case 5: mode5();break;
case 6: mode5();break;
case 7:mode7();break;
}
}
}
}
一周热门 更多>