Пример #1
0
////FUNCTIONS//////////////////
//-----------------------------------------------------------------------------
// Name: Main()
// Desc: Where all work is done
//-----------------------------------------------------------------------------
bool main()
{
	static int nFrames = 0;
	//static CVECTOR shipsVelVector(0.f,0.f,0.f);
	
	if(GetKeyStatus(VK_ESCAPE) == true)
		return(0);
	
	//Clear the surface
	if(!ClrS(lpddsSecondary,&wndRect))//can't be within a lock-Unlock block or u can't blt
		return(0);
	
	DynamicStarField(NULL,800,Sprites[0].physProp.VelVector,nFrames);
	//Sprites[0].DrawSprite(lpddsSecondary);
	MoveShip();
	
	if(bDebugMode)
		DebugInfo(nFrames);
	
	//Flip primary and secondary surfaces
	Flip();
	//Sleep(1000);
	fFrameTime = frameTimer.EndTimerAndRestart();
	nFrames++;
	return(1);
}
/*------------------------------------------------------------
 * Function Name  : SelectRestoreMediumProcess
 * Description    : 选择还原媒介
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
uint8_t SelectRestoreMediumProcess( void )
{	
	if (SystemRestore.Account == MANAGER)
	{
		return 0xff;
	}
	
	LCD_ClearAssistButton(COLOR_BACK);
	
	lcd_show_image(ASSIST_FUNC_POS_X,ASSIST_FUNC_POS1_Y,BUTTON_RESTORE_FROM_SD);
	lcd_show_image(ASSIST_FUNC_POS_X,ASSIST_FUNC_POS2_Y,BUTTON_RESTORE_FROM_U);
	
	while (1)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F5:
					return BACKUP_SD;
					 
				case KEY_F6:
					return BACKUP_USB;
			}
		}
	}
}
Пример #3
0
/*------------------------------------------------------------
 * Function Name  : UserLoginEnterLogin
 * Description    : 管理员模式中
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadManageMode( void )
{
	/* 初始化 */
	ManageModeInit();
	
	/* GUI界面 */
	GUI_ManageMode();
	
	while (GetPage() == MANAGE_MODE_PAGE)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 索引值判断 */
		ChangeKeyIndex(ENABLE,MAX_PARAMETER_CNT,1,MAX_PARAMETER_CNT,&ManageMode.now_index);
		
		/* 改变光标 */
		ManageModeCursorChange(&ManageMode.last_index,&ManageMode.now_index);
		
		/* 快速进入子页 */
		ManageModeMoreParameterQuickEnter();
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F7:
					ManageModeEnterSubPage(ManageMode.now_index);
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
}
/*------------------------------------------------------------
 * Function Name  : LoadTestAfterDispose
 * Description    : 试验后处理
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadTestAfterDispose( void )
{
	/* 初始化 */
	TestAfterDisposeInit();
	
	/* 获取参数 */
	GetTestAfterDisposeDateFromFlash(READ_FLASH);
	
	/* GUI界面 */
	GUI_TestAfterDispose();
	
	/* 遍历 */
	ShowTestAfterDispose(AUTO_PRINT,TestAfterDispose.data[AUTO_PRINT]);
	
	while (GetPage() == TEST_AFTER_DISPOSE_PAGE)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F8:
					TestAfterDispose.data[AUTO_PRINT] = (TestAfterDispose.data[AUTO_PRINT] == ENABLE) ? DISABLE : ENABLE;
					ShowTestAfterDispose(AUTO_PRINT,TestAfterDispose.data[AUTO_PRINT]);
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
	
	TestAfterDisposeSave();
}
Пример #5
0
/*------------------------------------------------------------
 * Function Name  : LoadUnitSelect
 * Description    : 单位选择
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadUnitSelect( void )
{
	/* 初始化 */
	UnitSelectInit();
	
	/* 获取参数 */
	GetUnitSelectDateFromFlash(READ_FLASH);
	
	/* GUI界面 */
	GUI_UnitSelect();
	
	ShowUnitSelect(UNIT_KY,UnitSelect.data[UNIT_KY]);
	
	while (GetPage() == UNIT_SELECT_PAGE)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MANAGE_MODE_PAGE);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F8:
					UnitSelect.data[UNIT_KY] = (UnitSelect.data[UNIT_KY] == ENABLE) ? DISABLE : ENABLE;
					ShowUnitSelect(UNIT_KY,UnitSelect.data[UNIT_KY]);
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
	
	UnitSelectSave();
}
Пример #6
0
/*------------------------------------------------------------
 * Function Name  : LoadHardTest
 * Description    : 硬件测试
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadHardTest( void )
{	
	/* 初始化 */
	HardTestInit();
	
	/* GUI界面 */
	GUI_HardTest();
	
	while ( GetPage() == HARD_TEST_PAGE)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* 获取数据 */
		GetHardTestDataFromPrm();
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F5:
					SendClearZeroCmd();
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}	
	}
	
	LeaveHardTest();
}
/*------------------------------------------------------------
 * Function Name  : LoadPutinPassword
 * Description    : 输入用户密码页
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
TestStatus LoadPutinPassword( PAGE_TypeDef Page )
{
	if (JudgeNeedPassword() == DISABLE)
	{
		SetPage(Page);
		
		return PASSED; 
	}
	
	/* 初始化 */
	PutinPasswordInit();
	
	/* GUI */
	GUI_PutinPassword();
	
	/* 遍历 */
	ShowPutinPassword();
	
	while (PutinPassword.ExceptionBackOut == DISABLE)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 数据输入 */
		PutinPasswordPutin(PASSWORD_PUTIN);
		
		/* 上位机警告 */
		PutinPassword.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					return PASSED;
				
				case KEY_F8:
					strcpy(PutinPassword.data[PASSWORD_PUTIN],TypeWriteChar);
					if (SystemPasswordCheck(PutinPassword.data[PASSWORD_PUTIN]) == PASSED)
					{
						SetPage(Page);
						return PASSED;
					}
					else
					{
						SetErr(&GeneralWarning,PCM_ERR,0xff,1,&PutinPasswordWarn[0]);
					}
					break;
			}
		}
	}
	
	return FAILED;
}
Пример #8
0
InputMethodIdentifier BEInput::GetPressedKeyMode(BEKeyBinds key){
    for (auto &it : keyData[key]){
        InputState state;
        if (forcedData[key].dur > 0){
            state = forcedData[key].key;
        }else{
            state = GetKeyStatus(it);
        }
        if (state == JUST_PRESSED || state == PRESSED){
            return it.method;
        }
    }
    return IM_NONE;
}
Пример #9
0
bool BEInput::KeyRelease(BEKeyBinds key){
    for (auto &it : keyData[key]){
        InputState state;
        if (forcedData[key].dur > 0){
            state = forcedData[key].key;
        }else{
            state = GetKeyStatus(it);
        }
        if (state == JUST_RELEASED){
            return true;
        }
    }
    return false;
}
Пример #10
0
bool BEInput::IsKeyDown(BEKeyBinds key){
    for (auto &it : keyData[key]){
        InputState state;
        if (forcedData[key].dur > 0){
            state = forcedData[key].key;
        }else{
            state = GetKeyStatus(it);
        }
        if (state == JUST_PRESSED || state == PRESSED){
            return true;
        }
    }
    return false;
}
Пример #11
0
////FUNCTIONS//////////////////
//-----------------------------------------------------------------------------
// Name: Main()
// Desc: Where all work is done
//-----------------------------------------------------------------------------
bool main()
{
	static int frames=0;
	static float fps=0.0f, frametime=0.0f;
	static char buffer[1024];
	frames++;
	
	//if(frames == 1)
	//	bitmap.LoadBitmapFile24();
	if(GetKeyStatus(VK_ESCAPE) == true)
		return(0);
	
	//Clear the surface
	if(!ClrS(lpddsSecondary,&wndRect))//can't be within a lock-Unlock block or u can't blt
		return(0);

	//Lock the surface for drawing
	//if(!Lock(lpddsPrimary))
	//	return(0);
/*
	UCHAR *imagebuffer=NULL;
	imagebuffer = (UCHAR*)ddsd.lpSurface;
	for(int y=0; y<bitmap.GetHeight(); y++)
	{
		memcpy( &imagebuffer[y*ddsd.lPitch], 
		        &bitmap.GetImageData()[y*bitmap.GetWidth()*4],
				bitmap.GetWidth()*4 );
		
	}
*/
	//Unlock the surface
	//if(!UnLock(lpddsPrimary))
	//	return(0);
	
	Sprites[0].DrawSprite(lpddsSecondary);
	Sprites[1].DrawSprite(lpddsSecondary);
	Sprites[2].DrawSprite(lpddsSecondary);
	frametime = Frametimer.EndTimerAndRestart();
	//----Output FPS----
	sprintf(buffer,"Render Time= %g",frametime);
	DrawStringGDI(lpddsSecondary,0,0,buffer);
	fps = ((float)frames)/((float)(gametimer.GetStartElapsedTime())*0.001f);
	sprintf(buffer,"FPS= %g",fps);
	DrawStringGDI(lpddsSecondary,0,20,buffer);
	//----End  FPS----

	//Flip primary and secondary surfaces
	Flip();
	return(1);
}
Пример #12
0
bool BEInput::KeyPress(BEKeyBinds key){

    InputState state = UNKNOW_STATE;
    if (forcedData[key].dur > 0){
        state = forcedData[key].key;
        if (state == JUST_PRESSED){
            return true;
        }
    }
    for (auto &it : keyData[key]){
        state = GetKeyStatus(it);
        if (state == JUST_PRESSED){
            return true;
        }
    }
    return false;
}
Пример #13
0
/*------------------------------------------------------------
 * Function Name  : LoadManagerLogin
 * Description    : 加载管理员登录(纯输入密码验证)
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
TestStatus LoadManagerLogin( void )
{	
MANAGER_LOGIN:
	
	/* 初始化 */
	UserLoginInit();
	
	/* GUI */
	GUI_ManagerLogin();
	
	/* 遍历 */
	ShowUserLogin();
	
	while ((GetPage() == USER_LOGIN_PAGE) && (UserLogin.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 数据输入 */
		ManagerLoginPutin(PASSWORD_PUTIN);
		
		/* 上位机警告 */
		UserLogin.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{			
				case KEY_F7:
					strcpy(UserLogin.data[PASSWORD_PUTIN],TypeWriteChar);
	
					if (FAILED == SuperPasswordCheck(UserLogin.data[PASSWORD_PUTIN]))
					{
						SetErr(&GeneralWarning,PCM_ERR,0xff,1,&UserLoginWarn[0]);
						break;
					}
					return PASSED;
				
				case KEY_F8:
					return FAILED;
			}
		}
	}
	
	goto MANAGER_LOGIN;
}
Пример #14
0
//判断按键状态
//enable_shift:ENABLE_SHIFT-允许切换输入法;DISABLE_SHIFT-不允许切换输入法
//返回值:KEY_PRESS_OK-按键按下(短按/长按);KEY_NO_PRESS-按键未按下; KEY_PRESS_NO_LEAVE-按键按下未松开
KEY_STA_TypeDef judge_key_sta(STATUS_SHIFT_TypeDef enable_shift)
{
	pKey->key_status = GetKeyStatus();		//获取按键状态
	judge_shift_sta(enable_shift);	  		//判断按下SHIFT键状态
	judge_data_avail();						//判断按键输入的有效性
	
	if ((STATUS_KEY_SHORT_PRESS==pKey->key_status) || (STATUS_KEY_LONG_PRESS==pKey->key_status))	//短按或长按	
	{			
		#ifdef ENABLE_BEEP
			BEEP_RING_ONE();
		#endif
		
		return KEY_PRESS_OK;			
	}
	else
	{
		return KEY_PRESS_ERROR;
	}
}
Пример #15
0
/*------------------------------------------------------------
 * Function Name  : SelectSaveMediumProcess
 * Description    : 选择保存媒介
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
uint8_t SelectSaveMediumProcess( void )
{			
	LCD_ClearAssistButton(COLOR_BACK);
	
	lcd_show_image(ASSIST_FUNC_POS_X,ASSIST_FUNC_POS1_Y,BUTTON_BACKUP_TO_SD);
	lcd_show_image(ASSIST_FUNC_POS_X,ASSIST_FUNC_POS2_Y,BUTTON_BACKUP_TO_U);
	
	while (1)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F5:
					return BACKUP_SD;
					 
				case KEY_F6:
					return BACKUP_USB;
			}
		}
	}
}
Пример #16
0
/*------------------------------------------------------------
 * Function Name  : LoadSystemRestore
 * Description    : 系统还原
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadSystemRestore( void )
{
	/* 初始化 */
	SystemRestoreInit();
	
	/* GUI界面 */
	GUI_SystemRestore();
	
	/* 遍历 */
	ShowSystemRestore();
	
	while ((GetPage() == SYSTEM_RESTORE_PAGE) && (SystemRestore.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 数据输入 */
		SystemRestorePutin(SystemRestore.now_index);
		
		/* 改变光标 */
		SystemRestoreCursorChange(&SystemRestore.last_index,&SystemRestore.now_index);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* 状态处理 */
		SystemRestoreStatusHandler();
		
		/* USB循环体 */
		LinkUSBCycle();
		
		/* 上位机警告 */
		SystemRestore.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;				
				
				case KEY_F5:
					SystemRestore.Account = (SystemRestore.Account == TEST_CUSTOM) ? MANAGER : TEST_CUSTOM;
					SystemRestore.ExceptionBackOut = ENABLE;
					break;
				
				case KEY_F6:
					if (SystemRestore.Account == MANAGER)
					{
						SystemRestore.now_index++;
						SystemRestore.now_index %= SystemRestore.ParameterNum;
					}
					break;
					
				case KEY_F7:
					SystemRestoreDataExchange(SystemRestore.now_index);
					ShowSystemRestore();
					break;
					
				case KEY_F8:		
					if (SystemRestoreConfirmDataPutin() == ERROR)
					{
						break;
					}
					
					SystemRestoreStart();
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
}
Пример #17
0
/*------------------------------------------------------------
 * Function Name  : LoadMoreParameterSubPage
 * Description    : 加载更多参数子页
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadMoreParameterSubPage( void )
{
	/* 初始化 */
	MoreParameterInit();
	
	/* GUI界面 */
	GUI_MoreParameter();
	
	while (GetPage() == MORE_PARAMETER)
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 索引值判断 */
		ChangeKeyIndex(ENABLE,MoreParameter.ParameterCnt,1,MoreParameter.ParameterCnt,&MoreParameter.now_index);
		
		/* 状态切换 */
		MoreParameterStatusChg();
		
		/* 光标切换 */
		MoreParameterCursorChange(&MoreParameter.last_index,&MoreParameter.now_index);
		
		/* 快速进入页 */
		MoreParameterQuickEnter();
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F7:
					MoreParameterEnterSubPage(MoreParameter.now_index);
					break;
				
				case KEY_F8:
					MoreParameterDrawSeleteGUI(MoreParameter.now_index,DISABLE);
					
					MoreParameterAreaIndexExchange();
					MoreParameterAreaExchange();
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
}
/*------------------------------------------------------------
 * Function Name  : LoadSystemPasswordSet
 * Description    : 加载系统密码设置
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadSystemPasswordSet( void )
{
	/* 初始化 */
	SystemPasswordInit();
	
	/* 获取参数 */
	GetSystemPasswordDateFromFlash(READ_FLASH);
	
	/* GUI界面 */
	GUI_SystemPassword();
	
	while ((GetPage() == SYSTEM_PASSWORD_PAGE) && (SystemPassword.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 索引值改变 */
		ChangeKeyIndex(ENABLE,PARAMETER_NUM,1,PARAMETER_NUM,&SystemPassword.now_index);
		
		/* 改变光标 */
		SystemPasswordCursorChange(&SystemPassword.last_index,&SystemPassword.now_index);
		
		/* 数据输入 */
		SystemPasswordPutin(SystemPassword.now_index);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* 上位机警告 */
		SystemPassword.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F7:
					SystemPasswordEnterData(SystemPassword.now_index);
					break;
				
				case KEY_F8:
					SystemPasswordSave();
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
}
Пример #19
0
//-----------------------------------------------------------------------------
// Name: MoveShip()
// Desc: 
//-----------------------------------------------------------------------------
void MoveShip()
{
	//static float angle = 90.f;
	static int nIndex = Sprites[0].GetCurrentAnimNum();
	static int array[]={0,0};
	static float fDegreeCount = 0;
	static int temp=0, nTimeBetweenFrames=130;
	
	//if(GetKeyStatus(VK_DOWN) == true)
	//{//decelerating
	//	return;
	//}
	if(GetKeyStatus(VK_RIGHT) == true) //increases angle
	{//turns the ship clockwise and changes the angle 10 degrees
	 	fDegreeCount += 7.5f;
		
		if(fabs(fDegreeCount) >= 22.5f)
		{
			Sprites[0].physProp.angle += 22.5f;
			if(Sprites[0].physProp.angle >= 360)
				Sprites[0].physProp.angle = Sprites[0].physProp.angle-360;
			nIndex++;
			if( nIndex > 15 )
				nIndex = 0;
			
			if(nIndex>7)
				temp = nIndex+8;
			else
				temp = nIndex;
			array[0] = temp; array[1] = temp;
			Sprites[0].SetAnimations(array,1,SPRITE_ANIM_ONCE,16);
			Sprites[0].SetCurrentAnim(16);
			
			fDegreeCount=0;
		}
	}
	else
		if(GetKeyStatus(VK_LEFT) == true) //decreases angle
		{//turns the ship counter-clockwise and changes the angle
			fDegreeCount -= 7.5f;
		
			if(fabs(fDegreeCount) >= 22.5f)
			{
				Sprites[0].physProp.angle -= 22.5f;
				if(Sprites[0].physProp.angle <= 0)
					Sprites[0].physProp.angle = (360+Sprites[0].physProp.angle);
	
				nIndex--;
				if(nIndex < 0)
					nIndex = 15;
			
				if(nIndex>7)
					temp = nIndex+8;
				else
					temp = nIndex;
				array[0] = temp; array[1] = temp;
				Sprites[0].SetAnimations(array,1,SPRITE_ANIM_ONCE,16);
				Sprites[0].SetCurrentAnim(16);

				fDegreeCount=0;
			}
	}
	
	if(GetKeyStatus(VK_UP) == true)
	{//accelerating
		static float accel=0;
		accel = 1; //1 pixel/s^s
		Sprites[0].physProp.VelVector.x += accel*fFrameTime;
		Sprites[0].physProp.VelVector.y = 0;
		if(Sprites[0].physProp.VelVector.x > VEL_CAP)
			Sprites[0].physProp.VelVector.x = VEL_CAP;
		if(Sprites[0].physProp.VelVector.x < -VEL_CAP)
			Sprites[0].physProp.VelVector.x = -VEL_CAP;
		if(Sprites[0].physProp.VelVector.y > VEL_CAP)
			Sprites[0].physProp.VelVector.y = VEL_CAP;
		if(Sprites[0].physProp.VelVector.y < -VEL_CAP)
			Sprites[0].physProp.VelVector.y = -VEL_CAP;
		nTimeBetweenFrames-=5;
		if(nTimeBetweenFrames < 30)
			nTimeBetweenFrames=30;
		Sprites[0].SetTimeBetweenFrames(nTimeBetweenFrames);
		Sprites[0].SetCurrentAnim(nIndex);
	}
	else
	{
		if(nIndex>7)
			temp = nIndex+8;
		else
			temp = nIndex;
		
		array[0] = temp; array[1] = temp;
		Sprites[0].SetAnimations(array,1,SPRITE_ANIM_ONCE,16);
		Sprites[0].SetCurrentAnim(16);
		nTimeBetweenFrames=130;
	}

	//----Debug info----
	if(bDebugMode)
	{
		sprintf(cpErrorBuf,"Angle= %g",Sprites[0].physProp.angle);
		DrawStringGDI(lpddsSecondary,100,60,cpErrorBuf);
		sprintf(cpErrorBuf,"Temp Index= %d",temp);
		DrawStringGDI(lpddsSecondary,100,75,cpErrorBuf);
		sprintf(cpErrorBuf,"Ship index= %d", nIndex);
		DrawStringGDI(lpddsSecondary,130,135,cpErrorBuf);
		sprintf(cpErrorBuf,"AnimationSeqMax()= %d", Sprites[0].GetAnimSeqMax(Sprites[0].GetCurrentAnimNum())+1);
		DrawStringGDI(lpddsSecondary,130,150,cpErrorBuf);
	}
	//----End Debug info----
}
Пример #20
0
void SetTime()
{
	

	uint8_t hr,min,sec,am_pm,temp;

	//Read the Second Register
	DS1307Read(0x00,&temp);
	sec=(((temp & 0b01110000)>>4)*10)+(temp & 0b00001111);

	//Read the Minute Register
	DS1307Read(0x01,&temp);
	min=(((temp & 0b01110000)>>4)*10)+(temp & 0b00001111);

	//Read the Hour Register
	DS1307Read(0x02,&temp);
	hr=(((temp & 0b00010000)>>4)*10)+(temp & 0b00001111);

	am_pm=(temp & 0b00100000)>>4;

	//If Hour Register is 0 make it 12, as 00:00:00 invalid time
	if(hr==0) hr=12;

	uint8_t sel=0;

	while(1)
	{
		LCDClear();

		LCDWriteString("00:00:00    <OK>");
		
		LCDWriteIntXY(0,0,hr,2);
		LCDWriteIntXY(3,0,min,2);
		LCDWriteIntXY(6,0,sec,2);

		if(am_pm)
		{
			LCDWriteStringXY(9,0,"PM");
		}
		else
		{
			LCDWriteStringXY(9,0,"AM");
		}

		//Draw Pointer
		LCDWriteStringXY(sel*3,1,"^^");

		//Input Up key
		if(GetKeyStatus(1))
		{
			if(!GetPrevKeyStatus(1))
			{
				if(sel==0)
				{	
					//Hour
					if(hr==12)
					{
						hr=1;
					}
					else
					{
						hr++;
					}
				}

				if(sel==1)
				{	
					//Min
					if(min==59)
					{
						min=0;
					}
					else
					{
						min++;
					}
				}

				if(sel==2)
				{	
					//Sec
					if(sec==59)
					{
						sec=0;
					}
					else
					{
						sec++;
					}
				}

				if(sel==3)
				{	
					//AM-PM
					if(am_pm==0)
					{
						am_pm=1;
					}
					else
					{
						am_pm=0;
					}
				}
				if(sel == 4)
				{
					//OK
					break;
				}
			}
		}

		//Input Down
		if(GetKeyStatus(0))
		{
			if(!GetPrevKeyStatus(0))
			{
				if(sel==0)
				{	
					//Hour
					if(hr==1)
					{
						hr=12;
					}
					else
					{
						hr--;
					}
				}

				if(sel==1)
				{	
					//Min
					if(min==0)
					{
						min=59;
					}
					else
					{
						min--;
					}
				}

				if(sel==2)
				{	
					//Sec
					if(sec==0)
					{
						sec=59;
					}
					else
					{
						sec--;
					}
				}

				if(sel==3)
				{	
					//AM-PM
					if(am_pm==0)
					{
						am_pm=1;
					}
					else
					{
						am_pm=0;
					}
				}
				if(sel == 4)
				{
					//OK
					break;
				}
			}
		}

		if(GetKeyStatus(2))
		{
			if(!GetPrevKeyStatus(2))
			{
				//Change Selection
				if(sel==4)
					sel=0;
				else
					sel++;
			}
		}

		PREV_PINB=PINB;

		_delay_loop_2(30000);

	}

	//Now write time back to RTC Module
	temp=((sec/10)<<4)|(sec%10);
	DS1307Write(0x00,temp);

	temp=((min/10)<<4)|(min%10);
	DS1307Write(0x01,temp);

	temp=((hr/10)<<4)|(hr%10);
	temp|=0b01000000; //12 Hr Mode
	if(am_pm)
	{
		temp|=0b00100000;
	}
	DS1307Write(0x02,temp);

	LCDClear();
	LCDWriteString("Message !");
	LCDWriteStringXY(0,1,"Main Time Set");

	uint8_t i;
	for(i=0;i<10;i++)
		_delay_loop_2(0);




}
Пример #21
0
/*------------------------------------------------------------
 * Function Name  : LoadSoftActiveSet
 * Description    : 加载软件激活设置
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadSoftActiveSet( void )
{
	/* 初始化 */
	SoftActiveInit();
	
	/* 获取数据 */
	GetSoftActiveDateFromFlash(READ_FLASH);
	
	/* GUI界面 */
	GUI_SoftActive();
	
	/* 遍历 */
	Traverse_SoftActive();
	
	while ((GetPage() == SOFT_ACTIVE_PAGE) && (SoftActive.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 索引值改变 */
		SoftActiveChangeIndex(&SoftActive.now_index);
		
		/* 数据输入 */
		SoftActivePutin(SoftActive.now_index);
		
		/* 改变光标 */
		SoftActiveCursorChange(&SoftActive.last_index,&SoftActive.now_index);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* 上位机警告 */
		SoftActive.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F5:
					if (SystemPasswordCheck(SoftActive.data[PUTIN_PASSWORD]) == PASSED)
					{
						GetSoftActiveDateFromFlash(WRITE_FLASH);
						
						SetErr(&GeneralWarning,PCM_ERR,0xff,1,&ActiveStatusWarn[7]);
					}
					else
					{
						SetErr(&GeneralWarning,PCM_ERR,0xff,1,&ActiveStatusWarn[6]);
					}
					break;
				
				case KEY_F7:
					SoftActiveEnterData(SoftActive.now_index);
					break;
				
				case KEY_F8:
					ProdectActiveCheck(SoftActive.data[PUTIN_PASSWORD]);
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
}
Пример #22
0
void main()
{
	//Wait Util Other device startup
	_delay_loop_2(0);
	_delay_loop_2(0);

	//Initialize the LCD Module
	LCDInit(LS_BLINK);

	//Initialize I2C Bus
	I2CInit();

	//Enable Pull ups on keys
	PORTB|=((1<<PB2)|(1<<PB1)|(1<<PB0));

	//Clear CH bit of RTC
	#define CH 7

	uint8_t temp;
	DS1307Read(0x00,&temp);

	//Clear CH Bit
	temp&=(~(1<<CH));

	DS1307Write(0x00,temp);

	//Set 12 Hour Mode
	DS1307Read(0x02,&temp);

	//Set 12Hour BIT
	temp|=(0b01000000);

	//Write Back to DS1307
	DS1307Write(0x02,temp);

	
	LCDClear();
	
	LCDWriteString("DS1307 RTC Exmple");
	
	char Time[12];	//hh:mm:ss AM/PM
	
	//Now Read and format time
	uint8_t data;
	
	while(1)
	{
		
		DS1307Read(0x00,&data);
		Time[8]='\0';
		Time[7]=48+(data & 0b00001111);
		Time[6]=48+((data & 0b01110000)>>4);
		Time[5]=':';
	
		DS1307Read(0x01,&data);
	
		Time[4]=48+(data & 0b00001111);
		Time[3]=48+((data & 0b01110000)>>4);
		Time[2]=':';
	
		DS1307Read(0x02,&data);
	
		Time[1]=48+(data & 0b00001111);
		Time[0]=48+((data & 0b00010000)>>4);

		LCDClear();
	
		LCDWriteString("DS1307 RTC Exmple");
	
		LCDWriteStringXY(2,1,Time);

		//AM/PM
		if(data & 0b00100000)
		{
			LCDWriteStringXY(11,1,"PM");
		}
		else
		{
			LCDWriteStringXY(11,1,"AM");
		}

		//Wait Some time and keep testing key input
		uint8_t i;
		for(i=0;i<20;i++)
		{
		
			if(GetKeyStatus(2))
			{
				//Go To Main Menu
				ShowMainMenu();

				_delay_loop_2(0);
				_delay_loop_2(0);
				_delay_loop_2(0);

			}
			_delay_loop_2(5000);
		}
	}
	

	
}
Пример #23
0
void ShowMainMenu()
{
	//The Main Menu
	char *menu_items[]={ 	"Set Time",
							"Set On Time",
							"Set Off Time",
							"Quit"
						};
	uint8_t menu_count=4;
	uint8_t selected=0;

	_delay_loop_2(0);
	_delay_loop_2(0);

	while(1)
	{
		LCDClear();
		LCDWriteString("    Main Menu  ");

		LCDWriteStringXY(2,1,menu_items[selected]);

		LCDWriteStringXY(0,1,"<");
		LCDWriteStringXY(15,1,">");

		if(GetKeyStatus(1))
		{
			//Left Key(No 1) is pressed
			//Check that it was not pressed previously
			if(!GetPrevKeyStatus(1))
			{
				if(selected !=0)
					selected--;
			}
		}

		if(GetKeyStatus(0))
		{
			//Right Key(No 0) is pressed
			//Check that it was not pressed previously
			if(!GetPrevKeyStatus(0))
			{
				if(selected !=(menu_count-1))
					selected++;
			}
		}

		if(GetKeyStatus(2))
		{
			//Enter Key Pressed
			//Check that it was not pressed previously
			if(!GetPrevKeyStatus(2))
			{
				//Call Appropriate Function
				switch (selected)
				{
					case 0:
						SetTime();
						break;
					case 1:
						//SetOnTime();
						break;

					case 2:
						//SetOffTime();
						break;

					case 3:
						return;//Quit
				}
				
			}
		}

		PREV_PINB=PINB;

		_delay_loop_2(5000);
	}
}
Пример #24
0
////FUNCTIONS//////////////////
//-----------------------------------------------------------------------------
// Name: Main()
// Desc: Whwere all work is done
//-----------------------------------------------------------------------------
bool main()
{
    static SCCOLOR col;
    static UCHAR* back_buf;
    static HDC hDC;
    static int iFrames=0;
    static int x=0;

    col.b = col.r = col.g = 255;

    if(GetKeyStatus(VK_ESCAPE) == true)
        return(0);

    //Clear the surface
    if(!ClrS(lpddsSecondary,wndRect))//can't be within a lock-Unlock block or u can't blt
        return(0);

    //Write text to the Secondary surface remember to Release the DC
    ddReturnVal = lpddsSecondary->GetDC(&hDC);
    if (DDFailedCheck(ddReturnVal, "GetDC() failed", cpErrorBuf ))
    {
        if(ddReturnVal == DDERR_SURFACELOST)
        {
            lpddsSecondary->Restore();
            lpddsSecondary->GetDC(&hDC);
        }
        else
        {
            MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
            return(0);
        }
    }

    static char buffer[1024];
    SetBkColor(hDC,RGB(0,0,0));
    SetBkMode(hDC,OPAQUE);
    sprintf(buffer, "Time elapsed(s)= %d", (int)(gametimer.GetStartElapsedTime()*0.001) );//0.00001666666f
    static DWORD starttime=GetTickCount();
    if( gametimer.Elapsed(starttime,(60/0.001)) )
        sprintf(buffer,"TIME!"," 1 minute");
    SetTextColor(hDC,RGB(255,255,255));
    iFrames++;
    static int FramesPerSec=0;
    FramesPerSec = iFrames/( ((int)(gametimer.GetStartElapsedTime()*0.001)+1) );
    sprintf(buffer, "Frames/s = %d", FramesPerSec);
    TextOut(hDC, 100,100, buffer, strlen(buffer));

    sprintf(buffer, "X= %d", x);
    TextOut(hDC, 100,140, buffer, strlen(buffer));
    ddReturnVal = lpddsSecondary->ReleaseDC(hDC);
    if (DDFailedCheck(ddReturnVal, "ReleaseDC() failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
        return(0);
    }

    //Lock the surface for drawing
    if(!Lock(lpddsSecondary))
        return(0);

    back_buf = (UCHAR*)ddsd.lpSurface;

    //test drawing pixels
    DrawPixel(ddsd,x+200,100,col);
    DrawPixel(ddsd,x+200,101,col);
    DrawPixel(ddsd,x+200,102,col);
    DrawPixel(ddsd,x+200,103,col);
    DrawPixel(ddsd,x+200,104,col);
    DrawPixel(ddsd,x+200,105,col);
    DrawPixel(ddsd,x+200,106,col);
    DrawPixel(ddsd,x+200,107,col);
    DrawPixel(ddsd,x+200,108,col);
    x++;
    if(x>780)
        x=0;

    //test bitmap class
    for (int y=0; y < bitmap1.GetHeight(); y++)
    {
        // copy the line
        memcpy(&back_buf[100+(y+200)*ddsd.lPitch], // dest address
               &bitmap1.GetImageData()[y*bitmap1.GetWidth()*2],   // src address
               bitmap1.GetWidth()*2);                         // bytes to copy
    } // end for y

    //Unlock the surface
    if(!UnLock(lpddsSecondary))
        return(0);

    if(!Lock(Temp))
        return(0);
    back_buf = (UCHAR*)ddsd.lpSurface;
    for (int y=0; y < bitmap2.GetHeight(); y++)
    {
        // copy the line
        memcpy(&back_buf[y*ddsd.lPitch], // dest address
               &bitmap2.GetImageData()[y*bitmap2.GetWidth()*2],   // src address
               bitmap2.GetWidth()*2);                         // bytes to copy
    } // end for y
    if(!UnLock(Temp))
        return(0);
    static RECT temprect= {200,200,520,400};
    static RECT sorc_rect= {0,0,320,200};
    ddReturnVal = lpddsSecondary->Blt(&temprect/*dest rect*/,Temp, //pointer to source surface
                                      &sorc_rect, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }


    static RECT temprect2;
    temprect2.top=200;
    temprect2.left=500;
    temprect2.right=sprite.GetWidth()+500;
    temprect2.bottom=sprite.GetHeight()+200;
    static int i=0;
    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,sprite.GetFrame(i), //pointer to source surface
                                      NULL, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }
    static DWORD start = GetTickCount();
    if(gametimer.Elapsed(start,120))
    {
        i++;
        start = GetTickCount();
    }
    if(i>13)
        i=0;

    static int size=0;
    temprect2.top=500+size;
    temprect2.left=300+size;
    temprect2.bottom=500+myface.GetWidth()+size;
    temprect2.right=300+myface.GetWidth()+size;
    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,myface.GetFrame(0), //pointer to source surface
                                      NULL, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    static int what=0;
    what++;
    size= sin(what)+cos(what+5);

    static int j=0;
    static DWORD start2=GetTickCount();
    if(gametimer.Elapsed(start2,50))
    {
        j++;
        start2=GetTickCount();
    }
    if(j>=3)j=0;
    temprect2.top=500;
    temprect2.left=100;
    temprect2.bottom=500+ship.GetHeight();
    temprect2.right=100+ship.GetWidth();
    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,ship.GetFrame(j), //pointer to source surface
                                      NULL, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    temprect2.top=400;
    temprect2.left=500;
    temprect2.bottom=400+recttest.GetHeight()+50;
    temprect2.right=500+recttest.GetWidth()+50;

    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,recttest.GetFrame(0), //pointer to source surface
                                      &recttest.GetRect(), //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    temprect2.top=485;
    temprect2.left=160;
    temprect2.bottom=485+ship2.GetHeight();
    temprect2.right=160+ship2.GetWidth();
    static int k=0;
    static DWORD start3;
    if(gametimer.Elapsed(start3,0))
    {
        k++;
        start3=GetTickCount();
    }
    if(k>=11)k=0;

    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,ship2.GetFrame(0), //pointer to source surface
                                      &ship2.GetRect(), //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    Flip();

    return(1);
}
Пример #25
0
/*------------------------------------------------------------
 * Function Name  : LoadUserLogin
 * Description    : 加载用户登录
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadUserLogin( void )
{
	if (GetManageModeStatus() == SUCCESS)
	{
		SetPage(MANAGE_MODE_PAGE);
		
		return;
	}
	
	/* 初始化 */
	UserLoginInit();
	
	/* GUI */
	GUI_UserLogin();
	
	/* 遍历 */
	ShowUserLogin();
	
	while ((GetPage() == USER_LOGIN_PAGE) && (UserLogin.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 数据输入 */
		UserLoginPutin(PASSWORD_PUTIN);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* 上位机警告 */
		UserLogin.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F8:
					UserLoginTryLogin();
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
}
Пример #26
0
/*------------------------------------------------------------
 * Function Name  : LoadSystemBackup
 * Description    : 系统备份
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadSystemBackup( void )
{
	/* 初始化 */
	SystemBackupInit();
	
	/* GUI界面 */
	GUI_SystemBackup();
	
	/* 遍历 */
	ShowSystemBackup();
	
	while ((GetPage() == SYSTEM_BACKUP_PAGE) && (SystemBackup.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 数据输入 */
		SystemBackupPutin(PASSWORD_PUTIN);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* USB循环体 */
		LinkUSBCycle();
		
		/* 上位机警告 */
		SystemBackup.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F8:
					SystemBackupStartBackUp();
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
}
Пример #27
0
/*------------------------------------------------------------
 * Function Name  : LoadPidAndCalibrationTable
 * Description    : PID、标定表
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadPidAndCalibrationTable( void )
{
	/* 初始化 */
	PidCalibrationInit();
	
	/* 从FLASH获取参数 */
	PIDCalibrationFromFlashGetParameter(READ_FLASH,PidCalibration.ch,PidCalibration.ture_ch);

	/* GUI界面 */
	GUI_PidCalibration();
	
	/* 遍历 */
	Traverse_PidCalibration();
	
	while ((GetPage() == PID_CALIBRATION) && (PidCalibration.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 索引值改变 */
		PidCalibrationIndexMove();
		
		/* 数据输入 */
		PidCalibrationPutin(PidCalibration.now_index);
		
		/* 光标移动 */
		PidCalibrationCursorChange(&PidCalibration.last_index,&PidCalibration.now_index);	
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* 上位机警告 */
		PidCalibration.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					if (PASSED == PidCalibrationCheckData() )
					{											
						SetPage(CONTROL_PARAMETER);
					}
					else
					{
						PidCalibration.now_index = 0;
					}
					break;
				
				case KEY_F2:
					PIDCalibrationLoadDefaultButton();
					PidCalibrationDrawSeleteGUI(PidCalibration.now_index,DISABLE);	
				
					PidCalibrationAreaIndexExchange();
					PidCalibrationAreaExchange();
					break;
				
				case KEY_F3:
					if (PASSED == PidCalibrationCheckData() )
					{
						SetPage(MORE_PARAMETER);
					}
					else
					{
						PidCalibration.now_index = 0;
					}
					
					break;
				
				case KEY_F4:
					if (PASSED == PidCalibrationCheckData() )
					{
						SetPage(MAIN_PAGE);
					}
					else
					{
						PidCalibration.now_index = 0;
					}						
					break;
				
				case KEY_F7:
					PidCalibrationEnterData(PidCalibration.now_index);
					break;
				
				case KEY_F8:
					PidCalibrationEscData(PidCalibration.now_index);					
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
				
				case KEY_SET:
					PidCalibrationPrint();
					break;
			}
		}
	}
	
	PidCalibrationSaveData();
}
/*------------------------------------------------------------
 * Function Name  : LoadOnlineParameterSet
 * Description    : 加载联机参数设置
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void LoadOnlineParameterSet( void )
{
	/* 初始化 */
	OnlineParameterInit();
	
	/* 获取参数 */
	GetOnlineParameterDateFromFlash(READ_FLASH);
	
	/* GUI界面 */
	GUI_OnlineParameter();
	
	/* 遍历 */
	Traverse_OnlineParameter();
		
	while ((GetPage() == ONLINE_PARAMETER_PAGE) && (OnlineParameter.ExceptionBackOut == DISABLE))
	{
		pKey->key_sta = GetKeyStatus(DISABLE_SHIFT);
		
		/* 数据输入 */
		OnlineParameterPutin(OnlineParameter.now_index);
		
		/* 索引值改变 */
		ChangeKeyIndex(ENABLE,PARAMETER_NUM,1,PARAMETER_NUM,&OnlineParameter.now_index);
		
		/* 改变光标 */
		OnlineParameterCursorChange(&OnlineParameter.last_index,&OnlineParameter.now_index);
		
		/* 虚拟按键显示 */
		DummyKey.Key = GeneralKeyShow(ENABLE);
		
		/* 虚拟按键恢复默认 */
		DummyKey.Check = DummyKeyClose();
		
		/* 上位机警告 */
		OnlineParameter.ExceptionBackOut = PCM_GeneralWarningHandlerProcess(COLOR_BACK);
		
		if ( pKey->key_sta == KEY_PRESS_OK)
		{
			switch ( pKey->key_value )
			{
				case KEY_F1:
					SetPage(CONTROL_PARAMETER);
					break;
				
				case KEY_F2:
					SetPage(PID_CALIBRATION);
					break;
				
				case KEY_F3:
					SetPage(MORE_PARAMETER);
					break;
				
				case KEY_F4:
					SetPage(MAIN_PAGE);
					break;
				
				case KEY_F7:
					OnlineParameterEnterData(OnlineParameter.now_index);
					break;
				
				case KEY_F8:
					OnlineParameterEscData(OnlineParameter.now_index);
					break;
				
				case KEY_CALI:
					SetPage(FORCE_CALIBRATION);
					break;
			}
		}
	}
	
	OnlineParameterSave();
}