文件名称:用stm32驱动TFT
文件大小:21KB
文件格式:UVPROJX
更新时间:2022-05-03 12:48:39
stm32
#include "system.h" #include "SysTick.h" #include "led.h" #include "usart.h" #include "tftlcd.h" #include "dht11.h" #include "ds18b20.h" u8 temp; u8 humi; u8 temp_buf[3],humi_buf[3]; void data_pros() //Êý¾Ý´¦Àíº¯Êý { DHT11_Read_Data(&temp;,&humi;); temp_buf[0]=temp/10+0x30; temp_buf[1]=temp+0x30; temp_buf[2]='\0'; humi_buf[0]=humi/10+0x30; humi_buf[1]=humi+0x30; humi_buf[2]='\0'; } int main() { u8 i=0; u8 temper; SysTick_Init(168); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //ÖжÏÓÅÏȼ¶·Ö×é ·Ö2×é LED_Init(); USART1_Init(9600); TFTLCD_Init(); //LCD³õʼ»¯ FRONT_COLOR=BLACK; LCD_ShowString(10,10,tftlcd_data.width,tftlcd_data.height,16,"PRECHIN STM32F4"); LCD_ShowString(10,30,tftlcd_data.width,tftlcd_data.height,16,"www.prechin.net"); LCD_ShowString(10,50,tftlcd_data.width,tftlcd_data.height,16,"DHT11 Test"); LCD_ShowString(10,100,tftlcd_data.width,tftlcd_data.height,16,"Temp: C"); LCD_ShowString(10,130,tftlcd_data.width,tftlcd_data.height,16,"Humi: %RH"); FRONT_COLOR=RED; while(DHT11_Init()) //¼ì²âDS18B20ÊÇ·ñ´¿ÔÚ { LCD_ShowString(130,50,tftlcd_data.width,tftlcd_data.height,16,"Error "); delay_ms(500); } LCD_ShowString(130,50,tftlcd_data.width,tftlcd_data.height,16,"Success"); while(1) { i++; if(iP==0) { temper=DS18B20_GetTemperture(); led1=!led1; data_pros(); //¶ÁÈ¡Ò»´ÎDHT11Êý¾Ý×îÉÙÒª´óÓÚ100ms } LCD_ShowString(55,100,tftlcd_data.width,tftlcd_data.height,16,temp_buf); LCD_ShowString(55,130,tftlcd_data.width,tftlcd_data.height,16,humi_buf); LCD_ShowNum(55,160,temper,8,12); delay_ms(10); } }