Tests forked Keypad library.

Dependencies:   FPointer keypad mbed

Schematic:

http://schind.nl/keypad.png

No extra hardware is needed besides the wires and switches. The columns are outputs configured with open drain. The rows are inputs configured with pull up resistors. A key press pulls down its row. With scanning the column is determined thereafter.

See keypad for the forked library used in this project.

Files at this revision

API Documentation at this revision

Comitter:
gj_schoneveld
Date:
Sun Nov 04 09:50:00 2012 +0000
Parent:
2:eaa3d23e9b29
Child:
4:16191e501b63
Commit message:
Multiple keys added

Changed in this revision

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
--- a/keypad.lib	Sat Nov 03 23:45:20 2012 +0000
+++ b/keypad.lib	Sun Nov 04 09:50:00 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/gj_schoneveld/code/keypad/#e6623f165199
+http://mbed.org/users/gj_schoneveld/code/keypad/#fb6929fac0db
--- a/main.cpp	Sat Nov 03 23:45:20 2012 +0000
+++ b/main.cpp	Sun Nov 04 09:50:00 2012 +0000
@@ -18,6 +18,19 @@
     return 0;
 }
 
+uint32_t cbAfterMultipleInput(uint32_t key)
+{
+    for (int i = 0; i < 16; i++) {
+        if (key & (1 << i)) {
+             printf("Key: %d => \'%c\'\t", i, Keytable[i]);
+        }
+    }
+    printf("\n");
+    code = key;
+
+    return 0;
+}
+
 void Sleep(void)
 {
     __WFI();
@@ -30,22 +43,31 @@
     Keypad keypad(p25, p26, p27, p28, p21, p22, p23, p24);
 
 // interrupt mode
+/*
     keypad.CallAfterInput(&cbAfterInput);
     keypad.Start();
     while (1) {
         Sleep();
     }
+*/
     
 // polling mode
 /*
     keypad.Start();
-    
-    int key = -1;
     while (1) {
-        key = keypad.DebouncedScan();
+        int key = keypad.DebouncedScan();
         if (key >= 0)
             cbAfterInput(key);
         wait(0.1);
     }
 */
+
+// poll multiple mode
+    keypad.Start();
+    while (1) {
+        key = keypad.DebouncedScanMultiple();
+        if (key > 0)
+            cbAfterMultipleInput(key);
+        wait(0.1);
+    }
 }
\ No newline at end of file