[EDIT - SOLVED]
Finally got home this morning and I took the code apart a bit more.
For those that read this post I found a solution to the problem below.
the waitForKey() function does trigger the keypad event listener.
char Keypad::waitForKey() {
char waitKey = NO_KEY;
while( (waitKey = getKey()) == NO_KEY ); // Block everything while waiting for a keypress.
return waitKey;
The function actually calls the getKey() function and that function triggers the keypad event listener.
Depending on your code you may have to make and play around with a debounce so you don't spam the function. My results were kinda wonky with how my whole program is set up.
Cheers to all that helped and good luck to those that had the same question as me,
Andrew
[END EDIT]
Good afternoon everyone,
I am using a keypad in some code that I am writing and I am using an event listener to decide
what to do when keys are pressed. I need to have one function wait for a key press. I see a function waitForKey that returns the char. Does this function also trigger the keypad eventlistner? Here are the options I believe that I have:
If the function does not call the event should I some how convert the char to a KeypadEvent.
or
Should I save the char and pass it into an overloaded keypadEvent function like so:
//declare
void keypadEvent(char extrnKey);
then call keypadEnven(keypad.waitForKey());
or will that cause me problems down the line that you know of.
or should I save the menu keys that I am wanting in global variables?
or should I cut out the wait for key option and try something like:
if(keypad.getState() == PRESSED)
{
keypad.getKey() //to trigger the event listener
}
else
{
//recursively call this function
mainMenu();
//Which I belive will cause flicker because I am using an LCD to display the menu
}
Is there a decent way to handle this that you know of?
I am using 1.0.5 r2 IDE and I am using an UNO board.
Thank you any and all that offer information. I hope to one day be the one answering the tough questions here,
Andrew