[rpi] Runeaudio๋ฅผ ์ด์ฉํ ์ค๋์ค ์์คํ
๋ง๋ค๊ธฐ
Runeaudio๋ฅผ ์ด์ฉํ ์ค๋์ค ์์คํ
๋ง๋ค๊ธฐ
How to make audio system using Runeaudio
์๋
ํ์ธ์. ์ฐ๋ธ๊ธฐ๋ง์ zzeromin์
๋๋ค. ๋ง์ด์ ๋๋์ด ์์ฑํ์ ํ๋์จ์ด ์ ์๋ฒ์ ์ด์ด์ ์ํํธ์จ์ด ์ค์น๋ฒ์ ๋ํด์ ๊ธ์ ์ฌ๋ฆฝ๋๋ค.
์ฐ๋ธ๊ธฐ๋ง์์์ ์ ์ํ ํ์ด์ฌ์ธ์๊ณผ ํ์ด๋ฏธ๋์ฌ์ ์๋์ ๊ฐ์ Runeaudio, Volumio, KODI(OSMC, Openelec), RetroPie๋ฅผ ์ด์ฉํ์ฌ ๋ฏธ๋์ด์์คํ
์ ๊ตฌ์ถํ ์ ์์ต๋๋ค.
์ด ๊ธ์์๋ ์๋ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด Runeaudio์ ์ฐ์ ๋ค๋ฃจ๊ฒ ์ต๋๋ค.
Runeaudio๋ ์๋ฒ ๋๋ ํ๋ซํผ์์ ์ฌ์ฉํ ์ ์๋ Arch Linux ๊ธฐ๋ฐ ์คํ์์ค ํ์ดํ์ด ๋์งํธ ๋ฎค์ง ํ๋ ์ด์ด์
๋๋ค. (http://www.runeaudio.com/about/)
๋ชฉ์ฐจ.
1. Runeaudio ๋ค์ด๋ก๋์ ์ค์น
2. DAC ์ค์น ๋ฐฉ๋ฒ(PCM5102 ๋๋ ES9023)
3. I2C ๋ฐฉ์ LCD ์ค์น ๋ฐฉ๋ฒ
4. LCD์ ์์
์ ๋ณด๋ฅผ ์ถ๋ ฅํ๊ธฐ ์ํ python2 ํจํค์ง ์ค์น
5. IR-remote ์ค์น
1. Runeaudio ๋ค์ด๋ก๋์ ์ค์น
๊ฐ. Runeaudio ์ด๋ฏธ์ง ๋ค์ด๋ก๋
์๋ ๋งํฌ์์ ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด2์ฉ ์ด๋ฏธ์ง๋ฅผ ๋ด๋ ค๋ฐ์ต๋๋ค.
Latest release: v0.3-beta (14/04/2015)
http://www.runeaudio.com/download/
Win32DiskImager๋ฅผ ์ด์ฉํ์ฌ 4G ์ด์ SD์นด๋์ ์ด๋ฏธ์ง๋ฅผ ์ค์นํฉ๋๋ค.
http://www.runeaudio.com/documentation/quick-start/sd-card-setup-windows/
๋ง์ด์ ๋๋์ ๊ธ์ ์ฐธ๊ณ ํ์ธ์.
http://www.rasplay.org/?p=24175
๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ DAC๋ฅผ GPIO ํ์ผ๋ก ์ฐ๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ์๋ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์ญ์์ค.
http://www.tjaekel.com/T-DAC/files/RPi-Bplus_guideline.pdf
2. DAC ์ค์น ๋ฐฉ๋ฒ(PCM5102 ๋๋ ES9023)
์ด ํ๋ก์ ํธ์์ ์ฌ์ฉํ DAC๋ PCM5102์
๋๋ค. ES9023๋ ์ฌ์ฉํ์ค ์ ์์ต๋๋ค. ๊ตญ๋ด์์ ์ ์ ์์
ํ๋ ๊ณณ์ด ์์ผ๋ฏ๋ก ebay๋ aliexpress์์ ๊ตฌ๋งค๋ฅผ ํ์๊ธธ ๋ฐ๋๋๋ค.
PCM5102 Features:
Input: I2S
Output: RCA
Sampling rates supported: 32bit 384khz beyond ES9023
SNR :112db
Distortion:-93db
Directly output is 2.1V RMS audio voltage
PCB Size: 48 x 48mm
ES9023 Features:
Input: I2S
Output: RCA
Sampling rates supported: 16 / 24bit 192khz
PCB Size: 50 x 42mm
๋ผ์ฆ๋ฒ ๋ฆฌํ์ด์ DAC๋ฅผ GPIO ํ์ผ๋ก ์ฐ๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ์๋ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์ญ์์ค.
http://www.tjaekel.com/T-DAC/files/RPi-Bplus_guideline.pdf
์๋์ฐ(putty) ๋๋ ๋ฆฌ๋
์ค ํฐ๋ฏธ๋์์ ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
# sudo nano /boot/config.txt
์๋ ๋ ์ค์ ์ฐพ์์ #์ ์ ๊ฑฐ ํ
ctrl+x ๋๋ฅด๊ณ y, ์ํฐ
device_tree_param=i2s=on
dtoverlay=hifiberry-dac
๋ผ. ๋๋ผ์ด๋ฒ๊ฐ ์ค์น๋๋์ง ํ์ธ
card 1์ ์๋ snd_rpi_hifiberry ๊ฐ ํ๋ฉด์ ๋ณด์ด๋ฉด ์ ์์ ์ผ๋ก ์ค์นํ ๊ฒ์
๋๋ค.
์น๋ธ๋ผ์ฐ์ ์์ DAC๋ฅผ ์ ํํฉ๋๋ค.
3. I2C ๋ฐฉ์ LCD ์ค์น ๋ฐฉ๋ฒ
๊ฐ. i2c LCD ๊ด๋ จ ์ ๋ณด
์ด ํ๋ก์ ํธ์์ ์ฌ์ฉํ LCD๋ 16*2 LCD์
๋๋ค.
i2c Address: 0x27 or 0x3f
Backlight (Blue or Yellow background).
Supply voltage: 5V
Size: 82x35x18 mm
LCD๋ฅผ ์ค์นํ๋ ๋ฐฉ๋ฒ์ ์ฐ์ i2c๋ฅผ ํ์ฑํ ์ํค๊ณ i2c-tools ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค.
์๋ ์ฌ์ดํธ๋ฅผ ์ฐธ๊ณ ํ์
๋ ์ข์ต๋๋ค.
* reference site:
http://buzzthisnow.com/how-to-enable-i2c-on-raspberry-pi-2-running-runeaudio-archlinux/
์๋์ฐ(putty) ๋๋ ๋ฆฌ๋
์ค ํฐ๋ฏธ๋์์ ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
์๋ ์ค์ ์ฐพ์์ #์ ์ ๊ฑฐ ํ
ctrl+x ๋๋ฅด๊ณ y, ์ํฐ
device_tree_param=i2c_arm=on
๋ค. cmdline์ ๋ด์ฉ ์ถ๊ฐ
ํฐ๋ฏธ๋์์ ์๋ ๋ด์ฉ์ ์ถ๊ฐํฉ๋๋ค.
๋์ผ๋ก ์ด๋(ํค๋ณด๋ Endํค) ํ ์๋ ์ค์ ๋ถ์ฌ๋ฃ๊ณ
ctrl+x ๋๋ฅด๊ณ y, ์ํฐ
bcm2708.vc_i2c_override=1
ํฐ๋ฏธ๋์์ ์๋ ๋ด์ฉ์ ์ถ๊ฐํฉ๋๋ค.
# nano /etc/modules-load.d/raspberrypi.conf
๋งจ์๋์ ์๋ ๋ด์ฉ์ ์ถ๊ฐ ํ
ctrl+x ๋๋ฅด๊ณ y, ์ํฐ
pacman(ํ๋ก๊ทธ๋จ ํจํค์ง ๊ด๋ฆฌ์) ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์
๋ฐ์ดํธ ํฉ๋๋ค.
* debian ๋ฆฌ๋
์ค ๊ณ์ด(์ฐ๋ถํฌ, ๋ผ์ฆ๋น์)์ ํ๋ก๊ทธ๋จ ์ค์นํ ๋ apt๋ฅผ ์ฌ์ฉํ์ง๋ง arch ๋ฆฌ๋
์ค๋ pacman์ ์ฌ์ฉํฉ๋๋ค.
๋ฐ. i2c LCD ์ค์น ํ์ธ
i2c LCD ๊ฐ ์ฌ์ฉํ๋ ์ฃผ์๋ฅผ ํ์ธํฉ๋๋ค.
์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉํ๋ ์ฃผ์๋ 3f ๋๋ 27 ์
๋๋ค. (0x3f or 0x27)
4. LCD์ ์์
์ ๋ณด๋ฅผ ์ถ๋ ฅํ๊ธฐ ์ํ python2 ํจํค์ง ์ค์น
* runeaudio ํฌ๋ผ์ XploD ๋ ์๋ฃ๋ฅผ ์ฐธ๊ณ ํ์๋ฉด ์ดํด๋ฅผ ์ฝ๊ฒ ํ ์ ์์ต๋๋ค.
http://www.runeaudio.com/forum/lcd-display-and-buttons-in-python-tutorial-and-code-t1191.html
์ฃผ์) ํ์ฌ ์ฌ์ฉํ๊ณ ์๋ runeaudio์ ๋ฆฌ๋
์ค ์ปค๋์ โLinux runeaudio 3.18.7-3-ARCHโ ์
๋๋ค. ๋ฃฌ์ค๋์ค ์์๋ python2 ๋ฒ์ ์ด ๋ฏธ๋ฆฌ ์ค์น๋์ด ์์ต๋๋ค. ๊ทธ๋์ python ๊ด๋ จ ํ๋ก๊ทธ๋จ ํจํค์ง๋ ๋๋ถ๋ถ python2๋ฅผ ์ฌ์ฉํฉ๋๋ค. (python3์ ํผ๋์ด ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.)
์ฌ๊ธฐ๋ถํฐ๋ ํจํค์ง ์ค์น ์คํฌ๋ฆฐ์ท์ ์๋ตํฉ๋๋ค.
๊ฐ. python ๊ด๋ จ ํ๋ก๊ทธ๋จ ์ค์น
# pacman โS python-setuptools
# pacman โS python2-pip
๋. ์์
์ ๋ณด, GPIO ๊ด๋ จ ํ๋ก๊ทธ๋จ ์ค์น
# cd
# git clone https://github.com/Mic92/python-mpd2.git
# cd python-mpd2/
# python2 setup.py install
# cd
# wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.6.1.tar.gz#md5=254d0443a436eb241367c487274e7197
# tar -xvf RPi.GPIO-0.6.1.tar.gz
# cd RPi.GPIO-0.6.1
# python2 setup.py install
# cd
# git clone https://github.com/RandyCupic/RuneAudioLCD.git
# cd RuneAudioLCD/
๊ฐ) starty.py ์์ ํ๊ธฐ
32๋ฒ์งธ ์ค๋ถํฐ ์๋๋ฅผ ์ฐธ๊ณ ํด์ ์์ ํ์ธ์.
# Specify I2C display address (usually 0x27)
I2C_DISPLAY_ADDRESS = 0X3f
# This program generates LCD output dynamically
# Which means that it support both 20x4 and 16x2 LCDs
# Specify LCD size (for example 20x4 or 16x2 LCD
LCD_COLUMNS = 16
LCD_ROWS = 2
# Specify scrolling period (for artist and title) in SECONDS
# WARNING: By decreasing scrolling_period, CPU usage increases fast
SCROLLING_PERIOD = 0.5
70๋ฒ์งธ ์ค ์ซ์ True๋ฅผ False๋ก ์์
*์ฃผ์: ๋ฒํผ ๊ธฐ๋ฅ์ ๋นํ์ฑํํ๋ ๋ถ๋ถ์
๋๋ค. ์ด ๋ถ๋ถ์ ๊ฑด๋๋ฐ๋ฉด ๋ฃฌ์ค๋์ค๊ฐ ๋ค์ด๋ฉ๋๋ค. ๊ผญ ์์ ํ์ธ์.
# If you want to use buttons, put to True, otherwise put to False
BUTTONS_ENABLE = False
522๋ฒ์งธ ์ค ์ซ์ 20์ 16์ผ๋ก ์์
# For 16x2 LCD, remove decimal value (to fit on the screen)
if (self.columns < 16):
๋ค) i2c_display.py ์์
56๋ฒ์งธ ์ค 20์ 16์ผ๋ก ์์
# Define LCD device constants
LCD_WIDTH = 16 # Default characters per line # TODO
๋ค. ๋ถํ
์ start.py๋ฅผ ์คํ์ํค๋ ์๋น์ค ๋ง๋ค๊ธฐ
# nano /usr/lib/systemd/system/runelcd.service
์๋ ๋ด์ฉ ๋ถ์ฌ๋ฃ๊ณ ctrl+x ๋๋ฅด๊ณ y, ์ํฐ
[Unit]
Description=Runeaudio_I2C_LCD service
After=network.target
[Service]
Type=simple
ExecStartPre=/usr/bin/sh -c "sleep 3"
ExecStart=/usr/bin/python2 /root/RuneAudioLCD/start.py
Restart=always
[Install]
WantedBy=multi-user.target
์์คํ
์์์ ์๋น์ค ์คํํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
# systemctl start runelcd.service
# systemctl enable runelcd.service
๋ง์ฝ LCD์ ๋ณํ๊ฐ ์์ผ๋ฉด ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํ์ฌ ์ํ๋ฅผ ํ์ธํฉ๋๋ค.
# systemctl status -l runelcd.service
์ด ํ๋ก์ ํธ์ ์ฌ์ฉํ IR์ผ์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
KSM-603LM5ND(๋ฆฌ๋ชจ์ฝ๋ชจ๋ ์๊ด๋ถ)
http://eleparts.co.kr/EPX33JXL
1๋ฒํ -> GPIO 17
2๋ฒํ -> GND 09
3๋ฒํ -> 3.3V 01
* XploD ๋ ์๋ฃ๋ฅผ ์ฐธ๊ณ ํ์๋ฉด ์ฝ๊ฒ ๋ฐ๋ผ์ ํ์ค ์ ์์ต๋๋ค.
http://buzzthisnow.com/ir-remote-with-lirc-on-raspberry-pi-2-running-runeaudio-archlinux/
์ฐจ๋ก๋๋ก ์คํํ์๋ฉด 9๋ฒ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
์๋ํ๋ฉด ๋ฃฌ์ค๋์ค์์ irrecord๋ก ๋ฆฌ๋ชจ์ปจ ์
ํ
์ ํ ์ ์๋ค๊ณ xplode๋์ด ๋ฌธ์ ์ ์ ์ง์ ํ์ต๋๋ค.
irw ๋ฌธ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋ณผ๋ฃจ๋ฏธ์ค๋ฅผ ์ด์ฉ(sudo irrecord -f -d /dev/lirc0 /etc/lirc/lircd.conf)ํด์ lircd.conf๋ฅผ ๋ง๋ ํ์ ๋ฃฌ์ค๋์ค๋ก ๊ฐ์ ธ์์ /etc/lirc/lircd.conf.d ์ ์ ์ฅํ๋ฉด ๋ฉ๋๋ค. MPC ๋ช
๋ น์ด๋ฅผ ์ ์ฅํ lircrc ํ์ผ์ /etc/conf.d/์ ์ ์ฅํ์ธ์.
lircd.conf๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ ๋ง์ด์ ๋๋์ด ์์ฑํ์ โvolumio ์ ์ธ์ ์์ IR๋ฆฌ์๋ฒ๋ฅผ์ด์ฉํ ๋ฆฌ๋ชจํธ์ปจํธ๋กคโ ๊ธ์ ์ฐธ๊ณ ํ์๊ธธ ๋ฐ๋๋๋ค.
http://www.runeaudio.com/documentation/
http://www.runeaudio.com/forum/lcd-display-and-buttons-in-python-tutorial-and-code-t1191.html