본문 바로가기

Enginius/C / C++

using enum in switch()


void test1(void)
{
typedef enum  
{_IDLE, _FORWARD, _RIGHT, _LEFT }
MOVE_STEP;
unsigned char suction_flag = 0, rmc;
MOVE_STEP  step = _IDLE;
Initialize_AccSlipCheck();
while(1)
{
AccSlipCheck();


rmc = GetRemocon();
switch(rmc)
{
case RMC_STOP:
step = _IDLE;
break;
case RMC_FORWARD:
step = _FORWARD;
break;
case RMC_RIGHT:
step = _RIGHT;
break;
case RMC_LEFT:
step = _LEFT;
break;
case RMC_BLOWUP:
suction_flag = 1;
break;
case RMC_BLOWDOWN:
suction_flag = 0;
break;
}
switch(step)
{
case _IDLE:
DriveStop();
break;
case _FORWARD:
DriveVelocity(25.0, 0.0);
break;
case _RIGHT:
DriveVelocity(0.0, -25.0);
break;
case _LEFT:
DriveVelocity(0.0, 25.0);
break;
}

if(suction_flag)
SuctionMotor(SUCTION_HIGH);
else
SuctionMotor(SUCTION_STOP);
}
}

'Enginius > C / C++' 카테고리의 다른 글

linked list class  (0) 2012.03.23
Variance Estimator  (0) 2012.02.19
implementing function in 'struct' using C language(not C++)  (0) 2012.02.07
Listbox control 사용하기  (0) 2011.12.30
synchronization문제  (0) 2011.11.25