int main(void)
{
	start_configration();
	
	while(1)
	{
		DataProcessing();
		
		/*当有旋转开关改变时*/
		if(RotaryKeyChanged_flag == 1)
		{
			MeasureModeChange();//测量模式选择:DTA0660<->STM32
			
			DataProcessing();
			
			SoftKeyState_AllInit();//软按钮状态初始化
			Display_RotaryKeyChange();//旋转开关时状态字显示初始化
			
			RotaryKeyChanged_flag = 0;
		}
		/*当有软按钮改变时*/
		if(SoftKeyChanged_flag == 1)
		{
			SoftKeyStateChange();//软按键发生时,改变相应状态(及软按键6时测量功能的改变)
			
			DataProcessing();
			
			Display_SoftKeyChange();//软按键发生时,针对相应已改变的状态进行显示状态字
			SoftKeyChanged_flag = 0;
		}
		
		Display();//还没写,2014-12-15日
	}
}
Example #2
0
void main()
{
	DataEM_T DataEM;
	OutputData_T OutputData;
	

	InitEM();								//初始化所有模块
	
	InitSimulatTimerMs(0, compare, 3);		//开启主任务定时执行用的模拟定时器
	InitSimulatTimerMs(1, compare, 200);	//开启oled定时显示用的模拟定时器
	
	for(uint8_t i = 0; i < 6; i++)			//给AD参考值假定一个值,(如果不采集的话,此时需手动调节传感器)
	{
		DataEM.ResultAD[i].max = 3500;
		DataEM.ResultAD[i].min = 900;
	}
	
	while(1)
	{
		if(SimulatTimerMs_tcf(0) == 1)
		{
			DataCollection(&DataEM);
			OutputData = DataProcessing(DataEM);
			OutputControl(OutputData);
		}
		if(SimulatTimerMs_tcf(1) == 1)
		{
			DisplayOLED();
		}
	}
}
Example #3
0
void ServerProcedures::receiveFromClients()
{

	Packet packet;

	std::map<unsigned int, SOCKET>::iterator iter;

	for (iter = network->sessions.begin(); iter != network->sessions.end(); iter++)
	{
		int data_length = network->receiveData(iter->first, network_data);

		if (data_length <= 0)
		{
			//no data recieved
			continue;
		}

		int i = 0;
		while (i < (unsigned int)data_length)
		{
			packet.deserialize(&(network_data[i]));
			i += sizeof(Packet);

			switch (packet.packet_type) {

			case INIT_CONNECTION:
				sendInitPacket();
				break;

			case MESSAGE_EVENT:

				printf("server received message event packet from client: ");
				std::cout << packet.message;
				printf("\n");
				
				sendMessagePackets(packet.message,packet.client_id);
				break;

			case GAME_EVENT:
				DataProcessing(packet);
				break;

			default:
				printf("error in packet types\n");
				break;
			}
		}
	}
}
int main(void)
{
//	u8 t;
//	u8 len;	
//	u16 times=0;
//	float num;
	start_configration();
	
	//2016-07-25 增加内部校准  启动时的按键检测
	SoftKeyValue = OnceSoftKey();//无消抖的获取按键值  ScanKey();//
	if(SoftKeyValue==KEY_VALUE_5)//启动检测到func按键 置位校准标志位
	{
		SoftKeyValue = KEY_NULL;
		Is_Cal_Mode = 1;
		BUZZER_Open(0);delay_ms(1000);
		BUZZER_Open(0);delay_ms(1000);
		BUZZER_Open(0);delay_ms(1000);
		BUZZER_Open(0);delay_ms(1000);
	}
	
	//旋转开关位置预检测
	EXTI->IMR &= ~Keyboard_EXTI_Line;//屏蔽来自线上的中断请求,防止在定时器扫描矩阵键盘时进入此中断
	TIM_Cmd(TIM3, ENABLE);//打开定时器3,在定时器作用下开始扫描矩阵键盘
	
	//WriteEeprom();
	//Self_Calibration();//在电阻档自检线路和放大器

	
//	//液晶全亮
//	Send(SetAddr,0x3B,0x00,0x8B);//设置LCD地址
//	CheckReceive(SetAddr);//等待60ms,DTA从接收到发送完需要时间
//	for(t=0;t<8;t++)
//	{
//		Send(WriteFwd,0xFF,0xFF+WriteFwd);
//		CheckReceive(WriteFwd);
//	}
	
	while(1)
	{
		if(timer_1s_flag_for_Standby==1)//用于休眠计时
		{
			timer_1s_flag_for_Standby=0;
			count_for_Standby++;//休眠计时+1s;
			if(count_for_Standby==5400)//5min-300,10min-600,15min-900,20min-1200,25min-1500,30min-1800
			{
				lcd_clr();
				StandbyMode_Measure();//进入休眠
//				Power_Off_VDD();
			}
		}
		if((RotaryKeyChanged_flag == 1) || (SoftKeyChanged_flag == 1))//有按键
		{
			count_for_Standby=0;//休眠计时清零
			manipulate();
		}
		
		DataProcessing();//根据相应功能档配置DTA0660,并做当前档位的数据处理。  
		display();//液晶显示
		
		Communication_Service();//蓝牙串口服务函数
	}
	return 0;
}