1.6 KiB
1.6 KiB
Keypad
Purpose
This module manages the matrix keypad used by OpenParcelBox.
The current implementation targets the development hardware based on a Freenove 4x4 keypad connected through a PCF8574 I²C GPIO expander.
The production hardware will use a custom 2x6 keypad. The scanning algorithm will remain identical. Only the hardware mapping and key table will change.
Development Hardware
- Seeed Studio XIAO nRF52840
- Freenove 4x4 Matrix Keypad
- PCF8574 GPIO Expander
- I²C address:
0x20
Wiring
| PCF8574 | Function |
|---|---|
| P0 | Row 1 |
| P1 | Row 2 |
| P2 | Row 3 |
| P3 | Row 4 |
| P4 | Column 1 |
| P5 | Column 2 |
| P6 | Column 3 |
| P7 | Column 4 |
Key Mapping
| Col 1 | Col 2 | Col 3 | Col 4 | |
|---|---|---|---|---|
| Row 1 | 1 | 2 | 3 | A |
| Row 2 | 4 | 5 | 6 | B |
| Row 3 | 7 | 8 | 9 | C |
| Row 4 | * | 0 | # | D |
Public API
int keypad_init(void);
char keypad_get_key(void);
keypad_get_key() returns:
0if no key is available.- The ASCII value of the pressed key.
Each key press is reported only once.
Current Features
- Matrix scanning
- Debounce
- Single key detection
- Anti-repeat
- Modular GPIO Expander interface
- Higher-level short beep on each accepted key press
B,*, or#cancellation of an in-progress access-code entry- First-key trigger for the fixed, non-renewable 15-second NFC scan window
Planned Improvements
- Support for the production 2x6 keypad.
- Configurable key mapping.
- Unit tests.