How to change this function in to a non-blocking function?
make buffer[] and i static.
get rid of the while() loop.


Like this:

int getTheNumber()
{
    static char buffer[4];
    static int i=0;
    // Input up to 3 numbers until we find a * or #
    char key = keypad.getKey();

    // If it's a number AND we have space left, add to our string
    if ('0' &lt;= key &amp;&amp; key &lt;= '9' &amp;&amp; i &lt; 3)
        {
            buffer[i] = key;
            i++; 
            return(-1)       
        }
        // If it's a * or #, end
    else if ('#' == key &amp;&amp; i &gt; 0)
        {
            // Null terminate
            buffer[i] =0; 
            int value = atoi(buffer);
            i=0;
            return atoi(buffer);
        }        
}