树莓派-键盘篇

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值