using enum in switch()

Posted 2012.02.14 12:38

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
using enum in switch()  (0) 2012.02.14
implementing function in 'struct' using C language(not C++)  (0) 2012.02.07
Listbox control 사용하기  (0) 2011.12.30
synchronization문제  (0) 2011.11.25
« PREV : 1 : ··· : 14 : 15 : 16 : 17 : 18 : 19 : 20 : 21 : 22 : ··· : 37 : NEXT »