I have wrote the following:
if (PA!=NAPA)
{
switch(NAPA)
{
case 0x00:
switch (PA) //check last state
{
case 0x02:myvolume++; break;
case 0x01:myvolume--; break;
}
break;
case 0x01:
switch (PA)
{
case 0x00:myvolume++; break;
case 0x03:myvolume--; break;
}
break;
case 0x03:
switch (PA)
{
case 0x01:myvolume++; break;
case 0x02:myvolume--; break;
}
break;
case 0x02:
switch (PA)
{
case 0x03: myvolume++; break;
case 0x00: myvolume--; break;
}
default:break;
}
}
My question is, is it possible to combine multiple cases somehow, like:
case 0x00 OR case 0x01, if I could do something like this I could reduce it further.
This is a routine to detect the direction of a greyscale(or Manchester) encoder and change the volume accordingly.