覚書。

SPI液晶モジュールやD級アンプのGPIOのPINアサインとか、ドライバの導入とか。

Adafruit MAX98357 I2S D級アンプの設定

Class D AMP ↔ RPi GPIO
PIN Assignment
AMPRPi
PIN NameGPIOPIN No.
Vin(5V)4
GND(GND)6
DIN2140
BCLK18 (PCM_CLK)12
LRC1935

参考→Adafruit MAX98357 I2S Class-D Mono Amp

  1. emulationstationの「MAIN MENU」 →
    1. 「SOUND SETTINGS」 → 「AUDIO DEVICE」 → 「PCM」
  2. /boot/config.txtを編集する
    #dtparam=audio=on
    dtoverlay=hifiberry-dac
    dtoverlay=i2s-mmap
  3. /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
  4. ボリューム調節
    • 方法1
      $ amixer sset PCM 80%※音量を80%に
    • 方法2
      1. MENU → 「SOUND SETTINGS」 →
        1. 「AUDIO CARD」 → 「DEFAULT」
        2. 「AUDIO DEVICE」 → 「PCM」
      2. 設定変更後「SYSTEM VOLUME」で調節

モノアンプのステレオ化について

  1. RPiにアンプを2枚、完全に並列で接続する
  2. VinとSDの間に、1枚を100kΩ、もう1枚を680kΩの抵抗器をはんだ付けする
  3. VinとGAINの間にも、出力を3dBに減じるために100kΩの抵抗器を入れるから結構大変

SPI通信式LCDモジュールの設定

LCD Module ↔ RPi GPIO
PIN Assignment
LCDRPi
NamePIN NameGPIOPIN No.
1.3inch LCD HATLCD MOSI10 (MOSI)19
SCLK11 (SCLK)23
CS8 (CE0)24
DC2522
RST2713
BL2418
Stick 6N/A
19N/A
5N/A
26N/A
Thumb13N/A
Button KEY121N/A
KEY220N/A
KEY316N/A
1.3inch LCD Module (ST7789) VCC(3.3V)17
GND(GND)20
DIN10 (MOSI)19
CLK11 (SCLK)23
CS8 (CE0)24
DC2522
RST2713
BL2418
2.2inch LCD Module (ILI9341) SDD/MISO9 (MISO)21
LED (BL)(3.3V)17
SCK11 (SCLK)23
SDI/MOSI10 (MOSI)19
DC/RS2522
RESET2713
CS8 (CE0)24
GND(GND)20
VCC(3.3V)17
4inch LCD Module (ST7796) SDD(MISO)9 (MISO)21
LED2418
SCK11 (SCLK)23
SDI(MOSI)10 (MOSI)19
DC/RS2522
RESET2713
CS8 (CE0)24
GND(GND)20
VCC(3.3V)17

参考→240x240, 1.3inch IPS LCD display HAT for Raspberry Pi

  1. SPIを有効にする
    1. $ raspi-config
    2. Interface Options → SPI → Yes
  2. 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未満が望ましい
    • 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が通らない
  3. make & インストール
    $ make -j
    $ sudo install fbcp-ili9341 /usr/local/bin/fbcp-ili9341
  4. /etc/rc.localを編集する
    fi

    fbcp-ili9341 &

    exit 0
  5. /boot/config.txtを編集する
    hdmi_group=2※HDMIアウトプットグループをDMTに
    hdmi_force_hotplug=1※HDMIモニタが検出されなくてもHDMIで出力
  6. 起動時にROMイメージを自動実行
    1. ~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
  7. 画面を90°回転させて使用したい場合
    • 古い方法(display_rotate=3はGPUメモリを余計に消費し、エミュの実行速度がかなり落ちる)
      1. /boot/config.txtを編集し、下記の1行を追加する
        display_rotate=3
      2. libretroのaspect_ratioを、横画面モノは1:1、縦画面モノはCustomの3:4にする※やめた方法なのでうろ覚え
      3. /opt/retropie/configs/mame-libretro/retroarch.cfgを編集する
        aspect_ratio_index = "23"
        custom_viewport_width = "200"
        custom_viewport_height = "320"
        custom_viewport_x = "20"
    • 新たに考えた方法(こちらの方法なら本来の実行速度が出る)
      1. /opt/retropie/configs/autostart.shを編集する
        emulationstation --screenrotate 3 --screensize 480 640 #auto
      2. /opt/retropie/configs/retroarch.cfgを編集する
        aspect_ratio_index = "5"
        # video_allow_rotate = "true"
        # video_rotation = 0"1"
      3. libretroのaspect_ratioを、横画面モノは16:9、縦画面モノは1:1を指定する
  8. (emulationstationの文字を大きくする)
    • themeがcarbonの場合
      1. /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」が良さげ
    • themeがcarbon-2021の場合
      1. /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>
  9. KIOSK(公共端末)モードで設定変更を抑止する
    1. MENU → 「UI SETTINGS」 → 「UI MODE」 → 「KIOSK」
      • モードの解除は Emulation Station の、どの画面でも良いので「↑↑↓↓←→←→BA」と正確に入力
      • Emulation Stationが再読み込みされたら解除成功

Helmets 1/12レトロアップライト筐体 覚書

あると便利なもの…セーム革の眼鏡拭き、デザインナイフ、皮膜剥きペンチ

材質が木なので、ラッカー系塗料で黒く塗ると板が反ってしまうので注意

Amazon Prime Video