test program for keypad(Extended not only 3x4 but 4x4,4x5 and 5x5 keys)
Fork of study_step0 by
see /users/kenjiArai/notebook/keypadkey-matrix--control/
Diff: key_5x5.cpp
- Revision:
- 5:53fb9eed6b67
- Parent:
- 4:0564f82dd0ef
--- a/key_5x5.cpp Sat Aug 01 07:49:39 2020 +0000 +++ b/key_5x5.cpp Thu Feb 18 08:15:37 2021 +0000 @@ -1,11 +1,11 @@ /* * Mbed Application program * - * Copyright (c) 2020 Kenji Arai / JH1PJL + * Copyright (c) 2020,'21 Kenji Arai / JH1PJL * http://www7b.biglobe.ne.jp/~kenjia/ * https://os.mbed.com/users/kenjiArai/ * Created: April 5th, 2020 - * Revised: August 1st, 2020 + * Revised: February 18th, 2021 */ // Pre-selection -------------------------------------------------------------- @@ -18,6 +18,11 @@ #include "Keypad.h" // Definition ----------------------------------------------------------------- +#if (MBED_MAJOR_VERSION == 2) || (MBED_MAJOR_VERSION == 5) +# define WAIT_100MS() {wait_us(100000);} +#else +# define WAIT_100MS() {ThisThread::sleep_for(100ms);} +#endif // Object --------------------------------------------------------------------- DigitalOut my_led(LED1); @@ -37,6 +42,7 @@ // 1234567890123456789012345 // Function prototypes -------------------------------------------------------- +extern void print_revision(void); //------------------------------------------------------------------------------ // Control Program @@ -46,13 +52,14 @@ uint32_t key_num; uint32_t counter = 0; + print_revision(); printf("Start Key-Pad test 5x5 keys\r\n"); while(true) { while ((key_num = key.read()) != 0) { printf("%2u:[%2d] %c\r\n", counter++, key_num, *(key_table + key_num)); } - wait_us(100000); + WAIT_100MS(); } }