keypad Library - waitForKey() advice (SOLVED)

[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

Does this function also trigger the keypad eventlistner?

It would have taken less time to test than to type the question.

If the function does not call the event should I some how convert the char to a KeypadEvent.

If you think you can...

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());

You want to call keypat.waitForKey() after you have a key? Well, OK.

   //recursively call this function
   mainMenu();

You almost certainly do not want to recursively call that function.

PaulS:
It would have taken less time to test than to type the question.

I was on a phone when I typed it out. Did not have a way to test it. I am out of state for work.

PaulS:
If you think you can...

Did not know if I could I have not really been able to dig into the library's code yet. If I knew these answers I would not be seeking the communities wisdom. I figured someone with as high a rating and as many posts as you would be able to sympathize with that. I do not know how the programmer handled the Keypad Event in the library.

PaulS:
You want to call keypat.waitForKey() after you have a key? Well, OK.

void keypadEvent(char extrnKey); would be a function. And I would call it and pass it the char from the waitForKey return character.

Barring the tone of condescension of your responses, you were helpful. This is completely different beast than the type of programming that I am used to. I do not fully understand the limitations and abilities of this clever little chip. Through this community I know that I will have a great opportunity to grow, so I thank you PaulS for your support and knowledge.

It sounds to me like (assuming when I test the "does the function activate the listener" that it does not work) that making a different function (void keypadEvent(char extrnKey)) and just passing in the wait for key response is my only choice. Does this sound like I viable option? Or do you think I am looking into some trouble with it? Based on your response it sounds like you know this library quite well. Am I looking at any conflict with keypad listener bit? This is the only time that I absolutely have to wait for a key press and record it.

Maybe a while loop could fit into this. Make sure that a valid digit is entered before it continues the code. I am just trowing some thoughts out there. I know that resources are limited on these little guys. I am trying to keep that in mind.

PaulS:
You almost certainly do not want to recursively call that function.

Why specifically do you believe that calling the mainmenu function recursively is a bad idea? minus the flickering that would occur on the lcd, which I am sure I could fix prevent.

Anymore thoughts to add to this PaulS, or anyone else?

agluck:
Why specifically do you believe that calling the mainmenu function recursively is a bad idea? minus the flickering that would occur on the lcd, which I am sure I could fix prevent.

I didn't look at the mainmenu function. But in general, recursion is not a good idea on the Arduino because the limited RAM means that stack space is at a premium.

aarg:
I didn't look at the mainmenu function. But in general, recursion is not a good idea on the Arduino because the limited RAM means that stack space is at a premium.

Thank you aarg, I did not post it so do not worry. I was thinking that was the case, but wanted to be sure it was not a deeper problem. These boards are still really exceptional considering their limitations.