Kenji Arai / Mbed 2 deprecated Keypad_input_OS2

Dependencies:   mbed Keypad

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers key_5x5.cpp Source File

key_5x5.cpp

00001 /*
00002  * Mbed Application program
00003  *
00004  * Copyright (c) 2020 Kenji Arai / JH1PJL
00005  *  http://www7b.biglobe.ne.jp/~kenjia/
00006  *  https://os.mbed.com/users/kenjiArai/
00007  *      Created:    April      5th, 2020
00008  *      Revised:    April     13th, 2020
00009  */
00010 
00011 //  Pre-selection --------------------------------------------------------------
00012 #include    "select_example.h"
00013 //#define KEY5X5
00014 #ifdef KEY5X5
00015 
00016 //  Include --------------------------------------------------------------------
00017 #include "mbed.h"
00018 #include "Keypad.h"
00019 
00020 //  Definition -----------------------------------------------------------------
00021 
00022 //  Object ---------------------------------------------------------------------
00023 DigitalOut  my_led(LED1);
00024 Serial      pc(USBTX,USBRX);
00025 //              X    Y    Z   W   V   A   B   C   D   E   OUT(XYZWV), IN(ABCDE)
00026 Keypad      key(D11, D10, D9, D8, D7, D6, D5, D4, D3, D2);
00027 
00028 //  RAM ------------------------------------------------------------------------
00029 
00030 //  ROM / Constant data --------------------------------------------------------
00031 //                          X*A = *, X*B = G, X*C = B, X*D = 6, X*E = 1
00032 //                          Y*A = /, Y*B = H, Y*C = C, Y*D = 7, Y*E = 2
00033 //                          Z*A = ., Z*B = I, Z*C = D, Z*D = 8, Z*E = 3
00034 //                          W*A = +, W*B = J, W*C = E, W*D = 9, W*E = 4
00035 //                          V*A = -, V*B = =, V*C = F, V*D = A, V*E = 5
00036 //                          key_table[0]=? is not used!
00037 const char *const key_table = "?*GB61/HC72.ID83+JE94-=FA5";
00038 //                              1234567890123456789012345
00039 
00040 //  Function prototypes --------------------------------------------------------
00041 
00042 //------------------------------------------------------------------------------
00043 //  Control Program
00044 //------------------------------------------------------------------------------
00045 int main()
00046 {
00047     uint32_t key_num;
00048     uint32_t counter = 0;
00049 
00050     pc.printf("Start Key-Pad test 5x5 keys\r\n");
00051     while(true) {
00052         while ((key_num = key.read()) != 0) {
00053             pc.printf("%2u:[%2d] %c\r\n",
00054                       counter++, key_num, *(key_table + key_num));
00055         }
00056         wait_us(100000);
00057     }
00058 }
00059 
00060 #endif  // #ifdef KEY5X5