2025-05-26 17:39:58 +08:00

109 lines
2.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "stm32f10x.h" // Device header
#include "Delay.h"
#include "OLED.h"
#include "mlx90614.h"
#include "buzzer.h"
#include "led.h"
#include "esp.h"
#include "String.h"
#include "key.h"
#define key1 GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_13)
#define key2 GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_14)
int main(void)
{
/*****************************
*操 作:函数初始化
*时 间2024-05-14
*Dragon-H
*****************************/
OLED_Init();//OLED屏初始化
OLED_ShowImage(47, 10, 32, 32,BYSJ);
OLED_ShowChinese(32, 44, "毕业设计");
OLED_Update();
SMBus_Init();//MLX90614红外测温初始化
buzzer_Init();//蜂鸣器初始化
LED_Init();//LED初始化
Esp_Init();//ESP-01S初始化
Key_Init();//按键初始化
/*****************************
*操 作:自定义变量
*时 间2024-05-14
*Dragon-H
*****************************/
double temperature=0.0;//温度
static float SET_temperature=37.0;//初始设置温度
/*****************************
*操 作Wifi参数初始化
*端口号2024
*I P: 192.168.4.1
*时 间2024-05-16
*Dragon-H
*****************************/
Esp_SetInstall();//ESP01s 初始化
OLED_Clear();
OLED_Update();
/*****************************
*操 作OLED初始化显示
*时 间2024-05-14
*Dragon-H
*****************************/
OLED_ShowImage(0, 0, 128, 64,Img);
OLED_ShowString(4,4, "Diploma project", OLED_8X16);
OLED_ShowChinese(2, 20, "当前温度");
OLED_ShowChinese(110, 20, "");
OLED_ShowChinese(2, 40, "报警温度");
OLED_ShowChinese(110, 40, "");
OLED_Update();
while (1){
Esp_Printf("AT+CIPSEND=0,18\r\n");//AT发送数据指令
Delay_ms(500);
temperature=SMBus_ReadTemp();//获取温度
OLED_ShowFloatNum(70, 20, temperature, 2, 1,OLED_8X16);
OLED_ShowNum(80, 40, SET_temperature, 2,OLED_8X16);
Esp_Printf("Temperature:%1.1f\r\n",temperature);//发送温度信息
if( temperature>=SET_temperature){
buzzer_on();
LEDGreen_OFF();
LEDRed_Flash();
}
if( temperature<SET_temperature){
buzzer_off();
LEDRed_OFF();
LEDGreen_ON();
}
//按键判断
if(key1==1){
Delay_ms(20);
while(key1==1);
SET_temperature++;
}else if(key2==1){
Delay_ms(20);
while(key2==1);
SET_temperature--;
}
Delay_ms(500);
OLED_Update();
}
}