-
Notifications
You must be signed in to change notification settings - Fork 1.5k
driver/input: Add keyboard matrix driver to read matrix keyboard using polling way. #18368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
8e7d651 to
b9b64f9
Compare
b9b64f9 to
b078847
Compare
b078847 to
4375fbc
Compare
4375fbc to
80a162a
Compare
drivers/input/kmatrix.c
Outdated
|
|
||
| /* Format string for /dev/kbdN device */ | ||
|
|
||
| #define DEV_FORMAT "/dev/kbd%d" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: use /dev/keypad%d or similar, /dev/kdb%d is already used by real keyboard, not an big issue, but could have some incompatibilities (if it is a /dev/kbd0 for example, it should be 100% compatible with a real keyboard, including scanning encoding support)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I will solve this.
80a162a to
50fed85
Compare
acassis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FelipeMdeO also since you are adding a new feature, we need Documentation/ to this matrix keyboard/keypad. Explain the purpose of this matrix keyboard, why it uses polling instead of interruptions, etc. Also drivers which functions a board needs to implement in order to support it (use the current stm32f4discovery implementation as reference)
|
Hello @acassis , I don't know how to proceed with documentation. |
0e7d5be to
88ffb4a
Compare
|
I did a documentation, please check if it is enough. |
88ffb4a to
5a155b8
Compare
michallenc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
5a155b8 to
b0b0ccd
Compare
|
@FelipeMdeO you can add your kmatrix driver inside Documentation/components/drivers/character/input/ Yes, that documentation is very old and needs to be updated later. Please create a Documentation giving context about your driver, what is its purpose, why is was created, how to add it to your board, etc. The Documentation is written in ReStructuredText (similar to Markdown) and you can use this document to verify if everything is fine: |
acassis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good @FelipeMdeO !!!
In your KMATRIX Documentation you can include that phone keypad to illustrate the idea ;-)
| events into the text data stream. The function interfaces that | ||
| comprise that encoding/decoding layer are defined in the header | ||
| file ``include/nuttx/input/kbd_code.h``. These functions provide | ||
| an matched set of (a) driver encoding interfaces, and (b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| an matched set of (a) driver encoding interfaces, and (b) | |
| a matched set of (a) driver encoding interfaces, and (b) |
Yes, your Documentation seems very good, I just suggested adding the keypad image after the title to illustrate the idea. Normally it makes the article more pleasant for someone reading the text. |
b0b0ccd to
58d5a51
Compare
Add a generic kmatrix lower-half with polling/debounce, STM32 board adapters, Kconfig options, a public API header, and a test example/documentation. Signed-off-by: Felipe Moura <[email protected]> decouple kbd / keypad. Fix some comments add documentation fix rule issues Update CMakeLists.txt update documentation. improve documentation
58d5a51 to
652f764
Compare
|
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
I think we can ignore this warning. Probably some new rule to avoid big commits |
Note: Please adhere to Contributing Guidelines.
Summary
Add a generic keyboard matrix (kmatrix) lower-half driver with polling/debounce, plus an STM32 GPIO board adapter and public API to expose
/dev/kbdN. Include a 4x3 keypad keymap example and documentation/test helper.I2C interface to used keypad was done but not tested yet.
The IRQ feature will be done as soon as possible. This is a first step development.
This change solve this request: apache/nuttx-apps#1764
Please @acassis , help me to verify if I followed all standards.
Impact
Optional input driver; no behavior change unless enabled. Enabling kmatrix adds periodic GPIO scanning and keyboard events on
/dev/kbd0.Testing
Host: Ubuntu 24.04.3 LTS x86_64.

Board: STM32F4Discovery + 4x3 membrane keypad (GPIO). See picture of keypad used below:
Build:
stm32f4discovery:nshwith:CONFIG_INPUT=yCONFIG_INPUT_KMATRIX=yCONFIG_EXAMPLES_KEYBOARD=yCONFIG_EXAMPLES_KEYBOARD_DEVPATH="/dev/kbd0"CONFIG_INPUT_KMATRIX_POLL_MS=10(default)CONFIG_INPUT_KMATRIX_DEBOUNCE=3(default)CONFIG_INPUT_KMATRIX_BUFSIZE=64(default)Runtime: Ran
kbdand observed key press/release events.Logs: