Difference between revisions of "Rotary encoder with GPIOs"
From ArmadeusWiki
(→Hardware) |
(→Software) |
||
Line 22: | Line 22: | ||
=Software= | =Software= | ||
− | Device | + | * Device tree need to be adapted: |
<source lang=diff> | <source lang=diff> | ||
gpio-keys { | gpio-keys { | ||
Line 69: | Line 69: | ||
... | ... | ||
</source> | </source> | ||
+ | |||
+ | * you can then replace ''/boot/imx6ul-opos6uldev.dtb'' file on your rootfs and reboot | ||
+ | * Rotary should then be recognized by ''evtest'' tool: | ||
+ | <pre class="apf"> | ||
+ | # evtest | ||
+ | |||
+ | </pre> | ||
=Links= | =Links= | ||
[[Category:Multimedia]] | [[Category:Multimedia]] |
Revision as of 17:19, 3 March 2017
Page under construction... Informations on this page are not guaranteed !!
Contents
Introduction
This page will explain you how to drive a rotary encoder connected to GPIOs of your APF/OPOS.
Hardware
The instructions were tested on OPOS6ULDev where rotary encoder is connected to GPIOs on RPi compatible connector:
Encoder | Pin number on RPi connector |
Function |
---|---|---|
+ | 1 | Power |
GND | 6 | GND |
SW | Key press | |
DT | 32 | |
CLK | 40 |
Software
- Device tree need to be adapted:
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_keys>;
user-button {
label = "User button";
gpios = <&gpio2 11 GPIO_ACTIVE_LOW>;
linux,code = <BTN_MISC>;
wakeup-source;
};
+ rotary1_button {
+ label = "rotary1_button";
+ gpios = <&gpio5 2 GPIO_ACTIVE_LOW>;
+ debounce-interval = <10>;
+ linux,code = <28>;
+ };
}
+ rotary1 {
+ compatible = "rotary-encoder";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_rotary1>;
+ gpios = <&gpio5 0 1>, <&gpio5 1 1>;
+ linux,axis = <1>; /* REL_Y */
+ rotary-encoder,relative-axis;
+ };
...
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpios>;
...
+ pinctrl_rotary1: rotary1grp {
+ fsl,pins = <
+ MX6UL_PAD_SNVS_TAMPER0__GPIO5_IO00 0x0b0b0
+ MX6UL_PAD_SNVS_TAMPER1__GPIO5_IO01 0x0b0b0
+ >;
+ };
...
- you can then replace /boot/imx6ul-opos6uldev.dtb file on your rootfs and reboot
- Rotary should then be recognized by evtest tool:
# evtest