test program for keypad(Extended not only 3x4 but 4x4,4x5 and 5x5 keys)

Dependencies:   Keypad

Fork of study_step0 by Team_PjL

see /users/kenjiArai/notebook/keypadkey-matrix--control/

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sat Sep 30 23:29:05 2017 +0000
Parent:
0:1672d0903bdc
Child:
2:aa6fdecebf2b
Commit message:
test program for keypad(4x3 keypad library)

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
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keypad.lib	Sat Sep 30 23:29:05 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kenjiArai/code/Keypad/#ed0ad90ad734
--- a/main.cpp	Thu Aug 10 20:50:46 2017 +0000
+++ b/main.cpp	Sat Sep 30 23:29:05 2017 +0000
@@ -1,20 +1,48 @@
 /*
- * Mbed Application program / Study step1 -> LED Blinky
+ * Mbed Application program / Akizuki AE-KIT45-KEYPAD4X3
+ *  http://akizukidenshi.com/catalog/g/gK-12229/
  *
  * Copyright (c) 2017 Kenji Arai / JH1PJL
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
- *      Created:    August    10th, 2017
- *      Revised:    August    10th, 2017
+ *      Created:    September 27th, 2017
+ *      Revised:    October    1st, 2017
  */
 
+//  Include --------------------------------------------------------------------
 #include "mbed.h"
+#include "Keypad.h"
+
+//  Definition -----------------------------------------------------------------
 
+//  Object ---------------------------------------------------------------------
 DigitalOut  my_led(LED1);
+Serial      pc(USBTX,USBRX);
+            //  X    Y   Z   A   B   C   D   OUT(XYZ), IN(ABCD)
+Keypad      key(D10, D9, D8, D7, D6, D5, D4);
+
+//  RAM ------------------------------------------------------------------------
 
+//  ROM / Constant data --------------------------------------------------------
+                        // X*A = *, X*B = 7, X*C = 4, X*D = 1
+                        // Y*A = 0, Y*B = 8, Y*C = 5, Y*D = 2
+                        // Z*A = #, Z*B = 9, Z*C = 6, Z*D = 3
+char *const key_table = "?*7410852#963";  // key_table[0]=? is not used!
+
+//  Function prototypes --------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
 int main() {
-    while(1) {
-        my_led = !my_led;
-        wait(1.0);  
+    uint32_t key_num;
+    uint32_t counter = 0;
+
+    pc.printf("Start Key-Pad test\r\n");
+    while(true) {
+        while ((key_num = key.read()) != 0){
+            pc.printf("%04u : %c\r\n", counter++, *(key_table + key_num));
+        }
+        wait(0.1);  
     }
 }
--- a/mbed-os.lib	Thu Aug 10 20:50:46 2017 +0000
+++ b/mbed-os.lib	Sat Sep 30 23:29:05 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#4c256f04596179699c4f14b6863b07cc024ca9be
+https://github.com/ARMmbed/mbed-os/#ca661f9d28526ca8f874b05432493a489c9671ea