Sense multiple keypresses from a 4x4 keypad

Dependencies:   Hotboards_keypad mbed

Fork of Hotboards_MultiKey by Hotboards MX

Revision:
2:5710f598e683
Parent:
1:bd23ec9647fd
diff -r bd23ec9647fd -r 5710f598e683 main.cpp
--- a/main.cpp	Tue Mar 08 21:19:09 2016 +0000
+++ b/main.cpp	Mon May 30 09:51:22 2016 +0000
@@ -1,4 +1,7 @@
 /* @file MultiKey.cpp
+|| @vesion 1.2 
+|| @modified by Istvan Cserny 
+|| @contact https://developer.mbed.org/users/icserny/
 || @version 1.1
 || @modified by Diego (http://hotboards.org)
 || @version 1.0
@@ -29,9 +32,9 @@
 };
 
 // Defines the pins connected to the rows
-DigitalInOut rowPins[ 4 ] = { PA_6 , PA_7 , PB_6 , PC_7 };
+DigitalInOut rowPins[ 4 ] = { PTB8 , PTB9 , PTB10 , PTB11 };
 // Defines the pins connected to the cols
-DigitalInOut colPins[ 4 ] = { PA_8 , PB_10 , PB_4 , PB_5 };
+DigitalInOut colPins[ 4 ] = { PTE2 , PTE3 , PTE4 , PTE5 };
 
 // Creates a new keyboard with the values entered before
 Keypad kpd( makeKeymap( keys ) , rowPins , colPins , 4 , 4 );
@@ -51,7 +54,7 @@
         if( kpd.getKeys( ) )
         {
             // Scan the whole key list.
-            for( i = 0 ; i <= LIST_MAX ; i++ )
+            for( i = 0 ; i < LIST_MAX ; i++ )
             {
                 // Only find keys that have changed state.
                 if( kpd.key[ i ].stateChanged )
@@ -75,7 +78,7 @@
                             break;
                     }
                     // Print the current state of the key pressed
-                    pc.printf( "Key " );
+                    pc.printf( "Key " );              
                     pc.printf( "%c" , kpd.key[ i ].kchar );
                     pc.printf( "%s" , msg.c_str() );
                     pc.printf( "\n\r" );