在写一个温度报警系统时,发现按键没有反应,功能库的key功能就是用的官网的,请帮小弟看看是什么原因 按键设置温度上下限代码段如下: delay_ms(10); //判断温度 zanshi_low=temp_low*10; zanshi_hign=temp_high*10; if((temperature<zanshi_low)||(temperature>zanshi_hign)) { if(temperature<zanshi_low) { flag=1; printf("chaoxiaxian"); } if(temperature>zanshi_hign) { flag=2; printf("chaoshangxian"); } } else { flag=0; LED0=1; //正常情况灯不亮 LED1=1; } //获取温度时间控制t t++; //浏览开关 KEY_Init(); delay_ms(10); keyvalue=KEY_Scan(0); if(keyvalue!=0) { if(keyvalue==3) { gaibianshui=(gaibianshui+1)%3; } if(gaibianshui==1) //改变上限 { if(keyvalue==2) //key1按下 { temp_high++; memset(shuzu, 0, 20); sprintf(shuzu, "Max is %2d C,Min is %2d C", temp_high, temp_low); LCD_ShowString(0, 90, 200, 16, 16, shuzu); } if(keyvalue==1) //key0按下 { temp_high--; memset(shuzu, 0, 20); sprintf(shuzu, "Max is %2d C,Min is %2d C", temp_high, temp_low); LCD_ShowString(0, 90, 200, 16, 16, shuzu); } } if(gaibianshui==2) //改变上限 { if(keyvalue==2) //key1按下 { temp_low++; memset(shuzu, 0, 20); sprintf(shuzu, "Max is %2d C,Min is %2d C", temp_high, temp_low); LCD_ShowString(0, 90, 200, 16, 16, shuzu); } if(keyvalue==1) //key0按下 { temp_low--; memset(shuzu, 0, 20); sprintf(shuzu, "Max is %2d C,Min is %2d C", temp_high, temp_low); LCD_ShowString(0, 90, 200, 16, 16, shuzu); } } keyvalue=0; } } }
|