1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include "led.h"
- #include "delay.h"
- #include "sys.h"
- #include "stm32f10x.h"
- #include "stdio.h"
- #include "usart.h"
- #include "adc.h"
- #include "oled.h"
- #include "ds18b20.h"
- #include "HX711.h"
- #define HwInput PBin(7) //红外传感器输入
- #define KEY1 PAin(0) // 手动控制加热
- #define JR_OUT_PIN PBout(12) //控制加热输出
- #define CS_OUT_PIN PBout(13) //控制出水 电磁阀
- void Hw_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //使能端口时钟
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; // 端口配置
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //上拉输入
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
- GPIO_Init(GPIOB, &GPIO_InitStructure); //根据设定参数初始化GPIOC13
- }
- //void TIM2_IRQHandler()
- //{
- // static u8 st;
- // st=TIM_GetFlagStatus(TIM2, TIM_IT_Update);
- // if(st!=0)
- // {
- // TIM_ClearFlag(TIM2, TIM_IT_Update);
- // }
- //}
- //测距
- int temp_val=0;
- u16 get_cnt=0;
- char showbuff[16]={0};
- int main(void)
- {
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
- delay_init(); //延时函数初始化
- LED_Init(); //初始化与LED连接的硬件接口
- uart_init(9600);
- // ADC1_Init();
- delay_ms(500);
- OLED_Init();
- OLED_Clear();
- OLED_ShowString(0,2,(u8*)"2322352",16); //显示
- DS18B20_Init();
- OLED_ShowText(0,0,"和你在一起好快乐",0);
- // sprintf(showbuff,"temp:%2d.%1d",temp_val/10,temp_val%10); //打印成字符串
- // OLED_ShowString(0,2,(u8*)showbuff,16); //显示
- buzz=1;
- while(1)
- {
-
- if(++get_cnt>100) //采集时间计数器
- {
- get_cnt=0;
- temp_val = DS18B20_Get_Temp();//采集温度值
- sprintf(showbuff,"temp:%2d.%1d",temp_val/10,temp_val%10); //打印成字符串
- OLED_ShowString(0,4,(u8*)showbuff,16); //显示
- }
-
- delay_ms(5);//延时
-
- }
- }
|