|
|
本帖最后由 kaikaiGeng 于 2020-7-7 11:25 編輯 char Buffer[20]; float temp; void UpdateUI() { //文本設(shè)置和顯示 定時(shí)20ms刷新一次 if(current_screen_id==7) { while(1) { i++; if(i%20==0) { GPIO_ResetBits(GPIOC,GPIO_Pin_4); } if(i%50==0) { temp=DS18B20_GetTemperture(); //DS18B20讀取的溫度保存在浮點(diǎn)型temp數(shù)據(jù)里 delay_ms(10); sprintf(Buffer,"%f", temp); //將Buffer組數(shù)據(jù)轉(zhuǎn)化為字符串 delay_ms(10); SetTextValue(0x07,0x03,(unsigned char*)Buffer); //通過函數(shù)SetTextValue()將字符串在屏幕指定位置顯示出來 GPIO_ResetBits(GPIOC,GPIO_Pin_5); } |
Powered by 單片機(jī)教程網(wǎng)