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:
Fri Nov 02 22:52:44 2012 +0000
Child:
1:8bbe2b267de6
Commit message:
Tests forked Keypad library

Changed in this revision

FPointer.lib Show annotated file Show diff for this revision Revisions of this file
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/FPointer.lib	Fri Nov 02 22:52:44 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/FPointer/#56e309e76c19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keypad.lib	Fri Nov 02 22:52:44 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/gj_schoneveld/code/keypad/#9a9ec143840b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 02 22:52:44 2012 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "keypad.h"
+
+#define       KEYLEN    4
+#define       ENDKEY   15
+char          Buffer[KEYLEN];
+int           Index = 0;
+
+// Define your own keypad values
+char Keytable[] = { '1', '2', '3', 'A',
+                    '4', '5', '6', 'B',
+                    '7', '8', '9', 'C',
+                    '*', '0', '#', 'D'
+                  };
+
+uint32_t cbAfterInput(uint32_t key)
+{
+    bool      finish = false;
+
+    printf("Index:%d => Key:%c\n", Index, Keytable[key]);
+
+    if (Index < KEYLEN - 1) {
+        if (key != ENDKEY)  // Terminating key
+            Buffer[Index] = Keytable[key];
+        else // Terminating key is entered
+            finish = true;
+        Index++;
+    }
+
+    if (finish || (Index == KEYLEN - 1)) {
+        printf("Complete string = %s\n", Buffer);
+        memset(&Buffer, 0, KEYLEN);
+        Index = 0;
+    }
+
+    return 0;
+}
+
+void Sleep(void)
+{
+    __WFI();
+}
+
+int main()
+{
+    printf("*** Keypad Demo ***\n");
+
+    memset(&Buffer, 0, KEYLEN);
+    Index = 0;
+    Keypad keypad(p25, p26, p27, p28, p21, p22, p23, p24);
+    keypad.CallAfterInput(&cbAfterInput);
+
+    keypad.Start();
+    while (1) {
+        Sleep();
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Nov 02 22:52:44 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06
\ No newline at end of file