覚書。
SPI液晶モジュールやD級アンプのGPIOのPINアサインとか、ドライバの導入とか。
Adafruit MAX98357 I2S D級アンプの設定
AMP | RPi | |
---|---|---|
PIN Name | GPIO | PIN No. |
Vin | (5V) | 4 |
GND | (GND) | 6 |
DIN | 21 | 40 |
BCLK | 18 (PCM_CLK) | 12 |
LRC | 19 | 35 |
参考→Adafruit MAX98357 I2S Class-D Mono Amp
- emulationstationの「MAIN MENU」 →
- 「SOUND SETTINGS」 → 「AUDIO DEVICE」 → 「PCM」
- /boot/config.txtを編集する
#dtparam=audio=on
dtoverlay=hifiberry-dac
dtoverlay=i2s-mmap - /etc/asound.confを作成する※改行コードはLFで
pcm.speakerbonnet {
type hw
card 0
}
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "speakerbonnet"
period_time 0
period_size 1024
buffer_size 8192
rate 44100
channels 2
}
}
ctl.dmixer {
type hw
card 0
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control.name "PCM"
control.card 0
}
ctl.softvol {
type hw
card 0
}
pcm.!default {
type plug
slave.pcm "softvol"
}$ chown root:root /etc/asound.conf
- ボリューム調節
- 方法1
$ amixer sset PCM 80%※音量を80%に
- 方法2
- MENU → 「SOUND SETTINGS」 →
- 「AUDIO CARD」 → 「DEFAULT」
- 「AUDIO DEVICE」 → 「PCM」
- 設定変更後「SYSTEM VOLUME」で調節
- MENU → 「SOUND SETTINGS」 →
- 方法1
モノアンプのステレオ化について
- RPiにアンプを2枚、完全に並列で接続する
- VinとSDの間に、1枚を100kΩ、もう1枚を680kΩの抵抗器をはんだ付けする
- VinとGAINの間にも、出力を3dBに減じるために100kΩの抵抗器を入れるから結構大変
SPI通信式LCDモジュールの設定
LCD | RPi | |||
---|---|---|---|---|
Name | PIN Name | GPIO | PIN No. | |
1.3inch LCD HAT | LCD | MOSI | 10 (MOSI) | 19 |
SCLK | 11 (SCLK) | 23 | ||
CS | 8 (CE0) | 24 | ||
DC | 25 | 22 | ||
RST | 27 | 13 | ||
BL | 24 | 18 | ||
Stick | ↑ | 6 | N/A | |
↓ | 19 | N/A | ||
← | 5 | N/A | ||
→ | 26 | N/A | ||
Thumb | 13 | N/A | ||
Button | KEY1 | 21 | N/A | |
KEY2 | 20 | N/A | ||
KEY3 | 16 | N/A | ||
1.3inch LCD Module (ST7789) | VCC | (3.3V) | 17 | |
GND | (GND) | 20 | ||
DIN | 10 (MOSI) | 19 | ||
CLK | 11 (SCLK) | 23 | ||
CS | 8 (CE0) | 24 | ||
DC | 25 | 22 | ||
RST | 27 | 13 | ||
BL | 24 | 18 | ||
2.2inch LCD Module (ILI9341) | SDD/MISO | 9 (MISO) | 21 | |
LED (BL) | (3.3V) | 17 | ||
SCK | 11 (SCLK) | 23 | ||
SDI/MOSI | 10 (MOSI) | 19 | ||
DC/RS | 25 | 22 | ||
RESET | 27 | 13 | ||
CS | 8 (CE0) | 24 | ||
GND | (GND) | 20 | ||
VCC | (3.3V) | 17 | ||
4inch LCD Module (ST7796) | SDD(MISO) | 9 (MISO) | 21 | |
LED | 24 | 18 | ||
SCK | 11 (SCLK) | 23 | ||
SDI(MOSI) | 10 (MOSI) | 19 | ||
DC/RS | 25 | 22 | ||
RESET | 27 | 13 | ||
CS | 8 (CE0) | 24 | ||
GND | (GND) | 20 | ||
VCC | (3.3V) | 17 |
参考→240x240, 1.3inch IPS LCD display HAT for Raspberry Pi
- SPIを有効にする
$ raspi-config
- Interface Options → SPI → Yes
- LCDのドライバを入手して、使用する RPi + LCD に合わせた引数を付けてビルドする※64bitOSではビルドが出来ないので注意
- RPiZ + 「1.3inch LCD HAT」及び「Waveshare 1.3inch LCD Module」の場合
$ git clone https://github.com/juj/fbcp-ili9341.git
$ cd fbcp-ili9341
$ mkdir build
$ cd build
$ cmake -DSTATISTICS=0 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON -DSPI_BUS_CLOCK_DIVISOR=6 -DWAVESHARE_ST7789VW_HAT=ON ..- STATISTICS=0
- フレームレート等の情報を非表示にする(デフォルトはON)
- DISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON
- アスペクト比を無視して全画面表示(デフォルトは4:3固定)
- DSPI_BUS_CLOCK_DIVISOR=6
- /boot/config.txt内のcore_freqをDIVISOR(偶数)で割った値がSPIバスクロック
- core_freqのデフォルト値は、RPi1と2が250MHz、RPiZとZ2と3が400MHz、RPi4が500MHz
- よってRPiZの場合、400÷6=66.67MHz※66.7MHz未満が望ましい
- STATISTICS=0
- RPiZ2 + 「2.2inch TFT LCD Module 240x320 ILI9341」の場合
$ git clone https://github.com/juj/fbcp-ili9341.git
$ cd fbcp-ili9341
$ mkdir build
$ cd build
$ cmake -DSTATISTICS=0 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON -DSPI_BUS_CLOCK_DIVISOR=6 -DADAFRUIT_ILI9341_PITFT=ON .. - RPiZ2 + 「4inch TFT LCD Module 480x320 ST7796」の場合
$ git clone https://github.com/jobitjoseph/fbcp-ST7796.git
$ cd fbcp-ST7796
$ mkdir build
$ cd build
$ cmake -DSTATISTICS=0 -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON -DSPI_BUS_CLOCK_DIVISOR=6 -DST7796S=ON -DGPIO_TFT_DATA_CONTROL=25 -DGPIO_TFT_RESET_PIN=27 -DBACKLIGHT_CONTROL=ON -DGPIO_TFT_BACKLIGHT=24 -DDISPLAY_SWAP_BGR=ON -DDISPLAY_ROTATE_180_DEGREES=ON ..- ST7796S=ON
- 一応「ILI9488=ON」でも動くが画質は落ちる
- DISPLAY_SWAP_BGR=ON
- RGBの赤と青のチャンネルを入れ替え
- DISPLAY_ROTATE_180_DEGREES=ON
- この液晶は、他の液晶と上下が逆
- またDC、RESET(BLも)のPIN番号を指定しないとmakeが通らない
- ST7796S=ON
- RPiZ + 「1.3inch LCD HAT」及び「Waveshare 1.3inch LCD Module」の場合
- make & インストール
$ make -j
$ sudo install fbcp-ili9341 /usr/local/bin/fbcp-ili9341 - /etc/rc.localを編集する
fi
fbcp-ili9341 &
exit 0 - /boot/config.txtを編集する
hdmi_group=2※HDMIアウトプットグループをDMTに
hdmi_force_hotplug=1※HDMIモニタが検出されなくてもHDMIで出力 - 起動時にROMイメージを自動実行
- ~configs/autostart.shに黄色字部分を追加する※ROMイメージ名が日本語の場合はutf-8で保存
# Added by me
/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ ROMフォルダ名 $HOME/RetroPie/roms/ROMフォルダ名/ROMイメージ名
emulationstation #auto
- ~configs/autostart.shに黄色字部分を追加する※ROMイメージ名が日本語の場合はutf-8で保存
- 画面を90°回転させて使用したい場合
- 古い方法(display_rotate=3はGPUメモリを余計に消費し、エミュの実行速度がかなり落ちる)
- /boot/config.txtを編集し、下記の1行を追加する
display_rotate=3
- libretroのaspect_ratioを、横画面モノは1:1、縦画面モノはCustomの3:4にする※やめた方法なのでうろ覚え
- /opt/retropie/configs/mame-libretro/retroarch.cfgを編集する
aspect_ratio_index = "23"
custom_viewport_width = "200"
custom_viewport_height = "320"
custom_viewport_x = "20"
- /boot/config.txtを編集し、下記の1行を追加する
- 新たに考えた方法(こちらの方法なら本来の実行速度が出る)
- /opt/retropie/configs/autostart.shを編集する
emulationstation --screenrotate 3 --screensize 480 640 #auto
- /opt/retropie/configs/retroarch.cfgを編集する
aspect_ratio_index = "5"
# video_allow_rotate = "true"
# video_rotation = 0"1" - libretroのaspect_ratioを、横画面モノは16:9、縦画面モノは1:1を指定する
- /opt/retropie/configs/autostart.shを編集する
- 古い方法(display_rotate=3はGPUメモリを余計に消費し、エミュの実行速度がかなり落ちる)
- (emulationstationの文字を大きくする)
- themeがcarbonの場合
- /etc/emulationstation/themes/carbon/carbon.xmlを編集する
<view name="basic">
<textlist name="gamelist">
<selecgtorColor>1c1c1c</selecgtorColor>
<selectedColor>8b0000</selectedColor>
<primaryColor>969696</primaryColor>
<secondaryColor>7a6161</secondaryColor>
<fontPath>./art/Cabin-Bold.ttf</fontPath>
<fontSize>0.0300.055</fontSize>※かなり巨大- 画面を90°回転させたときは「0.045」が良さげ
- /etc/emulationstation/themes/carbon/carbon.xmlを編集する
- themeがcarbon-2021の場合
- /etc/emulationstation/themes/carbon-2021/theme.xmlを編集する
<theme>
<variables>
<colorRed>8b0000</colorRed>
<colorBlue>3082ce</colorBlue>
<colorGreen>50d62c</colorGreen>
<colorYellow>efbc0b</colorYellow>
<colorOrange>ef710b</colorOrange>
<colorPurple>ac0bef</colorPurple>
<colorTeal>04e9f7</colorTeal>
<colorPink>f50297</colorPink>
<themeColor>${colorRed}</themeColor>
<themeArtFolder>./art</themeArtFolder>
<themeFont>${themeArtFolder}/Cabin-Bold.ttf</themeFont>
<themeScrollSound>${themeArtFolder}/scroll.wav</themeScrollSound>
<themeGamelistFontSize>3264</themeGamelistFontSize>※縦使いなら56くらい
</variables>
- /etc/emulationstation/themes/carbon-2021/theme.xmlを編集する
- themeがcarbonの場合
- KIOSK(公共端末)モードで設定変更を抑止する
- MENU → 「UI SETTINGS」 → 「UI MODE」 → 「KIOSK」
- モードの解除は Emulation Station の、どの画面でも良いので「↑↑↓↓←→←→BA」と正確に入力
- Emulation Stationが再読み込みされたら解除成功
- MENU → 「UI SETTINGS」 → 「UI MODE」 → 「KIOSK」
Helmets 1/12レトロアップライト筐体 覚書
あると便利なもの…セーム革の眼鏡拭き、デザインナイフ、皮膜剥きペンチ
材質が木なので、ラッカー系塗料で黒く塗ると板が反ってしまうので注意