I have a library on Arduino that declares a function like this :
void Keypad::waitPress()
// Wait for any key to be pressed.
{ while (scan() == 0);
}
Which, for one conditional is fine, but I also have an ISR (interrupt system routine) in my main code which will likely be triggered during the waitPress() call :
static void isr_zero(void) {
if (isr_change_flag == 0)
{
isr_dest = 0;
isr_change_flag = 1;
}
}
Since Keypad::waitPress is a loop, it won't care if the ISR is triggered and will continue looping indefinitely until a key is pressed, which is an undesireable behaviour as I need that ISR to act there
Is there a way to break that while loop if the ISR is triggered?
- I can't modify a single line of the library
scan()isn't apublicfunction so I can't just rewritewaitPress()(which would have been the easiest)gotowould have worked if it hadn't function-only scope
I thank about calling the processing function from the ISR, but I know that that's not good practice to hook a long running function within an ISR, although that would technically work
Reading through the
.hfile, I found that the class actually exported a functor that got me a view of the component outputI was able to implement it and my code now works