帮忙看下程序,这个是按键程序,嵌套有没问题

2019-03-24 19:09发布

 switch(key())
         {
                     case 0x06:flag++;if(flag==1){write_12864com(0x0f);write_12864com(0x90);}if(flag==2){write_12864com(0X90+5);}
                                                 if(flag==3){write_12864com(0x88);}if(flag==4){write_12864com(0x88+5);}
                                                 if(flag==5){write_12864com(0x98);}if(flag==6){TR0=1;write_12864com(0x0c);flag=0;}break;
                    case 0x05:if(flag==1)            {
                                                                init();write_12864com(0x01);dispay1();//initt0();
                                                                switch(key())
                                                                       {
                                                                           case 0x03:{init();write_12864com(0x0f);initt0();} break;
                                                                       }
                                                                  }
         }uint8 key()
{
    uint8 huoqu;
    rd=0;
    P3|=0x07;    if((P3&0x07)==0x07){huoqu=0xff;return(huoqu);}
    delay(20);
    P3|=0x07;    if((P3&0x07)==0x07){huoqu=0xff;return(huoqu);}
     huoqu=P3&0x07;
    while((P3&0x07)!=0X07)
    {   
    }
    return huoqu;
}我想说switch里面不能嵌套switch吗?可以的话,为什么我按下0x03这个件不能实现呢 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
Li_Lei
1楼-- · 2019-03-25 03:11
你的key()函数两次调用返回的不是同一个值
ylf175300
2楼-- · 2019-03-25 03:58
那应该怎么解决啊,我真的束手无策了
Li_Lei
3楼-- · 2019-03-25 05:25
 精彩回答 2  元偷偷看……

一周热门 更多>