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

📄 measure.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	
	DestroyWindow( mainwin );
}

void SetParameter( void )
{
	MSG 	msg;
 	U32		mainwin;
 	U8		quit=0;
	U32		st_promt[4];
	S8		*prompt[4] = { "图形参数", "记录频率", "连续记录时间", "新旧地类" };
	U32		bt_ok, bt_cancel;
	U32		lb_promt[5];
	U8		i;
	U16		st_y;
	PARAMETER	para;

	struct LBOX_ITEM	*lb_item[4] =
	{
		graph_par,
		gap_par,
		seq_par,
		type_par
	};


	const U16	title_x = 1, title_y = 1;
	const U16	title_w = PHY_LCD_W -2, title_h = 30;
	const U16	bt_w = 40, bt_h = 20, bt_y = PHY_LCD_H - bt_h -5;
	const U16	st_w = 72, st_h = 20, st_x = 5;
	const U16	lb_w = 80, lb_h = 20, lb_x = PHY_LCD_W - lb_w -5;

 	mainwin = CreateWindow(	WNDCLASS_WIN,
							"代码设置",
							WS_OVERLAPPEDWINDOW,
							0,0,
							PHY_LCD_W,PHY_LCD_H,
							0,
							0,
							NULL);
	
	
	bt_ok = CreateWindow(WNDCLASS_BUTTON, "确认", WS_CHILD|BS_REGULAR, 27,bt_y,bt_w,bt_h,mainwin,0,NULL);
	bt_cancel = CreateWindow(WNDCLASS_BUTTON, "取消", WS_CHILD|BS_REGULAR, 93,bt_y,bt_w,bt_h,mainwin,0,NULL);
	
	memset( &para, 0, sizeof(PARAMETER) );

	st_y = 35;
	for( i = 0; i < 4; i++ )
	{
		st_promt[i] = CreateWindow(WNDCLASS_STATIC, prompt[i], WS_CHILD|SS_TEXT, st_x,st_y,st_w,st_h,mainwin,0,NULL);
		lb_promt[i] = CreateWindow(WNDCLASS_LIST, prompt[i], WS_CHILD, lb_x,st_y,lb_w,lb_h,mainwin,0,(struct LBOX_ITEM	*)lb_item[i]);
		st_y += 35;
	}

	SelectListBox( lb_promt[3], ParSelect.terrain );
	
	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_ok )
				{
					// 确认。
					quit = 1;
//					WriteRecord( &para, Parameter, sizeof(PARAMETER) );
//					WriteRecord( &para, (BYTE *)FileCurrentAddress, sizeof(PARAMETER) );
//					FileCurrentAddress += sizeof(PARAMETER);
				}
				else if( msg.lparam == bt_cancel )
				{
					// 取消
					quit = 1;
				}
				break;
			case WM_LISTBOX:
				if( msg.lparam == lb_promt[0] )	// 图形参数
					para.zoom = msg.wparam;
				else if( msg.lparam == lb_promt[1] )	// 记录频率
					para.frequence = msg.wparam;
				else if( msg.lparam == lb_promt[2] )	// 连续记录时间
					para.continuance = msg.wparam;
				else if( msg.lparam == lb_promt[3] )	// 土地类型
				{
					ParSelect.terrain = (U8)msg.wparam;
					para.terrain_type = msg.wparam;
					break;
				}
				break;
			case WM_QUIT:
				quit = 1;
				break;
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	
	DestroyWindow( mainwin );

	return;
}

void ChangeSurvey( void )
{
	MSG 	msg;
 	U32		mainwin;
	U32		hGC;
 	U8		quit=0;
//	U32		bt_save;
	U32		bt_new, bt_open, bt_back;
	U16		caption_x, caption_y;
	S8		*caption = "调查之星V2.0数据采集系统";

	const U16	title_x = 1, title_y = 1;
	const U16	title_w = PHY_LCD_W -2, title_h = 30;
	const U16	bt_w = 80, bt_h = 20, bt_x = 40;

 	mainwin = CreateWindow(	WNDCLASS_WIN,
							NULL,
							WS_BORDER,
							0,0,
							PHY_LCD_W,PHY_LCD_H,
							0,
							0,
							NULL);
	
	
	bt_new = CreateWindow(WNDCLASS_BUTTON, "新建", WS_CHILD|BS_REGULAR, bt_x,80,bt_w,bt_h,mainwin,0,NULL);
	bt_open = CreateWindow(WNDCLASS_BUTTON, "打开", WS_CHILD|BS_REGULAR, bt_x,100,bt_w,bt_h,mainwin,0,NULL);
//	bt_save = CreateWindow(WNDCLASS_BUTTON, "保存", WS_CHILD|BS_REGULAR, bt_x,120,bt_w,bt_h,mainwin,0,NULL);
	bt_back = CreateWindow(WNDCLASS_BUTTON, "返回", WS_CHILD|BS_REGULAR, bt_x,120,bt_w,bt_h,mainwin,0,NULL);

	hGC = GetGC();
	
	caption_x = AlignString( caption, 1, title_w, GPC_ALIGN_CENTER );
	caption_y = title_y + ( title_h - CHINESE_CHAR_HEIGHT )/2;
	ClearRec( hGC, GPC_GREEN, title_x, title_y, title_w, title_h, GPC_REPLACE_STYLE );
	TextOut( hGC, caption, caption_x, caption_y, NULL, GPC_BLACK, GPC_REPLACE_STYLE );

	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_back )
				{
					quit = 1;
					// 退出处理
					
				}
				else if( msg.lparam == bt_new )
				{
					// 新建文件
					Survey();
				}
				else if( msg.lparam == bt_open )
				{
					// 打开文件
					Survey();
				}
