Tests forked Keypad library.
Dependencies: FPointer keypad mbed
Schematic:
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.
Diff: main.cpp
- Revision:
- 3:fb173f712440
- Parent:
- 2:eaa3d23e9b29
- Child:
- 4:16191e501b63
--- 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