Difference between revisions of "Keypad"
m (Use "Under Construction" Template) |
(→Deeper one) |
||
(19 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | How to connect a keypad to your Armadeus board | |
− | == | + | ==Introduction== |
− | + | Your Armadeus board allows you to connect a (matrix or not) keypad as input device. Keypads are a collection of switches assembled together to emulate a kind of keyboard to ease user interaction with your system. | |
− | + | ==Solutions== | |
+ | There are several solutions to connect a keypad to your Armadeus board: | ||
+ | ===Keypad directly connected to i.MXL/27=== | ||
+ | ====One GPIO for one key==== | ||
+ | This type of keypad generally called "common ground keypad" is the easiest one to build: connect your switch to an i.MX GPIO (with a pullup) on one side and to the ground on the other side . If you need more than 6 keys, this construction is however "GPIO consuming" and you would better use matrix keypads. | ||
+ | <br>Under Test... | ||
+ | |||
+ | ====Matrix keypads on i.MX27==== | ||
+ | The i.MX27 has an internal controller that can drive 8x8 keypads (= 64 keys with 16 dedicated pins): [[Keypad usage on i.MX27]]. | ||
+ | Please consult the i.MX27 Reference Manual (Chapter 25) for more informations. | ||
+ | |||
+ | ====Matrix keypads on i.MXL==== | ||
+ | [[Driver for i.MX GPIO controlled keypads]] | ||
− | |||
− | |||
− | |||
{| cellspacing=5 cellpadding=5 border=0 width=100% | {| cellspacing=5 cellpadding=5 border=0 width=100% | ||
|- | |- | ||
Line 18: | Line 27: | ||
{add a big picture of the keypad link with APF_DEV_LIGHT} | {add a big picture of the keypad link with APF_DEV_LIGHT} | ||
{add a big picture of the keypad link with APF_DEV_FULL} | {add a big picture of the keypad link with APF_DEV_FULL} | ||
− | | [[Image:keypad.svg|thumb|3x4 matrix keypad connected to i. | + | | [[Image:keypad.svg|thumb|3x4 matrix keypad connected to i.MX GPIOs|150px]] |
|} | |} | ||
− | ==== | + | ===== Keypad Connection (APF9328_devfull) ===== |
− | + | {| border="1" | |
+ | |+ 4x4 keypad caracters and corresponding CSI signals | ||
+ | ! CSI signal name !! !! D6 !! D5 !! D4 !! D3 | ||
+ | |- | ||
+ | ! !! X23 pin number !! 7 !! 8 !! 5 !! 6 | ||
+ | |- | ||
+ | ! MCLK !! 14 | ||
+ | | 1 || 2 || 3 || <- | ||
+ | |- | ||
+ | ! D0 !! 1 | ||
+ | | 4 || 5 || 6 || -> | ||
+ | |- | ||
+ | ! D1 !! 4 | ||
+ | | 7 || 8 || 9 || ENTER | ||
+ | |- | ||
+ | ! D2 !! 3 | ||
+ | | * || 0 || _ || ESC | ||
+ | |} | ||
− | === | + | ===FPGA solution=== |
+ | Development are also ongoing to connect matrix keypads using the FPGA... | ||
− | [[ | + | ==Test== |
+ | ===Quick try=== | ||
+ | * If you have a graphical LCD connected to your board (= virtual terminal), then you should see what you type (if your keypad keys are mapped to alphanumeric keyboard keys). | ||
+ | * If you don't have any virtual terminal, but only the serial console: '''(''event0'' may be ''event1'' if you already have a running touchscreen)''' | ||
+ | <pre class="apf"> | ||
+ | # cat /sys/class/input/input0/event0/device/name (check if event0 is really attached to keypad, otherwise, try event1, etc...) | ||
+ | MX27 Keypad | ||
+ | # cat /dev/input/event0 | ||
+ | </pre> | ||
+ | Then you should see weirds characters when pressing keyboard keys: | ||
+ | <pre class="apf"> | ||
+ | �,~~_�,}�}�3T,QToT6,TT�,�;��, � � | ||
+ | </pre> | ||
+ | * if the test wiped out your console, you can get it back with: | ||
+ | <pre class="apf"> | ||
+ | # reset | ||
+ | </pre> | ||
+ | * if you want to see hexadecimal values of what your are receiving: | ||
+ | <pre class="apf"> | ||
+ | # cat /dev/input/event0 | hexdump | ||
+ | 0000000 0283 0000 5a09 000e 0004 0004 0051 0007 | ||
+ | 0000010 0283 0000 5a30 000e 0001 006c 0001 0000 | ||
+ | 0000020 0283 0000 5a40 000e 0000 0000 .... .... | ||
+ | </pre> | ||
+ | * If corresponding device node in ''/dev/input/'' is not existing, then: | ||
+ | <pre class="apf"> | ||
+ | # cat /sys/class/input/input0/event0/dev | ||
+ | 13:64 | ||
+ | # mkdir -p /dev/input | ||
+ | # mknod /dev/input/event0 c 13 64 | ||
+ | </pre> | ||
+ | |||
+ | ===Deeper one === | ||
+ | * use ''target/demos/keypad_test/'' test tool | ||
+ | |||
+ | === «standard» one === | ||
+ | |||
+ | By default, keyboard are connected on /dev/tty1. Then to read keyboard output, simply cat on /dev/tty1 (type enter to see the text line): | ||
+ | |||
+ | <pre class="apf"> | ||
+ | # cat /dev/tty1 | ||
+ | qzerty | ||
+ | </pre> | ||
+ | |||
+ | == Tools == | ||
+ | |||
+ | === evtest === | ||
+ | |||
+ | evtest is a tool already installer on bsp to test keys comming from /dev/eventX. To use it simply launch it with path to device : | ||
+ | |||
+ | <pre class="apf"> | ||
+ | # evtest /dev/input/event1 | ||
+ | Input driver version is 1.0.1 | ||
+ | Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100 | ||
+ | Input device name: "gpio-keys.5" | ||
+ | Supported events: | ||
+ | Event type 0 (EV_SYN) | ||
+ | Event type 1 (EV_KEY) | ||
+ | Event code 21 (KEY_Y) | ||
+ | Event code 49 (KEY_N) | ||
+ | Properties: | ||
+ | Testing ... (interrupt to exit) | ||
+ | Event: time 201.720156, type 1 (EV_KEY), code 21 (KEY_Y), value 0 | ||
+ | Event: time 201.720156, -------------- SYN_REPORT ------------ | ||
+ | Event: time 202.040401, type 1 (EV_KEY), code 21 (KEY_Y), value 1 | ||
+ | Event: time 202.040401, -------------- SYN_REPORT ------------ | ||
+ | Event: time 202.580177, type 1 (EV_KEY), code 49 (KEY_N), value 0 | ||
+ | Event: time 202.580177, -------------- SYN_REPORT ------------ | ||
+ | Event: time 202.930185, type 1 (EV_KEY), code 49 (KEY_N), value 1 | ||
+ | Event: time 202.930185, -------------- SYN_REPORT ------------ | ||
+ | # | ||
+ | </pre> | ||
+ | |||
+ | === showkey === | ||
+ | |||
+ | showkey is already installed on armadeus bsp. It display all event (press or release) on key with codes : | ||
+ | |||
+ | <pre class="apf"> | ||
+ | # showkey | ||
+ | kb mode was UNICODE | ||
+ | [ if you are trying this under X, it might not work | ||
+ | since the X server is also reading /dev/console ] | ||
+ | |||
+ | press any key (program terminates 10s after last keypress)... | ||
+ | keycode 21 press | ||
+ | keycode 21 release | ||
+ | keycode 22 press | ||
+ | keycode 22 release | ||
+ | keycode 28 press | ||
+ | keycode 28 release | ||
+ | keycode 105 press | ||
+ | keycode 105 release | ||
+ | # | ||
+ | </pre> | ||
+ | |||
+ | === kbd === | ||
+ | |||
+ | [http://kbd-project.org/ kbd] is most advanced package that can be selected in config : | ||
+ | <pre class="config"> | ||
+ | Target packages ---> | ||
+ | Hardware handling ---> | ||
+ | [*] kbd | ||
+ | </pre> | ||
+ | |||
+ | Some program are provided with kbd. | ||
+ | |||
+ | ==== kbd_mode ==== | ||
+ | |||
+ | To change keyboard mode. To see actual mode symply type without arguments: | ||
+ | <pre> | ||
+ | # kbd_mode | ||
+ | The keyboard is in the default (ASCII) mode | ||
+ | </pre> | ||
+ | |||
+ | Mode can be change with options : | ||
+ | * -s: scancode mode (RAW), | ||
+ | * -k: keycode mode (MEDIUMRAW), | ||
+ | * -a: ASCII mode (XLATE), | ||
+ | * -u: UTF-8 mode (UNICODE). | ||
+ | |||
+ | Read more at: [https://www.commandlinux.com/man-page/man1/kbd_mode.1.html] | ||
+ | |||
+ | ==== kbdinfo ==== | ||
+ | |||
+ | TODO | ||
+ | |||
+ | ==== kbdrate ==== | ||
− | + | TODO | |
− | external links (for exemple: locomo driver model) | + | ==Links== |
+ | * external links (for exemple: locomo driver model) | ||
[[Category:UserInput]] | [[Category:UserInput]] |
Latest revision as of 15:04, 11 May 2020
How to connect a keypad to your Armadeus board
Contents
Introduction
Your Armadeus board allows you to connect a (matrix or not) keypad as input device. Keypads are a collection of switches assembled together to emulate a kind of keyboard to ease user interaction with your system.
Solutions
There are several solutions to connect a keypad to your Armadeus board:
Keypad directly connected to i.MXL/27
One GPIO for one key
This type of keypad generally called "common ground keypad" is the easiest one to build: connect your switch to an i.MX GPIO (with a pullup) on one side and to the ground on the other side . If you need more than 6 keys, this construction is however "GPIO consuming" and you would better use matrix keypads.
Under Test...
Matrix keypads on i.MX27
The i.MX27 has an internal controller that can drive 8x8 keypads (= 64 keys with 16 dedicated pins): Keypad usage on i.MX27. Please consult the i.MX27 Reference Manual (Chapter 25) for more informations.
Matrix keypads on i.MXL
Driver for i.MX GPIO controlled keypads
By default your board supports a direct connection with a 4x4 matrix keypad using the CSI lines: CSI_MCLK, CSI_D0...CSI_D6.
The driver uses the i.MXL GPIO's internal pull-up, therefore your board does not need any additional external resistor.
{add a big picture of the keypad link with APF_DEV_LIGHT} {add a big picture of the keypad link with APF_DEV_FULL} |
Keypad Connection (APF9328_devfull)
CSI signal name | D6 | D5 | D4 | D3 | |
---|---|---|---|---|---|
X23 pin number | 7 | 8 | 5 | 6 | |
MCLK | 14 | 1 | 2 | 3 | <- |
D0 | 1 | 4 | 5 | 6 | -> |
D1 | 4 | 7 | 8 | 9 | ENTER |
D2 | 3 | * | 0 | _ | ESC |
FPGA solution
Development are also ongoing to connect matrix keypads using the FPGA...
Test
Quick try
- If you have a graphical LCD connected to your board (= virtual terminal), then you should see what you type (if your keypad keys are mapped to alphanumeric keyboard keys).
- If you don't have any virtual terminal, but only the serial console: (event0 may be event1 if you already have a running touchscreen)
# cat /sys/class/input/input0/event0/device/name (check if event0 is really attached to keypad, otherwise, try event1, etc...) MX27 Keypad # cat /dev/input/event0
Then you should see weirds characters when pressing keyboard keys:
�,~~_�,}�}�3T,QToT6,TT�,�;��, � �
- if the test wiped out your console, you can get it back with:
# reset
- if you want to see hexadecimal values of what your are receiving:
# cat /dev/input/event0 | hexdump 0000000 0283 0000 5a09 000e 0004 0004 0051 0007 0000010 0283 0000 5a30 000e 0001 006c 0001 0000 0000020 0283 0000 5a40 000e 0000 0000 .... ....
- If corresponding device node in /dev/input/ is not existing, then:
# cat /sys/class/input/input0/event0/dev 13:64 # mkdir -p /dev/input # mknod /dev/input/event0 c 13 64
Deeper one
- use target/demos/keypad_test/ test tool
«standard» one
By default, keyboard are connected on /dev/tty1. Then to read keyboard output, simply cat on /dev/tty1 (type enter to see the text line):
# cat /dev/tty1 qzerty
Tools
evtest
evtest is a tool already installer on bsp to test keys comming from /dev/eventX. To use it simply launch it with path to device :
# evtest /dev/input/event1 Input driver version is 1.0.1 Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100 Input device name: "gpio-keys.5" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 21 (KEY_Y) Event code 49 (KEY_N) Properties: Testing ... (interrupt to exit) Event: time 201.720156, type 1 (EV_KEY), code 21 (KEY_Y), value 0 Event: time 201.720156, -------------- SYN_REPORT ------------ Event: time 202.040401, type 1 (EV_KEY), code 21 (KEY_Y), value 1 Event: time 202.040401, -------------- SYN_REPORT ------------ Event: time 202.580177, type 1 (EV_KEY), code 49 (KEY_N), value 0 Event: time 202.580177, -------------- SYN_REPORT ------------ Event: time 202.930185, type 1 (EV_KEY), code 49 (KEY_N), value 1 Event: time 202.930185, -------------- SYN_REPORT ------------ #
showkey
showkey is already installed on armadeus bsp. It display all event (press or release) on key with codes :
# showkey kb mode was UNICODE [ if you are trying this under X, it might not work since the X server is also reading /dev/console ] press any key (program terminates 10s after last keypress)... keycode 21 press keycode 21 release keycode 22 press keycode 22 release keycode 28 press keycode 28 release keycode 105 press keycode 105 release #
kbd
kbd is most advanced package that can be selected in config :
Target packages ---> Hardware handling ---> [*] kbd
Some program are provided with kbd.
kbd_mode
To change keyboard mode. To see actual mode symply type without arguments:
# kbd_mode The keyboard is in the default (ASCII) mode
Mode can be change with options :
- -s: scancode mode (RAW),
- -k: keycode mode (MEDIUMRAW),
- -a: ASCII mode (XLATE),
- -u: UTF-8 mode (UNICODE).
Read more at: [1]
kbdinfo
TODO
kbdrate
TODO
Links
- external links (for exemple: locomo driver model)