|
#include "delay.h"
#include "sys.h"
#include "oled.h"
#include "bmp.h"
#include "usart.h"
#include "dht11.h"
int main(void)
{
int n = 20;
u8 temperature;
u8 humidity;
delay_init();
OLED_Init();
uart_init(115200); //串口初始化,波特率115200
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
OLED_ColorTurn(0);//0正常显示,1 反色显示
OLED_DisplayTurn(0);//0正常显示 1 屏幕翻转显示
DectectDivce();
OLED_Clear();
OLED_Refresh();
LED_ON;
while(n--)
{
OLED_Refresh();
OLED_ShowString(14,20,"Device is OK",16);
}
OLED_Clear();
OLED_Refresh();
OLED_ShowString(0,16,"Temp: C",16);
OLED_ShowChinese(55,16,11,16);
OLED_ShowString(0,32,"Humi: %",16);
OLED_Refresh();
while(1)
{
OLED_Refresh();
delay_ms(10);
DHT11_Read_Data(&temperature,&humidity); //读取温湿度值'/
OLED_ShowNum(38,16,temperature,2,16);
OLED_ShowNum(38,32,humidity,2,16);
}
}
|
|