3 years, 11 months ago.

Custom Keypad Configurations

I have combed through the header and cpp files for this library. At line 97 of the header file there is a comment, "Allows custom keymap, pin configuration, and keypad sizes", does this function allow for actual configuration of keymaps larger than 4x4?

My code currently:

char keys[ 5 ][ 5 ] =
 {
     {'1','2','3','A'},
     {'4','5','6','B'},
     {'7','8','9','C'},
     {'*','0','#','D'},
     {'Q','W','E','R'}
  };
  
  DigitalInOut rowPins[ 5 ] = {P2_11, P2_12, P2_13, P2_14, P1_1};   //LPC11U68 
  DigitalInOut colPins[ 4 ] = {P1_26, P2_2, P1_27, P1_4};

  Keypad kpd( makeKeymap( keys ), rowPins, colPins, 5, 4 );

int main(){

while(1) {
        if( kpd.getKeys( ) ){
         // you need to poll the array kpd.key[]
         for( int i=0 ; i<LIST_MAX ; i++ ){
           if( kpd.key[ i ].stateChanged ){ 
            lcd.printf("%c\n", kpd.key[ i ].kchar);
           }
           lcd.locate(0,0);
       }
}

I have physically built a 5x4 keypad, the keypad hardware functions as expected just using the DigitalIn functionality and an LED. I did this as a sanity check and hardware debug just to confirm that my hardware wasn't causing an error. The issue I am having is that my fifth row will not register as a valid input on any of the keys. My "keys" array is 5x5 and that is the only way that I could find to make the progression of the characters track properly on the LCD. If defined as a 5x4, as one would logically think to be correct, the first columns characters are lost for some reason. I will continue hacking away at the source files, but it is definitely throwing out some glitches when modifying the library.

I really appreciate your comments and code, the library is great, but it seems to be tied to a 4x4 layout and it would be awesome to adapt it for larger or smaller keymaps.

Question relating to:

Be the first to answer this question.