树莓派-键盘篇

Posted skdev

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了树莓派-键盘篇相关的知识,希望对你有一定的参考价值。

1 keys驱动

新增文件:arch\\arm\\boot\\dts\\overlays\\example-keys-overlay.dts

/dts-v1/;

/plugin/;

 

/

compatible = "brcm,bcm2835";

 

fragment@0

target = <&gpio>;

__overlay__

keypad_pins: keypad_pins

brcm,pins = <17 22 23 27>;

brcm,function = <0>; /* in */

brcm,pull = <2>; /* up */

;

;

;

/*

 * Values for input event code is found under the

 * 'Keys and buttons' heading in include/uapi/linux/input.h

 */

fragment@1

target-path = "/soc";

__overlay__

keypad: keypad

compatible = "gpio-keys";

#address-cells = <1>;

#size-cells = <0>;

pinctrl-names = "default";

pinctrl-0 = <&keypad_pins>;

status = "okay";

autorepeat;

 

button@17

label = "GPIO KEY_UP";

linux,code = <103>;

gpios = <&gpio 17 0>;

;

button@22

label = "GPIO KEY_DOWN";

linux,code = <108>;

gpios = <&gpio 22 0>;

;

button@27

label = "GPIO KEY_LEFT";

linux,code = <105>;

gpios = <&gpio 27 0>;

;

button@23

label = "GPIO KEY_RIGHT";

linux,code = <106>;

gpios = <&gpio 23 0>;

;

;

;

;

 

__overrides__

keypad =     <&keypad>,"status";

;

;

 

linux\\arch\\arm\\boot\\dts\\overlays\\Makefile

dtbo-$(RPI_DT_OVERLAYS) += example-keys.dtbo

 

 

2 KERNEL编译

export PATH=$PATH:/home/thornton/work/pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/home/thornton/work/pi/firmware modules_install

 

3 KERNEL更新

将RPI T卡插在LINUX系统下,会弹出两个盘,一个是KERENL盘和一个BOOT盘

将firmware/lib拷到KERNEL盘,其他拷到BOOT盘

 

4 启动驱动

dtoverlay=example-keys

使能gpio-keys.ko

 

5 map key to system

Edit file ~/.config/openbox/lxde-rc.xml

Insert this code in the keyboard section:

CODE: SELECT ALL

 

<keybind key="XF86AudioRaiseVolume">

<action name="Execute">

<command>amixer set PCM 250+</command>

</action>

</keybind>

 

<keybind key="XF86AudioLowerVolume">

<action name="Execute">

<command>amixer set PCM 250-</command>

</action>

</keybind>

6 reboot

以上是关于树莓派-键盘篇的主要内容,如果未能解决你的问题,请参考以下文章

树莓派VNC Viewer 远程桌面配置教程

树莓派为啥不支持android

树莓派开启 SSH 和 WiFi(无需键盘显示器)

树莓派使用虚拟键盘

树莓派使用VNC进行远程控制

树莓派改键盘