multiple keys

Dependencies:   Hotboards_keypad mbed

Files at this revision

API Documentation at this revision

Comitter:
RomanValenciaP
Date:
Tue Mar 08 19:31:58 2016 +0000
Child:
1:2ca8747d39ed
Commit message:
beta release - needs testing

Changed in this revision

Hotboards_keypad.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hotboards_keypad.lib	Tue Mar 08 19:31:58 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Hotboards/code/Hotboards_keypad/#e870110f753b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 08 19:31:58 2016 +0000
@@ -0,0 +1,61 @@
+
+#include "mbed.h"
+#include "Hotboards_keypad.h"
+#include <string>
+
+using std::string;
+
+char keys[ 4 ][ 4 ] =
+{
+    { '1' , '2' , '3' , 'A' },
+    { '4' , '5' , '6' , 'B' },
+    { '7' , '8' , '9' , 'C' },
+    { '*' , '0' , '#' , 'D' }
+};
+
+DigitalInOut rowPins[ 4 ] = { PA_6 , PA_7 , PB_6 , PC_7 };
+DigitalInOut colPins[ 4 ] = { PA_8 , PB_10 , PB_4 , PB_5 };
+
+Keypad kpd( makeKeymap( keys ) , rowPins , colPins , 4 , 4 );
+
+Serial pc( USBTX , USBRX );
+
+int i;
+
+int main()
+{
+    string msg;
+    while(1)
+    {
+        if( kpd.getKeys( ) )
+        {
+            for( i = 0 ; i <= LIST_MAX ; i++ )
+            {
+                if( kpd.key[ i ].stateChanged )
+                {
+                    switch( kpd.key[ i ].kstate )
+                    {
+                        case PRESSED:
+                            msg = " PRESSED. ";
+                            break;
+                        case HOLD:
+                            msg = " HOLD. ";
+                            break;
+                        case RELEASED:
+                            msg = " RELEASED. ";
+                            break;
+                        case IDLE:
+                            msg = " IDLE. ";
+                            break;
+                        default:
+                            break;
+                    }
+                    pc.printf( "Key " );
+                    pc.printf( "%c" , kpd.key[ i ].kchar );
+                    pc.printf( "%s" , msg.c_str() );
+                    pc.printf( "\n\r" );
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 08 19:31:58 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb
\ No newline at end of file