#include "config.h"
#include "bmp.h"
const u8 QueryMenu[][16] = {
	"1.Network Info  ",
	"2.MD Port Info  ",
	"3.LORA RSSI     ",
	"4.Veresion Check",
	"5.Test Info.    ",
	"1.Network Info  ",
	"2.MD Port Info  ",
	"3.LORA RSSI     ",
};
const u8 QueryNetworkInfo[][16] = {
	"  Network Info  ",
	"                ",
	"                ",
	"                ",
};
const u8 PrintInfo[][16] = {
	"Print [Gun:   ] ",
	"                ",
	"                ",
	"                ",
};
const u8 QueryMDPortInfo[][16] = {
	"   PORT         ",
	"                ",
	"                ",
	"                ",
};
const u8 QueryTestInfo[][16] = {
	"   PORT         ",
	"                ",
	"                ",
	"                ",
};
/*
	PosNormal,
  PosBlueSky,
	PosLY,
	PosJP,
	PosDart,
	PosYWY,
	PosRFID,
	PosYGao,
	PosHongYang,
	PosLanFeng,*/
const u8 QueryMDPortInfo_POSType[][16] = {
	"Empty",
	"BlueSky",
	"LY",
	"JP",
	"Dart",
	"YWY_Bluesky",
	"RFID",
	"YGao",
	"HYang",
	"SS-Lan",
	"BlueSkyPlus",
	"PLC",
	"Price"};
const u8 YWY_Type_Info[][16] = {
	"YWY_Bluesky",
	"Probe_KY",
	"YWY_Pressure",
};
const u8 QueryLORARSSI[][16] = {
	"   PORT         ",
	"                ",
	"                ",
	"                ",
};
const u8 QueryVeresion[][16] = {
	"    Veresion    ",
	"                ",
	"                ",
	"                ",
};
const u8 SetMenu[][16] = {
	"1.MDConnect Set ",
	"2.LORA Slave Set",
	"3.PortLog Output",
	"4.Connect Mode  ",
	"5.Network Set   ",
	"6.DataInit      ",
	"1.MDConnect Set ",
	"2.LORA Slave Set",
	"3.PortLog Output",
};
const u8 SetMDConnect[][16] = {
	" MDConnect Set  ",
	"                ",
	"                ",
	"                ",
};
const u8 SetLORASlave[][16] = {
	" LORA Slave Set ",
	"                ",
	"                ",
	"                ",
};
const u8 SetPortLogOutput[][16] = {
	" PortLog Output ",
	"                ",
	"                ",
	"                ",
};
const u8 SetConnectMode[][16] = {
	"  Connect Mode  ",
	"                ",
	"                ",
	"Press | to shift",
};
const u8 SetNetworkSet[][16] = {
	"   Network Set  ",
	"                ",
	"                ",
	"Press | to shift",
};
const u8 ConnectMode_Info[][16] = {
	"Now:Dial switch ",
	"Now:Station     ",
	"Now:Cloud       ",
	"Now:Test Cloud  ",
	"Now:Wifi Station",
};
const u8 Network_Type_Info[][16] = {
	"Now:Dial switch ",
	"Now:4G_GM5      ",
	"Now:4G_L510     ",
	"Now:WiFi        ",
	"Now:WAN         ",
};
const u8 SetDataInit[][16] = {
	"Initialize Data?",
	"                ",
	"                ",
	"'ENTER' to shift",
};
void Surface_Copy_16(const u8 *Buff, u8 StLine, u8 Num) // ת�Ƶ�����
{
	u8 i, j;
	for (j = 0; j < Num; j++)
	{
		for (i = 0; i < 16; i++)
			OLED_ShowChar(i * 8, j * 16, *(Buff + i + StLine * 16 + j * 16), 16, 1);
	}
}
void SurfaceJump(u8 Surface)
{
	TXHData.SurfaceNow = Surface;
	TXHData.DisplayOn = 1;
	//	TXHData.SurfaceNowLine = 0;
}
void Surface_Init(void)
{
	TXHData.KeyFindTimer.Init = 0;			  // �����ʼ����־
	TXHData.KeyFindTimer.Flag = 0;			  // �����ʱ��־
	TXHData.KeyFindTimer.ON_OFF = 1;		  // ��
	TXHData.KeyFindTimer.Cycle = 1;			  // ����Ϊѭ��ģʽ������ʱ
	TXHData.KeyFindTimer.TimerCountMax = 100; // ����0.1��
	TXHData.DisplayOn = 1;
	SurfaceJump(Surface_Wait);
}
u8 KeyNumBefore = 0;
u8 KeyNumconfirm_Flag = 0;
u8 KeyNum0 = 0;
u8 KeyNum1 = 0;
u8 KeyNum = 0;
void FindKey(void)
{
	if (TXHData.KeyFindTimer.Flag == 1)
	{
		TXHData.KeyFindTimer.Flag = 0;
		if (KeyNumconfirm_Flag == 0)
		{
			KeyNumconfirm_Flag = 1;
			KeyNum0 = ~((Key4 << 3) | (Key3 << 2) | (Key2 << 1) | Key1) & 0x0f;
		}
		else
		{
			KeyNumconfirm_Flag = 0;
			KeyNum1 = ~((Key4 << 3) | (Key3 << 2) | (Key2 << 1) | Key1) & 0x0f;
		}
		if (KeyNum0 == KeyNum1)
		{
			KeyNum = KeyNum0;
			if (KeyNum != KeyNumBefore)
			{
				TXHData.KeyNum = KeyNum;
				KeyNumBefore = KeyNum;
				if (KeyNum)
					TXHData.DisplayOn = 1;
			}
		}
	}
}
u8 GetKeyNum(void)
{
	u8 K = TXHData.KeyNum;
	TXHData.KeyNum = 0;
	return K;
}

