while (1)
{
c = getchar();
switch(state)
{
case 0:
if((GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == Bit_SET))
{
state=1;
}
if ( c=='p')
{
state = 2;
}
break;
case 1 :
if((GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) != Bit_SET))
{
state = 0;
}
break;
case 2:
iprintf("%s",led_name_arr[i]);
if (c=='r')
{
state=0;
}
break;
}
}
I want to print the printf and then reach state2 .. how can this be achieved .below is what i have tried and where i am stuck .
psuedocode:
if ( c==P)
{
printf(" hi");
state 2;
}
** in this case the printf statement does not get executed **
or
case 2:
iprintf("%s",led_name_arr[i]);
if (c=='r')
{
state=0;
}
break;
** in this case the printf statement keeps printing in a loop **
i dont want the while loop to stop , in a continuous loop i want case 0 keeps working , but when it get the input p .. it pauses and executes the printf … and waits till it gets a r to resume case 0 …. Thus the program never halts but waits to either get “P” or “R” to execute each case… I hope i make sense
Any help will be appreciated .
i am not sure what you are asking but i m pretty sure what you want in case 2 is something like this: