Hi Gents,
Have encountered Compilation error: jump to label 'Bailout' [-fpermissive] on the below code.
Any ideas how I can do this differently perhaps..?
void readChannelA()
{
// Keep track of when we were here last (no more than every 5ms)
if (InterruptCNT > 10)
{goto ReadENC ;}
else
{goto Bailout ;}
ReadENC:
int interruptCNT = 0; // Quadrature incremental encoder
if (digitalRead(2) == LOW)
EncoderCNT ++; // Clockwise
else
EncoderCNT --; // Anti-clockwise
Bailout: int interruptCNT ++;
}
avoid using goto it leads to unstructured code which is difficult to read
is this what you require?
void readChannelA()
{
// Keep track of when we were here last (no more than every 5ms)
if (InterruptCNT > 10) {
int interruptCNT = 0; // Quadrature incremental encoder
if (digitalRead(2) == LOW)
EncoderCNT++; // Clockwise
else
EncoderCNT--; // Anti-clockwise
} else
int interruptCNT++;
}
Yes this looks like it will work..thanks for the quick reply...cheers
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.