void Sureface_Wait_TimeUpData(void)
{
	u8 X_Now = 4, Y_Now = 56;
	X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.CTIME.Hour), 0, 0, 8, 1);
	OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
	X_Now++;
	X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.CTIME.Min), 0, 0, 8, 1);
	OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
	X_Now++;
	X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.CTIME.Sec), 0, 0, 8, 1);
	OLED_ShowChar(6 * X_Now, Y_Now, ' ', 8, 1);
	X_Now++;
	X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.CTIME.Year), 0, 0, 8, 1);
	OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
	X_Now++;
	X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.CTIME.Month), 0, 0, 8, 1);
	OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
	X_Now++;
	X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.CTIME.Day), 0, 0, 8, 1);
}
void SurfaceTast(void)
{
	u16 i = 0, j = 0, X_Now = 0, Y_Now = 0, MD_Port = 0;
	u8 Buff[21];
	FindKey();
	if (TXHData.DisplayOn)
	{
		TXHData.DisplayOn = 0;
		OLED_Clear();
		switch (TXHData.SurfaceNow)
		{
		case Surface_FirmwareUpdate:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
			}
			break;
			case 0x02:
			{
			}
			break;
			case 0x04:
			{
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_Wait);
				TXHData.ROM_UpData_ProgressBar = 0;
			}
			break;
			}
			OLED_ShowString(0, 0, "FirmwareDownload", 21, 16, 1);
			if (TXHData.ROM_UpData_Port)
			{
				OLED_ShowString(0, 20, "Port:", 5, 8, 1);
				OLED_ShowNum(30, 20, TXHData.ROM_UpData_Port, 0, 0, 8, 1);
				OLED_ShowString(40, 20, TXHData.MD_Port_Data[TXHData.ROM_UpData_Port - 1].PortData.ROM_UpData_Version, 10, 8, 1);
			}
			if (TXHData.ROM_UpData_ProgressBar == 0xFF)
			{
				OLED_ShowString(20, 45, "Download Fail!", 21, 8, 1);
			}
			else
			{
				OLED_ProgressBar(10, 30, 100, 10, TXHData.ROM_UpData_ProgressBar, 1);
				i = OLED_ShowNum(50, 45, TXHData.ROM_UpData_ProgressBar, 0, 0, 8, 1);
				OLED_ShowChar(50 + i * 6, 45, '%', 8, 1);
				if (TXHData.ROM_UpData_ProgressBar == 100)
				{
					TXHData.ROM_UpData_ProgressBar = 0;
					SurfaceJump(Surface_Wait);
				}
			}
		}
		break;
		case Surface_OfflineRecordUpload: // ���߼�¼�ϴ�����
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
			}
			break;
			case 0x02:
			{
			}
			break;
			case 0x04:
			{
				SurfaceJump(Surface_SetMenu);
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_QueryMenu);
			}
			break;
			}
			if (TXHData.POS_Info.Link_Flag == 0)
				OLED_ShowString(0, 0, "No Signal", 21, 8, 1);
			else
			{
				switch (TXHData.POS_Info.ConnectType)
				{
				case POS_Connect_Typ_Station:
					OLED_ShowString(0, 0, "Type:Station", 21, 8, 1);
					break;
				case POS_Connect_Typ_Cloud:
					OLED_ShowString(0, 0, "Type:Cloud", 21, 8, 1);
					break;
				case POS_Connect_Typ_Cloud_Tast:
					OLED_ShowString(0, 0, "Type:Cloud-Test", 21, 8, 1);
					break;
				}
			}
			switch (TXHData.USART6_Drive)
			{
			case Bluetooth:
			{
				OLED_ShowPicture(0, 10, 9, 9, (u8 *)BMP_Bluetooth_9, 1);
			}
			break;
			case GPS:
			{
				OLED_ShowPicture(0, 10, 9, 9, (u8 *)BMP_GPS_9, 1);
			}
			break;
			}
			OLED_ShowPicture(104, 0, 24, 24, (u8 *)BMP_Bluesky_Con_24, 1);
			OLED_ShowString(0, 26, "Offline Record Upload", 21, 8, 1);
			OLED_ShowString(0, 36, "Record number:", 21, 8, 1);
			OLED_ShowNum(84, 36, TXHData.PREXDATA_WaitUpNummber, 0, 0, 8, 1);
			if (TXHData.PREXDATA_WaitUpNummber == 0)
			{
				SurfaceJump(Surface_Wait);
			}
			Sureface_Wait_TimeUpData();
		}
		break;
		case Surface_Wait: // ��������
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				SurfaceJump(Surface_PrintInfo);
				TXHData.ROM_UpData.ROM_UpData_State.Flag.DisableUpdate = 0;
			}
			break;
			case 0x02:
			{
				TXHData.ROM_UpData.ROM_UpData_State.Flag.DisableUpdate = 0;
				SurfaceJump(Surface_PrintInfo);
			}
			break;
			case 0x04:
			{
				TXHData.ROM_UpData.ROM_UpData_State.Flag.DisableUpdate = 0;
				SurfaceJump(Surface_SetMenu);
			}
			break;
			case 0x08:
			{
				TXHData.ROM_UpData.ROM_UpData_State.Flag.DisableUpdate = 0;
				SurfaceJump(Surface_QueryMenu);
			}
			break;
			}
			if (TXHData.POS_Info.Link_Flag == 0)
				OLED_ShowString(0, 0, "Offline", 21, 8, 1);
			else
			{
				switch (TXHData.POS_Info.ConnectType)
				{
				case POS_Connect_Typ_Station:
					OLED_ShowString(0, 0, "Type:Station", 21, 8, 1);
					break;
				case POS_Connect_Typ_Cloud:
					OLED_ShowString(0, 0, "Type:Cloud", 21, 8, 1);
					break;
				case POS_Connect_Typ_Cloud_Tast:
					OLED_ShowString(0, 0, "Type:Cloud-Test", 21, 8, 1);
					break;
				}
				// if(TXHData.POS_TX_CMDNow == POSConnect_PREXDATAUp)
				{

					// SurfaceJump(Surface_OfflineRecordUpload);
				}
			}
			switch (TXHData.USART6_Drive)
			{
			case Bluetooth:
			{
				OLED_ShowPicture(0, 20, 9, 9, (u8 *)BMP_Bluetooth_9, 1);
			}
			break;
			case GPS:
			{
				if (TXHData.GPSData.GPS.Latitude + TXHData.GPSData.GPS.Longitude)
					OLED_ShowPicture(0, 20, 9, 9, (u8 *)BMP_GPS_9, 1);
				else
					OLED_ShowPicture(0, 20, 9, 9, (u8 *)BMP_GPS_None_9, 1);
			}
			break;
			}
			if (TXHData.ROM_UpData_ProgressBar)
			{
				SurfaceJump(Surface_FirmwareUpdate);
			}
			if (TXHData.POS_Info.ConnectType != POS_Connect_Typ_Station) // վ��
			{
				if (TXHData.POS_Info.NetType == POS_Net_Typ_WiFi)
				{
					if (POS_4G_NET)
					{
						if (TXHData.POS_Info.WiFiRSSI < 50)
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI4_14x8, 1);
						else if (TXHData.POS_Info.WiFiRSSI < 60)
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI3_14x8, 1);
						else if (TXHData.POS_Info.WiFiRSSI < 70)
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI2_14x8, 1);
						else
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI1_14x8, 1);
					}
					else
					{
						OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI0_14x8, 1);
					}
				}
				else if (TXHData.POS_Info.NetType == POS_Net_Typ_4G_L510 || TXHData.POS_Info.NetType == POS_Net_Typ_4G_GM5)
				{
					if (TXHData.POS_Info.WiFiRSSI < 32)
					{
						if (TXHData.POS_Info.WiFiRSSI > 26)
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI4_14x8, 1);
						else if (TXHData.POS_Info.WiFiRSSI > 23)
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI3_14x8, 1);
						else if (TXHData.POS_Info.WiFiRSSI > 20)
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI2_14x8, 1);
						else if (TXHData.POS_Info.WiFiRSSI > 18)
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI1_14x8, 1);
						else
							OLED_ShowPicture(89, 0, 14, 8, (u8 *)BMP_WIFI0_14x8, 1);
					}
				}
			}
			OLED_ShowPicture(104, 0, 24, 24, (u8 *)BMP_Bluesky_Con_24, 1);
			OLED_ShowString(40, 20, "BLUESKY", 16, 16, 1);
			OLED_ShowString(18, 36, "ENERGY TECHNOLOGY", 21, 8, 1);
			if (TXHData.PREXDATA_WaitUpNummber > 0)
			{
				sprintf(Buff, "WaitUpload:%d/%d", TXHData.PREXDATA_WaitUpNummber, TXHData.OfflineAuthorizeNumberMax);
				OLED_ShowString(0, 46, Buff, 21, 8, 1);
			}
			if (TXHData.ROM_UpData.ROM_UpData_State.Flag.DisableUpdate == 1)
				OLED_ShowString(0, 46, "Upgrade ERR Check Gun", 21, 8, 1);
			Sureface_Wait_TimeUpData();
			if (TXHData.POSNetSetState.Flag.WorkMode == 1) // ͸��ģʽ
			{
				sprintf(&Buff[0], "%02x", TXHData.POS_Info.POS_CMD_Next);
				OLED_ShowString(0, 56, Buff, 2, 8, 1);
			}
			else
			{
				sprintf(&Buff[0], "%02x", TXHData.POSNetSetState.Flag.POSNetCMDNext);
				OLED_ShowString(0, 56, Buff, 2, 8, 1);
				// OLED_ShowNum(0,56,TXHData.POSNetSetState.Flag.POSNetCMDNext,0,0,8,1);
			}
			if (TXHData.DelayDetectionTimer.Flag)
			{
				OLED_ShowString(0, 10, "Blockage", 21, 8, 1);
			}
			else
			{
				sprintf(&Buff[0], "%dms", TXHData.DelayDetection);
				OLED_ShowString(0, 10, Buff, 10, 8, 1);
			}
			if (TXHData.ErrState.Flag.e_errPCBCheck == 1)
			{
				OLED_ShowString(0, 46, "PCB Validation Failed", 21, 8, 1);
			}
		}
		break;
		case Surface_PrintInfo: // ��ӡ����
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				i = 0;
				for (; TXHData.SurfaceNowItem >= 0;)
				{
					i++;
					if (i > 64)
						break;
					if (TXHData.SurfaceNowItem > 0)
						TXHData.SurfaceNowItem--;
					else
						TXHData.SurfaceNowItem = 63;
					if (TXHData.PrintLastRecord[TXHData.SurfaceNowItem].GunNumber != 0)
						break;
				}
			}
			break;
			case 0x02:
			{
				i = 0;
				for (; TXHData.SurfaceNowItem < 64;)
				{
					i++;
					if (i > 64)
						break;
					if (TXHData.SurfaceNowItem < 63)
						TXHData.SurfaceNowItem++;
					else
						TXHData.SurfaceNowItem = 0;
					if (TXHData.PrintLastRecord[TXHData.SurfaceNowItem].GunNumber != 0)
						break;
				}
			}
			break;
			case 0x04:
			{
				TXHData.MD_Multiplex_Port_Info.PrintPlaceNumber = TXHData.SurfaceNowItem;
				TXHData.MD_Multiplex_Port_Info.PrintType = PT_LastRecord;
				// Printf_UpData(TXHData.SurfaceNowLine,PT_LastRecord);
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_Wait);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_PrintInfo)
			{
				MD_Port = TXHData.SurfaceNowItem / 16;
				Surface_Copy_16(PrintInfo[0], 0, 1);
				OLED_ShowNum(88, 0, TXHData.PrintLastRecord[TXHData.SurfaceNowItem].GunNumber, 0, 0, 16, 1);
				OLED_ShowString(0, 16, "L:              ", 16, 16, 1);
				OLED_ShowNum(3 * 8, 16, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].FData.OilCNT), 0, TXHData.MD_Port_Data[MD_Port].PortData.GunDec.Dec.OilCNT, 16, 1);
				OLED_ShowString(0, 32, "P:              ", 16, 16, 1);
				OLED_ShowNum(3 * 8, 32, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].FData.MoneyCNT), 0, TXHData.MD_Port_Data[MD_Port].PortData.GunDec.Dec.MoneyCNT, 16, 1);
				X_Now = 4;
				Y_Now = 56;
				X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].RTIME.Hour), 0, 0, 8, 1);
				OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
				X_Now++;
				X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].RTIME.Min), 0, 0, 8, 1);
				OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
				X_Now++;
				X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].RTIME.Sec), 0, 0, 8, 1);
				OLED_ShowChar(6 * X_Now, Y_Now, ' ', 8, 1);
				X_Now++;
				X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].RTIME.Year), 0, 0, 8, 1);
				OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
				X_Now++;
				X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].RTIME.Month), 0, 0, 8, 1);
				OLED_ShowChar(6 * X_Now, Y_Now, '-', 8, 1);
				X_Now++;
				X_Now += OLED_ShowNum(6 * X_Now, Y_Now, MD_Connect_BCDTou64(TXHData.PrintLastRecord[TXHData.SurfaceNowItem].RTIME.Day), 0, 0, 8, 1);
				// OLED_ShowNum(80,0,TXHData.MD_Port_Info[0].GunInfo[0].FData.MoneyCNT,0,16,1);
				//	OLED_ShowString(80,0,"",16,3,0);
			}
		}
		break;
		case Surface_QueryMenu:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowLine > 0)
					TXHData.SurfaceNowLine--;
				else
					TXHData.SurfaceNowLine = Q_ItemEnd - 1;
			}
			break;
			case 0x02:
			{
				//					  TXHData.MD_LORA_Slave_Flag = 0;
				//				    TXHData.MD_LORA_SlaveTimer.Init = 1;
				//						MD_Connect_Init();
				if (TXHData.SurfaceNowLine < Q_ItemEnd - 1)
					TXHData.SurfaceNowLine++;
				else
					TXHData.SurfaceNowLine = 0;
			}
			break;
			case 0x04:
			{
				switch (TXHData.SurfaceNowLine)
				{
				case Q_NetworkInfo:
				{
					SurfaceJump(Surface_Q_NetworkInfo);
				}
				break;
				case Q_MDPortInfo:
				{
					SurfaceJump(Surface_Q_MDPortInfo);
				}
				break;
				case Q_LORARSSI:
				{
					SurfaceJump(Surface_Q_LORARSSI);
				}
				break;
				case Q_VeresionCheck:
				{
					SurfaceJump(Surface_Q_VeresionCheck);
				}
				break;
				case Q_Test_Info:
				{
					SurfaceJump(Surface_Q_Test_Info);
				}
				break;
				}
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_Wait);
				TXHData.SurfaceNowLine = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_QueryMenu)
			{
				Surface_Copy_16(QueryMenu[TXHData.SurfaceNowLine], 0, 4);
				OLED_ShowString(0, 0, (u8 *)&QueryMenu[TXHData.SurfaceNowLine], 16, 16, 0);
			}
		}
		break;
		case Surface_Q_NetworkInfo:
		{
			switch (GetKeyNum())
			{
			case 0x08:
			{
				SurfaceJump(Surface_QueryMenu);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_Q_NetworkInfo)
			{
				Surface_Copy_16(QueryNetworkInfo[0], 0, 4);
				switch (TXHData.POS_Info.ConnectType)
				{
				case POS_Connect_Typ_Station:
					OLED_ShowString(0, 16, "Type:Station", 16, 8, 1);
					break;
				case POS_Connect_Typ_Cloud:
					OLED_ShowString(0, 16, "Type:Cloud", 16, 8, 1);
					OLED_ShowString(0, 56, "URL:", 16, 8, 1);
					OLED_ShowString(5 * 6, 56, (u8 *)&TXHData.POSData.WirelessData.CMD_SOCKA[13], 17, 8, 1);
					break;
				case POS_Connect_Typ_Cloud_Tast:
					OLED_ShowString(0, 16, "Type:Cloud-Tast", 16, 8, 1);
					OLED_ShowString(0, 56, "URL:", 16, 8, 1);
					OLED_ShowString(5 * 6, 56, (u8 *)&TsatURL[13], 17, 8, 1);
					break;
				}
				if (TXHData.POS_Info.ConnectType != POS_Connect_Typ_Station)
				{
					if (TXHData.POS_Info.NetType == POS_Net_Typ_4G_GM5)
					{
						for (i = 0; i < sizeof(TXHData.ICCID); i++)
							if (TXHData.ICCID[i])
								break;
						// OLED_ShowString(0,26,"ICCID",16,8,1);OLED_ShowString(32,26,&TXHData.ICCID[i],16,8,1);
						OLED_ShowString(0, 26, "APN :", 16, 8, 1);
						OLED_ShowString(6 * 6, 26, &TXHData.POSData.WirelessData.APN[0], 16, 8, 1);
						if (TXHData.HardwareVersion > 24) // �µ�Ӳ���汾�����⿪ʼ�����е�ģ��ʹ����оƬ����IMEI��
						{
							OLED_ShowString(0, 36, "IMEI:", 16, 8, 1);
							OLED_ShowString(0, 46, &TXHData.POSData.WirelessData.IMEI[0], 20, 8, 1);
						}
						else
						{
							OLED_ShowString(0, 36, "IMEI:", 16, 8, 1);
							OLED_ShowString(0, 46, &TXHData.POSData.WirelessData.IMEI[5], 20, 8, 1);
						}
					}
					else if (TXHData.POS_Info.NetType == POS_Net_Typ_4G_L510)
					{
						for (i = 0; i < sizeof(TXHData.ICCID); i++)
							if (TXHData.ICCID[i])
								break;
						// OLED_ShowString(0,26,"ICCID",16,8,1);OLED_ShowString(32,26,&TXHData.ICCID[i],16,8,1);
						OLED_ShowString(0, 26, "APN :", 16, 8, 1);
						OLED_ShowString(6 * 6, 26, &TXHData.POSData.WirelessData.APN[0], 16, 8, 1);
						OLED_ShowString(0, 36, "IMEI:", 16, 8, 1);
						OLED_ShowString(0, 46, &TXHData.POSData.WirelessData.IMEI[0], 20, 8, 1);
					}
					else if (TXHData.POS_Info.NetType == POS_Net_Typ_WiFi)
					{
						//							if(TXHData.POS_Info.ConnectType == POS_Connect_Typ_WifiStation)
						//							{
						//							  OLED_ShowString(0,26,"SSID:THX-HD4-2.4",16,8,1);
						//							  }
						//							else
						{
							OLED_ShowString(0, 26, "SSID:", 16, 8, 1);
							OLED_ShowString(5 * 6, 26, &TXHData.POSData.WirelessData.WiFIName[0], 16, 8, 1);
						}
						OLED_ShowString(0, 36, "IMEI:", 16, 8, 1);
						OLED_ShowString(0, 46, &TXHData.POSData.WirelessData.IMEI[0], 20, 8, 1);
					}
					else if (TXHData.POS_Info.NetType == POS_Net_Typ_WAN)
					{
						OLED_ShowString(0, 26, "IP:", 16, 8, 1);
						OLED_ShowString(3 * 6, 26, &TXHData.POS_Info.IP[0], 16, 8, 1);
						OLED_ShowString(0, 36, "IMEI:", 16, 8, 1);
						OLED_ShowString(0, 46, &TXHData.POSData.WirelessData.IMEI[0], 20, 8, 1);
					}
				}
			}
		}
		break;
		case Surface_Q_MDPortInfo:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowItem > 0)
					TXHData.SurfaceNowItem--;
			}
			break;
			case 0x02:
			{
				if (TXHData.SurfaceNowItem < 3)
					TXHData.SurfaceNowItem++;
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_QueryMenu);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_Q_MDPortInfo)
			{
				Surface_Copy_16(QueryMDPortInfo[0], 0, 4);
				OLED_ShowNum(62, 0, TXHData.SurfaceNowItem + 1, 1, 0, 16, 1);
				OLED_ShowString(72, 0, "OnLine : ", 16, 8, 1);
				OLED_ShowPicture(120, 0, 8, 8, (u8 *)BMP_Bluesky_Empty_8, 1);
				OLED_ShowString(72, 8, "OffLine: ", 16, 8, 1);
				OLED_ShowPicture(120, 8, 8, 8, (u8 *)BMP_Bluesky_Empty_8, 0);
				OLED_ShowString(0, 16, "Type:", 16, 8, 1);
				if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType == MD_LORA)
					OLED_ShowString(5 * 6, 16, "LORA", 16, 8, 1);
				else
					OLED_ShowString(5 * 6, 16, "RS485", 16, 8, 1);
				OLED_ShowString(0, 24, "Protocol:", 16, 8, 1);
				if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.POSType == PosYWY)
					OLED_ShowString(9 * 6, 24, (u8 *)YWY_Type_Info[TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.Device_Type], 12, 8, 1);
				else
					OLED_ShowString(9 * 6, 24, (u8 *)QueryMDPortInfo_POSType[TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.POSType], 12, 8, 1);
				OLED_ShowString(0, 32, "Gun-Addr:", 16, 8, 1);
				X_Now = 9;
				Y_Now = 0;
				for (i = 0; i < TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.DeviceNumber; i++)
				{
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					X_Now += OLED_ShowNum(6 * X_Now, 32 + Y_Now * 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunNummber, 0, 0, 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunState.Flag.Online);
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					OLED_ShowChar(6 * X_Now, 32 + Y_Now * 8, '-', 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunState.Flag.Online);
					X_Now++;
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					X_Now += OLED_ShowNum(6 * X_Now, 32 + Y_Now * 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunAddr, 0, 0, 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunState.Flag.Online);
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					OLED_ShowChar(6 * X_Now, 32 + Y_Now * 8, ';', 8, 1);
					X_Now++;
				}
			}
		}
		break;
		case Surface_Q_LORARSSI:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowItem > 0)
					TXHData.SurfaceNowItem--;
			}
			break;
			case 0x02:
			{
				if (TXHData.SurfaceNowItem < 3)
					TXHData.SurfaceNowItem++;
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_QueryMenu);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_Q_LORARSSI)
			{
				TXHData.DisplayOn = 1;
				Surface_Copy_16(QueryLORARSSI[0], 0, 4);
				OLED_ShowNum(64, 0, TXHData.SurfaceNowItem + 1, 1, 0, 16, 1);
				OLED_ShowString(0, 20, "Gun-RSSI:", 16, 8, 1);
				X_Now = 9;
				Y_Now = 0;
				for (i = 0; i < TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.DeviceNumber; i++)
				{
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					X_Now += OLED_ShowNum(6 * X_Now, 20 + Y_Now * 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunNummber, 0, 0, 8, 1);
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					OLED_ShowChar(6 * X_Now, 20 + Y_Now * 8, '-', 8, 1);
					X_Now++;
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					X_Now += OLED_ShowNum(6 * X_Now, 20 + Y_Now * 8, TXHData.MD_Port_Info[TXHData.SurfaceNowItem].GunInfo[i].RSSI * 100 / 256, 0, 0, 8, 1);
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					OLED_ShowChar(6 * X_Now, 20 + Y_Now * 8, '%', 8, 1);
					X_Now++;
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					OLED_ShowChar(6 * X_Now, 20 + Y_Now * 8, ';', 8, 1);
					X_Now++;
				}
			}
		}
		break;
		case Surface_Q_VeresionCheck:
		{
			switch (GetKeyNum())
			{
			case 0x08:
			{
				SurfaceJump(Surface_QueryMenu);
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_Q_VeresionCheck)
			{
				Surface_Copy_16(QueryVeresion[0], 0, 4);
				OLED_ShowString(0, 18, "SV:", 16, 8, 1);
				OLED_ShowString(6 * 3, 18, (u8 *)&BoxVersion[0], 16, 8, 1);
				OLED_ShowString(6 * 15, 18, "HV:", 16, 8, 1);
				OLED_ShowNum(6 * 18, 18, TXHData.HardwareVersion, 2, 0, 8, 1);
				for (i = 0; i < 4; i++)
				{
					if (TXHData.MD_Port_Data[i].PortData.ROM_UpData.ROM_UpData_State.Flag.Update_Flag == 1)
					{
						OLED_ShowString(0, 27 + i * 9, "Port-", 5, 8, 1);
						OLED_ShowNum(5 * 6, 27 + i * 9, i + 1, 1, 0, 8, 1);
						OLED_ShowString(7 * 6, 27 + i * 9, (u8 *)&TXHData.MD_Port_Data[i].PortData.ROM_UpData_Version[0], 10, 8, 1);
					}
				}
			}
		}
		break;
		case Surface_Q_Test_Info:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowItem > 0)
					TXHData.SurfaceNowItem--;
			}
			break;
			case 0x02:
			{
				if (TXHData.SurfaceNowItem < 3)
					TXHData.SurfaceNowItem++;
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_QueryMenu);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_Q_Test_Info)
			{
				Surface_Copy_16(QueryTestInfo[0], 0, 4);
				OLED_ShowNum(62, 0, TXHData.SurfaceNowItem + 1, 1, 0, 16, 1);
				OLED_ShowString(72, 0, "OnLine : ", 16, 8, 1);
				OLED_ShowPicture(120, 0, 8, 8, (u8 *)BMP_Bluesky_Empty_8, 1);
				OLED_ShowString(72, 8, "OffLine: ", 16, 8, 1);
				OLED_ShowPicture(120, 8, 8, 8, (u8 *)BMP_Bluesky_Empty_8, 0);
				OLED_ShowString(0, 16, "Type:", 16, 8, 1);
				if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType == MD_LORA)
					OLED_ShowString(5 * 6, 16, "LORA", 16, 8, 1);
				else
					OLED_ShowString(5 * 6, 16, "RS485", 16, 8, 1);
				OLED_ShowString(0, 24, "Protocol:", 16, 8, 1);
				if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.POSType == PosYWY)
					OLED_ShowString(9 * 6, 24, (u8 *)YWY_Type_Info[TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.Device_Type], 12, 8, 1);
				else
					OLED_ShowString(9 * 6, 24, (u8 *)QueryMDPortInfo_POSType[TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.POSType], 12, 8, 1);
				OLED_ShowString(0, 32, "Gun-Addr:", 16, 8, 1);
				X_Now = 9;
				Y_Now = 0;
				for (i = 0; i < TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.DeviceNumber; i++)
				{
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					X_Now += OLED_ShowNum(6 * X_Now, 32 + Y_Now * 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunNummber, 0, 0, 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunState.Flag.Online);
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					OLED_ShowChar(6 * X_Now, 32 + Y_Now * 8, '-', 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunState.Flag.Online);
					X_Now++;
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					X_Now += OLED_ShowNum(6 * X_Now, 32 + Y_Now * 8, TXHData.MD_Port_Info[TXHData.SurfaceNowItem].GunInfo[i].WaitPREXDATA_flag, 0, 0, 8, TXHData.MD_Port_Data[TXHData.SurfaceNowItem].GunData[i].GunState.Flag.Online);
					if (6 * X_Now > 122)
					{
						Y_Now++;
						X_Now = 0;
					}
					OLED_ShowChar(6 * X_Now, 32 + Y_Now * 8, ';', 8, 1);
					X_Now++;
				}
			}
		}
		break;
		case Surface_SetMenu:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowLine > 0)
					TXHData.SurfaceNowLine--;
				else
					TXHData.SurfaceNowLine = S_ItemEnd - 1;
			}
			break;
			case 0x02:
			{
				//					  TXHData.MD_LORA_Slave_Flag = 0;
				//				    TXHData.MD_LORA_SlaveTimer.Init = 1;
				//						MD_Connect_Init();
				if (TXHData.SurfaceNowLine < S_ItemEnd - 1)
					TXHData.SurfaceNowLine++;
				else
					TXHData.SurfaceNowLine = 0;
			}
			break;
			case 0x04:
			{

				switch (TXHData.SurfaceNowLine)
				{
				case S_MDConnectSet:
				{
					SurfaceJump(Surface_S_MDConnectSet);
				}
				break;
				case S_LORASlaveSet:
				{
					SurfaceJump(Surface_S_LORASlaveSet);
				}
				break;
				case S_PortLogOutput:
				{
					SurfaceJump(Surface_S_PortLogOutput);
				}
				break;
				case S_ConnectMode:
				{
					SurfaceJump(Surface_S_ConnectMode);
					TXHData.SurfaceNowLine = TXHData.POSData.POSConnectTyye.Flag.ConnectMode;
				}
				break;
				case S_NetworkSet:
				{
					SurfaceJump(Surface_S_NetworkSet);
					TXHData.SurfaceNowLine = TXHData.POSData.POSConnectTyye.Flag.NetworkSet;
				}
				break;
				case S_DataInit:
				{
					SurfaceJump(Surface_S_DataInit);
				}
				break;
				}
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_Wait);
				TXHData.SurfaceNowLine = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_SetMenu)
			{
				Surface_Copy_16(SetMenu[TXHData.SurfaceNowLine], 0, 4);
				OLED_ShowString(0, 0, (u8 *)&SetMenu[TXHData.SurfaceNowLine], 16, 16, 0);
			}
		}
		break;
		case Surface_S_MDConnectSet:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowItem > 0)
				{
					TXHData.SurfaceNowItem--;
				}
			}
			break;
			case 0x02:
			{
				if (TXHData.SurfaceNowItem < 3)
				{
					TXHData.SurfaceNowItem++;
				}
			}
			break;
			case 0x04:
			{
				if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType == MD_LORA)
				{
					TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType = MD_RS485;
					FMItemWrite(CF_MD_Port_Data, TXHData.SurfaceNowItem);
					MD_Port_Init(TXHData.SurfaceNowItem);
					BEEP_OFF;
				}
				else if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType == MD_RS485)
				{
					BEEP_ON;
					TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType = MD_LORA;
					MD_Port_Init(TXHData.SurfaceNowItem);
					FMItemWrite(CF_MD_Port_Data, TXHData.SurfaceNowItem);
				}
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_SetMenu);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_S_MDConnectSet)
			{
				Surface_Copy_16(SetMDConnect[0], 0, 4);
				OLED_ShowString(40, 20, "PORT:", 21, 8, 1);
				OLED_ShowNum(70, 20, TXHData.SurfaceNowItem + 1, 1, 0, 8, 1);
				if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType == MD_LORA)
					OLED_ShowString(0, 30, "TYPE:LORA", 21, 8, 1);
				else if (TXHData.MD_Port_Data[TXHData.SurfaceNowItem].PortData.MDConnectType == MD_RS485)
					OLED_ShowString(0, 30, "TYPE:RS485", 21, 8, 1);
				OLED_ShowString(0, 50, "Pass Enter Change", 21, 8, 1);
			}
		}
		break;
		case Surface_S_LORASlaveSet:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowItem > 0)
				{
					if (TXHData.MD_LORA_Set_Flag)
					{
						MD_Port_Init(TXHData.SurfaceNowItem);
					}
					TXHData.SurfaceNowItem--;
				}
			}
			break;
			case 0x02:
			{
				if (TXHData.SurfaceNowItem < 3)
				{
					if (TXHData.MD_LORA_Set_Flag)
					{
						MD_Port_Init(TXHData.SurfaceNowItem);
					}
					TXHData.SurfaceNowItem++;
				}
			}
			break;
			case 0x04:
			{
				TXHData.MD_LORA_Set_Flag = 1;
				TXHData.MD_LORA_SlaveTimer.ON_OFF = 1;
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_SetMenu);
				TXHData.SurfaceNowItem = 0;
				TXHData.MD_LORA_SlaveTimer.Init = 1;
				if (TXHData.MD_LORA_Set_Flag)
				{
					BEEP_OFF;
					TXHData.MD_LORA_Set_Flag = 0;
					MD_Port_Init(TXHData.SurfaceNowItem);
				}
			}
			break;
			}

			if (TXHData.SurfaceNow == Surface_S_LORASlaveSet)
			{
				Surface_Copy_16(SetLORASlave[0], 0, 4);
				OLED_ShowString(40, 18, "PORT:", 21, 8, 1);
				OLED_ShowNum(70, 18, TXHData.SurfaceNowItem + 1, 1, 0, 8, 1);
				OLED_ShowString(0, 28, "1:Dip switch 1and2 ON", 21, 8, 1);
				OLED_ShowString(0, 38, "2:Insert slave module", 21, 8, 1);
				OLED_ShowString(0, 48, "3:Pass Enter Start", 21, 8, 1);
			}
			if (TXHData.MD_LORA_Set_Flag == 1)
			{
				TXHData.DisplayOn = 1;
				if (TXHData.MD_LORA_SlaveTimer.Flag)
				{
					BEEP_OFF;
					TXHData.MD_LORA_SlaveTimer.Flag = 0;
					MD_Port_LORASet(TXHData.SurfaceNowItem, LORA_Slave);
					OLED_ShowString(0, 56, "State:Sending", 21, 8, 1);
				}
				if (TXHData.MD_LORA_Slave_Flag)
				{
					TXHData.MD_LORA_Slave_Flag = 0;
					OLED_ShowString(0, 56, "State:Complete", 21, 8, 1);
					BEEP_ON;
				}
			}
		}
		break;
		case Surface_S_PortLogOutput:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
			}
			break;
			case 0x02:
			{
			}
			break;
			case 0x04:
			{
				if (CH376DiskConnect() == USB_INT_SUCCESS) /* ���U���Ƿ����� ,*/
				{
					TXHData.UDisk_Flag = 1; // �����־�����ģ�����ƽʱ���ܿ���
				}
				else
				{
					TXHData.UDisk_Flag = 0;
				}
			}
			break;
			case 0x08:
			{
				// TXHData.UDisk_Flag = 0;
				SurfaceJump(Surface_SetMenu);
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_S_PortLogOutput)
			{
				Surface_Copy_16(SetPortLogOutput[0], 0, 4);
				OLED_ShowString(0, 26, "Insert U-Disk First", 21, 8, 1);
				OLED_ShowString(0, 36, "Than Pass Enter", 21, 8, 1);
				OLED_ShowString(0, 46, "Format:FAT32;MAX:32G", 21, 8, 1);
				if (TXHData.UDisk_Flag)
					OLED_ShowString(0, 56, "Find U-Disk,Outputing", 21, 8, 1);
				else
					OLED_ShowString(0, 56, "State:Idle", 21, 8, 1);
			}
		}
		break;
		case Surface_S_ConnectMode:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowItem > 0)
				{

					TXHData.SurfaceNowItem--;
				}
				else
				{
					TXHData.SurfaceNowItem = POS_Connect_Typ_End;
				}
			}
			break;
			case 0x02:
			{
				if (TXHData.SurfaceNowItem < POS_Connect_Typ_End)
				{
					TXHData.SurfaceNowItem++;
				}
				else
				{
					TXHData.SurfaceNowItem = 0;
				}
			}
			break;
			case 0x04:
			{
				TXHData.POSData.POSConnectTyye.Flag.ConnectMode = TXHData.SurfaceNowItem;
				if (FMItemWrite(CF_POSData, 0))
				{
					i = TXHData.POSData.POSConnectTyye.State;
					SurfaceJump(Surface_Wait);
					FM_Data_Init();
					TXHData.POSData.POSConnectTyye.State = i;
					FMItemWrite(CF_POSData, 0);
					TXHData.ROM_UpData.ROM_UpData_State.Flag.Update_Flag = 0;
					TXHData.ROM_UpData.ROM_UpData_State.Flag.RightRun_Flag = 3;
					TXHData.ROM_UpData.FrameTop = 0;
					FMItemWrite(CF_ROM_UpData, 0);
					TXHData.POSNetSetState.Flag.WorkMode = 0;
					switch (TXHData.POS_Info.NetType)
					{
					case POS_Net_Typ_WAN:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = USRK3_ENTM;
						break;
					case POS_Net_Typ_WiFi:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = WIFI_WifiRST;
						break;
					case POS_Net_Typ_4G_GM5:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = GM5_ENTM;
						break;
					case POS_Net_Typ_4G_L510:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = L510_AT;
						;
						break;
					}
					POS_Connect_Init();
				}
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_SetMenu);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_S_ConnectMode)
			{
				Surface_Copy_16(SetConnectMode[0], 0, 4);
				OLED_ShowString(0, 16, (u8 *)ConnectMode_Info[TXHData.POSData.POSConnectTyye.Flag.ConnectMode], 16, 16, 1);
				if (TXHData.POSData.POSConnectTyye.Flag.ConnectMode != TXHData.SurfaceNowItem)
					OLED_ShowString(0, 32, (u8 *)(&ConnectMode_Info[TXHData.SurfaceNowItem][4]), 12, 16, 0);
				else
					OLED_ShowString(0, 32, (u8 *)(&ConnectMode_Info[TXHData.SurfaceNowItem][4]), 12, 16, 1);
			}
		}
		break;
		case Surface_S_NetworkSet:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
				if (TXHData.SurfaceNowItem > 0)
				{

					TXHData.SurfaceNowItem--;
				}
				else
				{
					TXHData.SurfaceNowItem = POS_Net_Typ_End;
				}
			}
			break;
			case 0x02:
			{
				if (TXHData.SurfaceNowItem < POS_Net_Typ_End)
				{
					TXHData.SurfaceNowItem++;
				}
				else
				{
					TXHData.SurfaceNowItem = 0;
				}
			}
			break;
			case 0x04:
			{
				TXHData.POSData.POSConnectTyye.Flag.NetworkSet = TXHData.SurfaceNowItem;
				if (FMItemWrite(CF_POSData, 0))
				{
					SurfaceJump(Surface_Wait);
					TXHData.POSNetSetState.Flag.WorkMode = 0;
					switch (TXHData.POS_Info.NetType)
					{
					case POS_Net_Typ_WAN:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = USRK3_ENTM;
						break;
					case POS_Net_Typ_WiFi:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = WIFI_WifiRST;
						break;
					case POS_Net_Typ_4G_GM5:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = GM5_ENTM;
						break;
					case POS_Net_Typ_4G_L510:
						TXHData.POSNetSetState.Flag.POSNetCMDNext = L510_AT;
						;
						break;
					}
					POS_Connect_Init();
					TXHData.SurfaceNowItem = 0;
					// FMItemWrite(CF_POSNetSetState,0);
					// POS_Network_Init();
				}
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_SetMenu);
				TXHData.SurfaceNowItem = 0;
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_S_NetworkSet)
			{
				Surface_Copy_16(SetNetworkSet[0], 0, 4);
				OLED_ShowString(0, 16, (u8 *)Network_Type_Info[TXHData.POSData.POSConnectTyye.Flag.NetworkSet], 16, 16, 1);
				if (TXHData.POSData.POSConnectTyye.Flag.NetworkSet != TXHData.SurfaceNowItem)
					OLED_ShowString(0, 32, (u8 *)(&Network_Type_Info[TXHData.SurfaceNowItem][4]), 12, 16, 0);
				else
					OLED_ShowString(0, 32, (u8 *)(&Network_Type_Info[TXHData.SurfaceNowItem][4]), 12, 16, 1);
			}
		}
		break;
		case Surface_S_DataInit:
		{
			switch (GetKeyNum())
			{
			case 0x01:
			{
			}
			break;
			case 0x02:
			{
			}
			break;
			case 0x04:
			{
				FM_Data_Init();
				__set_FAULTMASK(1);
				NVIC_SystemReset();
			}
			break;
			case 0x08:
			{
				SurfaceJump(Surface_SetMenu);
			}
			break;
			}
			if (TXHData.SurfaceNow == Surface_S_DataInit)
			{
				Surface_Copy_16(SetDataInit[0], 0, 4);
			}
		}
		break;
		}

		OLED_Refresh();
	}
}