查看: 15489|回复: 8

[原创] 树莓派HIFI DAC扩展板教程之红外线遥控Volumio

[复制链接]
  • TA的每日心情
    开心
    2012-11-23 16:50
  • 签到天数: 15 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    发表于 2014-6-14 02:10:55 | 显示全部楼层 |阅读模式
    分享到:
    本帖最后由 ukonline2000 于 2014-6-23 23:29 编辑

    扩展板简介:这是一款针对树莓派设计的专用HIFI DAC扩展板,采用TI公司高端DAC芯片(PCM5102A),使用的是I2S接口,非USB接口;使用这个扩展板后用户可以配合音频播放系统(如:volumio,xbmc系统等)搭建自己的网络HIFI播放器;扩展板提供2种输出接口方便外接功放等设备。有了它就可以摆脱PC功耗大,开机关机慢,电源杂音大等等困扰了。。。。

    HIFI DAC扩展板购买地址:http://item.taobao.com/item.htm?id=38890455462

    遥控器购买地址:http://item.taobao.com/item.htm?spm=a1z10.3.w4002-728255483.13.dDDR5L&id=39417392370


    此教程是让Volumio支持HIFI DAC扩展板的红外线功能,这样大家就可以通过手中的遥控器控制树莓派播放音乐了,不一定非要使用网络控制。

    教程:

    前期准备:刷入volumio系统,安装上HIFI DAC扩展板并焊上红外线接收器(如下图)

    1.启动树莓派,通过网络SSH方式登录树莓派,用户名:pi 密码:raspberry

    2.更新并安装lirc软件,运行以下命令:

    sudo apt-get update
    sudo apt-get install lirc

    2. 编辑modules ,并添加配置。扩展板的红外接收器=18

    sudo nano /etc/modules

    添加以下两行内容到modules中

    lirc_dev

    lirc_rpi gpio_in_pin=18

    3.编辑LRIC的配置文件使能红外线功能

    sudo nano /etc/lirc/hardware.conf

    修改以下行

    LIRCD_ARGS=”–uinput”

    DRIVER=”default”

    DEVICE=”/dev/lirc0″

    MODULES=”lirc_rpi”

    4.执行“sudo reboot”重启树莓派,并通过“ls /dev/l*”,查看红外线设备是否使能

    如果有红框中的内容就说明使能了

    5.录制按键

    sudo /etc/init.d/lirc stop
    irrecord -n -d /dev/lirc0 ~/lircd.conf

    根据提示录制你的遥控器,分别录制“pause”,“nextsong”,“prevsong”,“stop”


    将录制好的~/lircd.conf文件覆盖lirc软件的相应文件

    sudo cp ~/lircd.conf /etc/lirc/lircd.conf


    6.启动lirc软件

    sudo /etc/init.d/lirc start

    7.查看录制情况,执行以下命令

    irw

    然后按下刚才分别录制的按键

    8.编辑“.lircrc”,执行以下命令

    pico ~/.lircrc

    将以下内容添加到文件中

    begin
            prog = irexec
            button = pause
            config = mpc toggle
    end
    begin
            prog = irexec
            button = nextsong
            config = mpc next;mpc play
    end
    begin
            prog = irexec
            button = prevsong
            config = mpc prev;mpc play
    end
    begin
            prog = irexec
            button = stop
            config = mpc stop
    end


    注:可以在这里参考mpc的命令,自行添加自己想要的按键和功能(http://linux.die.net/man/1/mpc


    9.执行以下命令就能控制volumio了

    irexec -d

    10.编辑rc.local文件,让volumio启动后自动使能红外线接收功能,执行以下命令

    sudo nano /etc/rc.local

    在exit0之前,添加以下内容

    (sleep 3;
    sudo -u pi irexec -d
    )&

    保存退出,然后重启,恭喜你就成功完成红外控制volumio功能了,好好享受音乐盛宴吧!!!

    回复

    使用道具 举报

  • TA的每日心情
    开心
    2012-11-23 16:50
  • 签到天数: 15 天

    连续签到: 1 天

    [LV.4]偶尔看看III

     楼主| 发表于 2014-6-14 02:48:54 | 显示全部楼层
    一边看球一边写教程,必须留个沙发坐坐,表扬以下自己
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2012-11-23 16:50
  • 签到天数: 15 天

    连续签到: 1 天

    [LV.4]偶尔看看III

     楼主| 发表于 2014-6-23 21:50:49 | 显示全部楼层
    为啥没人关注呢
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2016-8-15 09:30
  • 签到天数: 162 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2014-6-24 08:56:41 | 显示全部楼层
    IT宅男最近看球的多,哈哈!UK大神,必顶~
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2012-11-23 16:50
  • 签到天数: 15 天

    连续签到: 1 天

    [LV.4]偶尔看看III

     楼主| 发表于 2014-6-24 10:34:09 | 显示全部楼层
    haothree 发表于 2014-6-24 08:56
    IT宅男最近看球的多,哈哈!UK大神,必顶~

    看球玩派两不误,哈哈
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2018-3-12 09:06
  • 签到天数: 75 天

    连续签到: 1 天

    [LV.6]常住居民II

    发表于 2014-7-7 17:14:41 | 显示全部楼层
    录制完启动后怎么没反应啊?
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2022-8-28 11:59
  • 签到天数: 1558 天

    连续签到: 1 天

    [LV.Master]伴坛终老

    发表于 2014-7-25 23:37:52 | 显示全部楼层
    世界杯已过,帮顶
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2014-12-31 15:22:42 | 显示全部楼层
    楼主,我问下,为啥我irw后什么都不输出呢??
    1. Press RETURN to continue.


    2. Now start pressing buttons on your remote control.

    3. It is very important that you press many different buttons and hold them
    4. down for approximately one second. Each button should generate at least one
    5. dot but in no case more than ten dots of output.
    6. Don't stop pressing buttons until two lines of dots (2x80) have been
    7. generated.

    8. Press RETURN now to start recording.
    9. ................................................................................
    10. Found const length: 107564
    11. Please keep on pressing buttons like described above.
    12. ................................................................................
    13. Space/pulse encoded remote control found.
    14. Signal length is 67.
    15. Found possible header: 8968 4484
    16. Found trail pulse: 544
    17. Found repeat code: 8965 2267
    18. Signals are space encoded.
    19. Signal length is 32
    20. Now enter the names for the buttons.

    21. Please enter the name for the next button (press <ENTER> to finish recording)
    22. KEY_UP

    23. Now hold down button "KEY_UP".

    24. Please enter the name for the next button (press <ENTER> to finish recording)
    25. KEY_DOWN

    26. Now hold down button "KEY_DOWN".

    27. Please enter the name for the next button (press <ENTER> to finish recording)
    28. KEY_LEFT

    29. Now hold down button "KEY_LEFT".

    30. Please enter the name for the next button (press <ENTER> to finish recording)
    31. KEY_RIGHT

    32. Now hold down button "KEY_RIGHT".

    33. Please enter the name for the next button (press <ENTER> to finish recording)
    34. KEY_ESC

    35. Now hold down button "KEY_ESC".

    36. Please enter the name for the next button (press <ENTER> to finish recording)
    37. KEY_ENTER

    38. Now hold down button "KEY_ENTER".

    39. Please enter the name for the next button (press <ENTER> to finish recording)

    40. Checking for toggle bit mask.
    41. Please press an arbitrary button repeatedly as fast as possible.
    42. Make sure you keep pressing the SAME button and that you DON'T HOLD
    43. the button down!.
    44. If you can't see any dots appear, then wait a bit between button presses.

    45. Press RETURN to continue.

    46. ..............................
    47. No toggle bit mask found.
    48. Successfully written config file.
    复制代码
    下面这是我cat lircd.conf的内容:
    1. # Please make this file available to others
    2. # by sending it to <lirc@bartelmus.de>
    3. #
    4. # this config file was automatically generated
    5. # using lirc-0.9.0-pre1(default) on Wed Dec 31 07:07:03 2014
    6. #
    7. # contributed by
    8. #
    9. # brand:                       /home/pirc.conf
    10. # model no. of remote control:
    11. # devices being controlled by this remote:
    12. #

    13. begin remote

    14.   name  /home/pirc.conf
    15.   bits           16
    16.   flags SPACE_ENC|CONST_LENGTH
    17.   eps            30
    18.   aeps          100

    19.   header       8968  4484
    20.   one           547  1699
    21.   zero          547   570
    22.   ptrail        544
    23.   repeat       8965  2267
    24.   pre_data_bits   16
    25.   pre_data       0x2FD
    26.   gap          107564
    27.   toggle_bit_mask 0x0

    28.       begin codes
    29.           KEY_UP                   0x9867
    30.           KEY_DOWN                 0xB847
    31.           KEY_LEFT                 0x629D
    32.           KEY_RIGHT                0xE21D
    33.           KEY_ESC                  0x22DD
    34.           KEY_ENTER                0x50AF
    35.       end codes

    36. end remote
    复制代码
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2014-12-31 15:24:18 | 显示全部楼层
    touchstone 发表于 2014-12-31 15:22
    楼主,我问下,为啥我irw后什么都不输出呢??下面这是我cat lircd.conf的内容: ...

    还有 问一下怎么修改第个人打断总的第16行的name呢?
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-4-30 00:12 , Processed in 0.197596 second(s), 31 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.