//				else if( msg.lparam == bt_save )
//				{
//					// 保存文件
//				}
				break;
			case WM_REPAINT:
				ClearRec( hGC, GPC_GREEN, title_x, title_y, title_w, title_h, GPC_REPLACE_STYLE );
				TextOut( hGC, caption, caption_x, caption_y, NULL, GPC_BLACK, GPC_REPLACE_STYLE );
				break;
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	
	DestroyWindow( mainwin );
}

void Survey( void )
{
	MSG 	msg;
 	U32		mainwin;
	U32		hGC;
 	U8		quit=0;
	U32		bt_propert, bt_mode, bt_survey, bt_save;
//	U32		bt_rcv_data;
	U32		bt_zoom_in, bt_zoom_out, bt_move, bt_hide, bt_back;
	U32		st_prompt1, st_prompt2, st_prompt3;
	U32		st_pdop, st_sat_num, st_time;
//	U32		map_area;
	U32		area[4];
	U32		hbmp;
//	U32		vsb, hsb;
	U16		caption_x, caption_y;
	S8		*caption = "变更调查";
	S8		*waiting_caption = "Now is loading the background map, please wait.";
	U8		meas_mode = 0;	// 连续测量模式
	U8		disp_mode = 0;	// 底图显示模式
	U8		zoom_state = ZOOM_ZERO;	 //缩放状态
	U8		state = STATE_STOP, oldstate;
	RECT	orireg, reginfo;
	DWORD	i, j;
	DWORD	xpos, ypos;
	int		read_length = 0, offset = 0, mesflag = 0, relat_flag = 0, rest_flag = NOREST;
	int		buffer[BUF_LEN];
	double	pdop = 0, hdop, vdop;
	BYTE	star_num = 0, hour = 0, minute = 0, second = 0;
	char	charpdop[53];// = (char *)Lmalloc( 53 );
	char	charstar_num[16];// = (char *)Lmalloc( 16 );
	char	chartime[5];// = (char *)Lmalloc( 5 );
//	DWORD	latitude, longitude;
	double	latitude = 0, longitude = 0;
	POINT		relat_point;//保存相连成线的两点信息
	POINT_INFO	*point_info = NULL;//总共可以保存POINT_NUM_MAX个点的信息
	U32			*point_area = NULL;
	POINT_FILE	*point_file = NULL;
	int			point_num = 0;//, area_num;
	RECT		two_line;
	BYTE		test1[] = { 00, 00, 00, 0xf0, 0x3f };//for test
	BYTE		test2[] = { 0x3f, 0xf0, 00, 00, 00 };//for test
//	CMC_MESSAGE		cmc_message;
//	MESSAGE_20	mes20;
	PMSG		pmsg = NULL;
	BYTE		mes20_num = 0;//两次处理数据之间读的20号电文的数目
	ID			tskID;
	BYTE		first_message = 1;
//	ROOT_DIR	rootdir;

	const U16	title_x = 1, title_y = 1;
	const U16	title_w = PHY_LCD_W -2, title_h = 16;
	const U16	bt_w = 40, bt_h = 20, bt_w2 = 26;
	const U16	bt_y2 = PHY_LCD_H - bt_h - 1, bt_y1 = bt_y2 - bt_h;
	const U16	st_h = 16, st_y1 = title_h + 1, st_y2 = st_y1 + st_h;
	const U16	map_x = 1, map_y = st_y2 + st_h;
//	const U16	sb_w = 20;
/*	RECT	regs[4] = {
		{ map_x, map_y, map_x + 78, map_y + 73 },
		{ map_x + 78, map_y, map_x + 156, map_y + 73 },
		{ map_x, map_y + 74, map_x + 79, map_y + 146 },
		{ map_x + 78, map_y + 74, map_x + 156, map_y + 146 },
	};
*/
	RECT	regs[4] = {
		{ 1, 49, 79, 122 },
		{ 80, 49, 157, 122 },
		{ 1, 123, 79, 195 },
		{ 80, 123, 157, 195 },
	};

	orireg.left = 0;
	orireg.top = 0;
	orireg.right = 156;
	orireg.bottom = 148;

	point_info = (POINT_INFO *)Lmalloc( POINT_NUM_MAX * sizeof(POINT_INFO) );
	point_area = (U32 *)Lmalloc( POINT_NUM_MAX * 4 );
	point_file = (POINT_FILE *)Lmalloc( POINT_NUM_MAX * sizeof(POINT_FILE) );
	pmsg = (PMSG)Lmalloc(sizeof(MSG));
	if ( point_info == NULL || point_area == NULL || point_file == NULL || pmsg == NULL )
		goto ERROR_HANDLE;

//	memcpy ( &reginfo, &orireg, sizeof(RECT) );
	memset( buffer, 0, BUF_LEN );
	memset( &mes20, 0, sizeof(MESSAGE_20) );
//	memset( &cmc_message, 0, sizeof(CMC_MESSAGE) );
	memset( &relat_point, 0, 1 );
	memset( point_info, 0, POINT_NUM_MAX * sizeof(POINT_INFO) );
	memset( charpdop, 0, 4 * sizeof(U32) );
	memset( charstar_num, 0, 2 * sizeof(U32) );
	memset( chartime, 0, 5 * sizeof(BYTE) );
	
	Double2Char( pdop, charpdop );
	Int2Char( star_num, charstar_num );
	Unite2Char( hour, minute, chartime );

	mainwin = CreateWindow(	WNDCLASS_WIN,
							NULL,
							WS_BORDER,
							0,0,
							PHY_LCD_W,PHY_LCD_H,
							0,
							0,
							NULL);
	
	bt_propert = CreateWindow(WNDCLASS_BUTTON, "属性", WS_CHILD|BS_TOOLBAR, 0,bt_y1, bt_w, bt_h,mainwin,0,NULL);
	bt_mode = CreateWindow(WNDCLASS_BUTTON, "连续", WS_CHILD|BS_REGULAR, 40, bt_y1, bt_w, bt_h,mainwin,0,NULL);
	bt_survey = CreateWindow(WNDCLASS_BUTTON, "测量", WS_CHILD|BS_REGULAR, 80, bt_y1, bt_w, bt_h,mainwin,0,NULL);
	bt_save = CreateWindow(WNDCLASS_BUTTON, "保存", WS_CHILD|BS_REGULAR, 120,bt_y1, bt_w, bt_h,mainwin,0,NULL);
//	bt_rcv_data = CreateWindow(WNDCLASS_BUTTON, "接收", WS_CHILD|BS_REGULAR, 0,bt_y2, bt_w, bt_h,mainwin,0,NULL);
	bt_zoom_in = CreateWindow(WNDCLASS_BUTTON, "+", WS_CHILD|BS_REGULAR, 0,bt_y2, bt_w2, bt_h,mainwin,0,NULL);
	bt_zoom_out = CreateWindow(WNDCLASS_BUTTON, "-", WS_CHILD|BS_REGULAR, 27, bt_y2, bt_w2, bt_h,mainwin,0,NULL);
	bt_move = CreateWindow(WNDCLASS_BUTTON, "移", WS_CHILD|BS_TOOLBAR, 54, bt_y2, bt_w2, bt_h,mainwin,0,NULL);
	bt_hide = CreateWindow(WNDCLASS_BUTTON, "隐藏", WS_CHILD|BS_REGULAR, 80, bt_y2, bt_w, bt_h,mainwin,0,NULL);
	bt_back = CreateWindow(WNDCLASS_BUTTON, "返回", WS_CHILD|BS_REGULAR, 120,bt_y2, bt_w, bt_h,mainwin,0,NULL);

	st_prompt1 = CreateWindow(WNDCLASS_STATIC, "PDOP:", WS_CHILD|SS_TEXT, 5, st_y1, 36, st_h,mainwin,0,NULL);
	st_prompt2 = CreateWindow(WNDCLASS_STATIC, "卫星数:", WS_CHILD|SS_TEXT, 90, st_y1, 48, st_h,mainwin,0,NULL);
	st_prompt3 = CreateWindow(WNDCLASS_STATIC, "跟踪时间:", WS_CHILD|SS_TEXT, 5,st_y2, 60, st_h,mainwin,0,NULL);
	st_pdop = CreateWindow(WNDCLASS_STATIC, charpdop, WS_CHILD|SS_TEXT, 41, st_y1, 36, st_h,mainwin,0,NULL);
	st_sat_num = CreateWindow(WNDCLASS_STATIC, charstar_num, WS_CHILD|SS_TEXT, 138, st_y1, 16, st_h,mainwin,0,NULL);
	st_time = CreateWindow(WNDCLASS_STATIC, chartime, WS_CHILD|SS_TEXT, 65,st_y2, 36, st_h,mainwin,0,NULL);

//	map_area = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_PEN_UP_CMD, 1, 50, PHY_LCD_W-2, 150, mainwin, 0, NULL);

//	vsb = CreateWindow(WNDCLASS_SCROLL, "VertScroll", WS_CHILD|SBS_VERT, (U16)(PHY_LCD_W-sb_w-1),(U16)(st_y2+st_h),sb_w,130,mainwin,MAKELONG(1,1), NULL);
//	hsb = CreateWindow(WNDCLASS_SCROLL, "HorzScroll", WS_CHILD|SBS_HORZ, 1,(U16)(PHY_LCD_H-sb_w-2*bt_h-1),138,sb_w,mainwin,MAKELONG(1,1), NULL);
	
	hGC = GetGC();

	caption_x = AlignString( caption, 1, title_w, GPC_ALIGN_CENTER );
	caption_y = title_y + ( title_h - CHINESE_CHAR_HEIGHT )/2;
	ClearRec( hGC, GPC_GREEN, title_x, title_y, title_w, title_h, GPC_REPLACE_STYLE );
	TextOut( hGC, caption, caption_x, caption_y, NULL, GPC_BLACK, GPC_REPLACE_STYLE );

//	DrawHorz( hGC, GPC_BLACK, 1, 195, 155, GPC_SOLID_LINE, GPC_REPLACE_STYLE );//for test
	SysDrawText( hGC, GPC_BLACK, 35, 80, 120, 150, waiting_caption, GPC_REPLACE_STYLE );
	hGC = GetGC();
//	hbmp = LoadBitmap( map_bkg002 );
//	DisplayBMP( hGC, map_x, map_y, hbmp );
	hbmp = LoadBitmap( seu_map1,NULL );
	SysDspCutBMP( hGC, map_x, map_y, hbmp, &orireg, 1 );

//	ActiveAreaEnable( &map_area,INPUT_AREA, CONTINUOUS_MODE, 1, 50, PHY_LCD_W-2, 150, NULL );
	for ( i = 0; i < 4; i++ )
	{
		ActiveAreaEnable( &area[i],INPUT_AREA, CONTINUOUS_MODE, regs[i].left, 
							regs[i].top, regs[i].right, regs[i].bottom, NULL );
		
		ActiveAreaSuspend( area[i], AREA_SUSPEND );
	}

	//启动读串口
	get_tid( &tskID );
	pmsg->lparam = tskID;
	pmsg->wparam = SM_START;
	SysSendMessage( MESSAGE_ID, pmsg );

	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_back )
				{
					// 返回。写目录
					quit = 1;
//					memcpy( &rootdir, area, 10 * sizeof(ROOT_DIR) );
//					if ( FileCurrentAddress < FLASH_LENGTH )//一个flash区没有写满

//					WriteRecord( area, FILE_START_ADDRESS, FLASH_LENGTH );//把文件和目录都写入flash
				}
				else if( msg.lparam == bt_zoom_in )
				{
					// 放大
					if( zoom_state == ZOOM_IN )
						zoom_state = ZOOM_ZERO;
					else
						zoom_state = ZOOM_IN;

					//Enable响应区
					for ( i = 0; i < 4; i++ )
					{
						ActiveAreaSuspend( area[i], AREA_REENABLE );
					}

					DrawHorz( hGC, GPC_BLACK, map_x, map_y + 73, 156, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
					DrawVert( hGC, GPC_BLACK, map_x + 78, map_y, 146, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
				}
				else if( msg.lparam == bt_zoom_out )
				{
					// 缩小
					zoom_state = ZOOM_OUT;

					//Disable响应区
					for ( i = 0; i < 4; i++ )
					{
						ActiveAreaSuspend( area[i], AREA_SUSPEND );
					}

					SysDspCutBMP( hGC, map_x, map_y, hbmp, &orireg, 1 );
					//重新画点
					for ( i = 0; i < point_num; i++ )
					{
						for ( j = 0; j < RELAT_POINT_NUM_MAX; j++ )
						{
							if ( point_info[i].relat[j].relat_flag == BEUSED )
							{
								if ( point_info[i].point.x >= orireg.left &&
									 point_info[i].point.y >= orireg.top && 
									 point_info[i].relat[j].relat_point.x >= orireg.left &&
									 point_info[i].relat[j].relat_point.y >= orireg.top )
								{
									DrawLine( hGC, GPC_BLACK, 
											  point_info[i].point.x - orireg.left + map_x - 2,

⌨️ 快捷键说明

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