⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datapro.c

📁 51开发板的源程序
💻 C
字号:


#include "c51base.h"


static void OutPutInit()
{
	struct SlineTable *temp_ptr;
	struct Stimer *timer_ptr;
	temp_ptr = I2c_humtable;
	if(temp_ptr[0].control_mode == 0 || temp_ptr[0].out_state == 0)
		HUM_OUT = 1;
	else if(temp_ptr[0].control_mode == 2 || temp_ptr[0].out_state == 1)
		HUM_OUT = 0;

	timer_ptr = I2c_timertable;
	if(timer_ptr[0].out_state ==0)
		TIMER_OUT = 1;
	else if(timer_ptr[0].out_state ==1)
		TIMER_OUT = 0;
}



/*************************************************************
数据区数据检测是否合法性。
*************************************************************/
void I2CDataCheck()
{
	uchar temp;
	struct Scheck *check_ptr;
	struct SlineTable *temp_ptr;
	struct Stimer *timer_ptr;
	uchar *pw_ptr;

	check_ptr = I2c_mhumtable;
	if(check_ptr[0].enable1>1)
		check_ptr[0].enable1=0;
	if(check_ptr[0].enable2>1)
		check_ptr[0].enable2=0;
	if(check_ptr[0].enable3>1)
		check_ptr[0].enable3=0;
	if(check_ptr[0].value1>60)
		check_ptr[0].value1 = 30;
	if(check_ptr[0].value2>60)
		check_ptr[0].value2 = 30;
	if(check_ptr[0].value3>60 || check_ptr[0].value3<0)
		check_ptr[0].value3 = 30;
	temp = check_ptr[0].value3;
//printf("湿度%x %d,%d,%d,%d,%d,%d,%d\n",(int)check_ptr,(int)check_ptr[0].enable1,(int)check_ptr[0].enable2,(int)check_ptr[0].enable3,(int)check_ptr[0].value1,(int)check_ptr[0].value2,(int)check_ptr[0].value3,(int)check_ptr[0].value3);

	check_ptr = I2c_mtemptable;
	if(check_ptr[0].enable1>1)
		check_ptr[0].enable1=0;
	if(check_ptr[0].enable2>1)
		check_ptr[0].enable2=0;
	if(check_ptr[0].enable3>1)
		check_ptr[0].enable3=0;
	if(check_ptr[0].value1>30)
		check_ptr[0].value1 = 15;
	if(check_ptr[0].value2>30)
		check_ptr[0].value2 = 15;
	if(check_ptr[0].value3>30)
		check_ptr[0].value3 = 15;
	temp = check_ptr[0].value1;
//printf("温度%x %d,%d,%d,%d,%d,%d\n",(int)check_ptr,(int)check_ptr[0].enable1,(int)check_ptr[0].enable2,(int)check_ptr[0].enable3,(int)check_ptr[0].value1,(int)check_ptr[0].value2,(int)check_ptr[0].value3);


	check_ptr = I2c_yalitable;
	if(check_ptr[0].enable1>1)
		check_ptr[0].enable1=0;	
	if(check_ptr[0].value1>30)
		check_ptr[0].value1 = 15;
	temp = check_ptr[0].value1;

	temp_ptr = I2c_humtable;
	if(temp_ptr[0].top_line > 99)
		temp_ptr[0].top_line = 0xff;
	if(temp_ptr[0].down_line > 99)
		temp_ptr[0].down_line = 0xff;
	if(temp_ptr[0].control_mode >= 3)
		temp_ptr[0].control_mode =0;
	if(temp_ptr[0].out_state >1)
		temp_ptr[0].out_state = 0;
	temp = temp_ptr[0].top_line;

	timer_ptr = I2c_timertable;
	if(timer_ptr[0].enable !=0 && timer_ptr[0].enable !=1)
		timer_ptr[0].enable =0;
	if(timer_ptr[0].open_time >60 || timer_ptr[0].open_time <0)
		timer_ptr[0].open_time =0;
	if(timer_ptr[0].close_time >60 || timer_ptr[0].close_time <0)
		timer_ptr[0].close_time =0;
	if(timer_ptr[0].out_state !=0 && timer_ptr[0].out_state !=1)
		timer_ptr[0].out_state =0;
	temp = timer_ptr[0].out_state;

	pw_ptr = I2c_pw;
	if(pw_ptr[0]>'9' || pw_ptr[0]<'0')
		pw_ptr[0] ='0';
	if(pw_ptr[1]>'9' || pw_ptr[1]<'0')
		pw_ptr[1] ='0';
	if(pw_ptr[2]>'9' || pw_ptr[2]<'0')
		pw_ptr[2] ='0';
	if(pw_ptr[3]>'9' || pw_ptr[3]<'0')
		pw_ptr[3] ='0';

	OutPutInit();
}


void I2CDataInit()
{
	uchar temp;
	struct Scheck *check_ptr;
	struct SlineTable *temp_ptr;
	struct Stimer *timer_ptr;
WDTReset_SM89516();
	CLEAR_SCREEN();
	DisplayStr(0,1,"初始化Data...");
WDTReset_SM89516();
	WaitKey(30);
	LcdInit();
WDTReset_SM89516();
	check_ptr = I2c_mhumtable;
	check_ptr[0].enable1=0;
	check_ptr[0].enable2=0;
	check_ptr[0].enable3=0;
	check_ptr[0].value1 = 30;
	check_ptr[0].value2 = 30;
	check_ptr[0].value3 = 30;
	temp = check_ptr[0].value1;
WDTReset_SM89516();
	check_ptr = I2c_mtemptable;
	check_ptr[0].enable1=0;
	check_ptr[0].enable2=0;
	check_ptr[0].enable3=0;
	check_ptr[0].value1 = 15;
	check_ptr[0].value2 = 15;
	check_ptr[0].value3 = 15;
	temp = check_ptr[0].value1;

	check_ptr = I2c_yalitable;
	check_ptr[0].enable1=0;
	check_ptr[0].value1 = 15;
	temp = check_ptr[0].value1;

	temp_ptr = I2c_humtable;
	temp_ptr[0].top_line = 0xff;
	temp_ptr[0].down_line = 0xff;
	temp_ptr[0].control_mode =0;
	temp_ptr[0].out_state = 0;
	temp = temp_ptr[0].top_line;

	timer_ptr = I2c_timertable;
	timer_ptr[0].enable =0;
	timer_ptr[0].open_time =0;
	timer_ptr[0].close_time =0;
	timer_ptr[0].out_state =0;
	temp = timer_ptr[0].out_state;

WDTReset_SM89516();
	OutPutInit();
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -