Beispiel #1
0
inline void BiMotor::Rotate(
    MTMovDir_enum Direction,
    uint8_t Angle,            // the unit is 10 degree
    MTSpeed_enum Speed
)
{
    MTSingleAct_enum Action;
    uint8_t i;
    //check para


    if ( MT_CLOCKRANDOM == Direction )
    {
        randomSeed(millis());
        Direction = (0 == random(2)) ? MT_CLOCKWISE : MT_ANTICLOCK;
    }

    if ( ANGLE_RANDOM == Angle )
    {
        Angle = random(5);
    }

    if ( 0 == Angle )
    {
        return;
    }

    /*set dirction*/
    switch(Direction)
    {
    case MT_CLOCKWISE:
        SetSingleMotorAction( MOTOR_INDEX_L, MT_ACTION_FORWORD);
        SetSingleMotorAction( MOTOR_INDEX_R, MT_ACTION_BACKWORD);
        break;

    case MT_ANTICLOCK:
        SetSingleMotorAction( MOTOR_INDEX_L, MT_ACTION_BACKWORD);
        SetSingleMotorAction( MOTOR_INDEX_R, MT_ACTION_FORWORD);
        break;

    default:
        ; //error

    }

    /** RunCnt must be set before SpeedVal**/
    SetRotateAngle(Angle);
    SetSpeed(Speed);

    Run();
}
void CRotateDispWnd::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	KillTimer(1);
	ShowWindow(SW_MINIMIZE);
	ShowWindow(SW_HIDE);
	if(IsMouseDllOk)
	{
		SetRotate(FALSE);

		switch(RotNum)
		{
			case ANG_90:
				SetRotateAngle(90);
				break;

			case ANG_180:
				SetRotateAngle(180);
				break;

			case ANG_270:
				SetRotateAngle(270);
				break;
			
			default:
				goto path1;
		}
		SetRotate(TRUE);
	}
path1:
	ChangeDispById(RotNum&3);
	if(PathFileExists("RotateDisp.vbs"))
	{
		char param=(RotNum&3)+'0';
		ShellExecute(NULL,"open","RotateDisp.vbs",&param,NULL,SW_SHOWNORMAL);
	}
	CWnd::OnTimer(nIDEvent);
}