Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TextLCD keypad mbed
Keypad Class Reference
An interrupt-based interface to 4x4 keypad. More...
#include <keypad.h>
Public Member Functions | |
| Keypad (PinName row3, PinName row2, PinName row1, PinName row0, PinName col3, PinName col2, PinName col1, PinName col0, int debounce_ms=20) | |
| Create a Keypad interface. | |
| void | Start (void) |
| Start the keypad interrupt routines. | |
| void | Stop (void) |
| Stop the keypad interrupt routines. | |
| int | DebouncedScan (void) |
| Scan the keyboard for a debounced pressed key. | |
| int | Scan (void) |
| Scan the keyboard for a pressed key. | |
| int | DebouncedScanMultiple (void) |
| Scan the keyboard for multiple debounced pressed keys. | |
| int | ScanMultiple (void) |
| Scan the keyboard for multiple pressed keys. | |
| void | CallAfterInput (uint32_t(*fptr)(uint32_t)) |
| User-defined function that to be called when a key is pressed. | |
Detailed Description
An interrupt-based interface to 4x4 keypad.
On each key pressed on a keypad, the index of the key is passed to a user-defined function. User is free to define what to be done with the input.
This library makes use of
- See also:
- http://mbed.org/cookbook/FPointer by Andy Kirkham
Example:
#include "mbed.h" #include "keypad.h" // 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 index) { printf("Index:%d => Key:%c\n", key, Keytable[index]); return 0; } int main() { Keypad keypad(p25, p26, p27, p28, p21, p22, p23, p24); keypad.CallAfterInput(&cbAfterInput); keypad.Start(); while (1) { wait_ms(100); } }
Definition at line 67 of file keypad.h.
Constructor & Destructor Documentation
| Keypad | ( | PinName | row3, |
| PinName | row2, | ||
| PinName | row1, | ||
| PinName | row0, | ||
| PinName | col3, | ||
| PinName | col2, | ||
| PinName | col1, | ||
| PinName | col0, | ||
| int | debounce_ms = 20 |
||
| ) |
Create a Keypad interface.
- Parameters:
-
row<3..0> Row data lines col<3..0> Column data lines debounce_ms Debounce in ms (Default to 20ms)
Definition at line 3 of file keypad.cpp.
Member Function Documentation
| void CallAfterInput | ( | uint32_t(*)(uint32_t) | fptr ) |
User-defined function that to be called when a key is pressed.
- Parameters:
-
fptr A function pointer takes a uint32_t and returns uint32_t
| int DebouncedScan | ( | void | ) |
Scan the keyboard for a debounced pressed key.
Definition at line 44 of file keypad.cpp.
| int DebouncedScanMultiple | ( | void | ) |
Scan the keyboard for multiple debounced pressed keys.
Definition at line 83 of file keypad.cpp.
| int Scan | ( | void | ) |
Scan the keyboard for a pressed key.
Definition at line 52 of file keypad.cpp.
| int ScanMultiple | ( | void | ) |
Scan the keyboard for multiple pressed keys.
Definition at line 91 of file keypad.cpp.
| void Start | ( | void | ) |
Start the keypad interrupt routines.
Definition at line 26 of file keypad.cpp.
| void Stop | ( | void | ) |
Stop the keypad interrupt routines.
Definition at line 32 of file keypad.cpp.
Generated on Sun Jul 17 2022 01:37:34 by
1.7.2