在写一个温度报警系统时,发现按键没有反应,功能库的key功能就是用的官网的,请帮小弟看看是什么原因 按键设置温度上下限代码段如下: int main(void) { u8 t = 0; u8 shuzu[20]; u8 keyvalue=0; u8 gaibianshui=0; short temperature; delay_init(); //延时函数初始化 uart_init(9600); //串口初始化为9600 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2 LED_Init(); //初始化与LED连接的硬件接口 TIM3_Int_Init(9999,7199);//10Khz的计数频率,计数到5000为500ms LCD_Init(); POINT_COLOR = RED; //设置字体为红色 LCD_ShowString(0, 50, 200, 16, 16, "STM32 test"); LCD_ShowString(0, 70, 200, 16, 16, "name: zhang qi qi "); //LCD_ShowString(0,90,200,16,16,"Max 32 C Min 26 C"); 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); while (DS18B20_Init()) //DS18B20初始化 { LCD_ShowString(0, 130, 200, 16, 16, "DS18B20 Error"); delay_ms(200); LCD_Fill(0, 130, 239, 130 + 16, WHITE); delay_ms(200); } POINT_COLOR = BLUE; //设置字体为蓝色 LCD_ShowString(0, 110, 260, 16, 16, "The temperature is: . C now "); LCD_ShowChar(0+25*8,110,',',16,0); LCD_ShowChar(0+29*8,110,'!',16,0); while (1) { POINT_COLOR = BLUE; //设置字体为蓝色 if (t % 10 == 0) //每100ms读取一次 { t = 0; temperature = DS18B20_Get_Temp(); if (temperature < 0) { LCD_ShowChar(0 + 40, 150, '-', 16, 0); //显示负号 temperature = -temperature; //转为正数 } else LCD_ShowChar(0 + 40, 150, ' ', 16, 0); //去掉负号 memset(shuzu, 0, 20); sprintf(shuzu, "The temperature is:%3d.%1dC", temperature / 10, temperature % 10); LCD_ShowString(0, 110, 200, 16, 16, shuzu); }
|