2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

M5Stack MPD client

Posted at

#概要

先日投稿した赤外線リモンデコーダを使ったMPDクライアントです。
M5Stackのボタンと赤外線リモコンでMPDの操作ができます。
RaspberryPiのGPIOにいろいろ接続せずに操作パネルが付けられないかと考え、試作してみました。

##機能

  • MPDのボタン操作
  • MPDの赤外線リモコン操作
  • 演奏中の曲名表示

##ソースコード

ソースコードはこちらに置きました。
https://github.com/tt-yawata/m5mpdclient.git

###設定方法

WiFi APとMPDサーバの設定はコードに埋め込んでありますのでそちらを修正してください。
m5mpdclient.ino : 24行目

const char ssid[] = "Your SSID";
const char pass[] = "Your PASS";

MPDサーバは、IPアドレスまたはサーバ名で指定できます。
m5mpdclient.ino : 28行目

//mpd server
// by IP address
//const char mpdserver[] = "IP:192.168.xxx.xxx";
//by server name
const char mpdserver[] = "moode";
//char mpdserver[] = "volumio";
//const char mpdserver[] = "smpd";

###ボタン操作

M5StackのAボタンでモードを選択してB/Cボタンで操作します。
Aボタンを押すたびに0⇒1⇒2⇒3⇒4⇒0⇒…とモードが変化します。
ボタンを離して5秒するとモード0に戻ります。

モード Bボタン Aボタン
0 play/pause stop
1 previous next
2 seek 0 seek end
3 Shuffle repeat
4 volume -5 volume +5

※赤外線受信器を接続しなくてもとりあえずボタンだけでも操作できます。

###赤外線リモコン

赤外線受信器はGPIO21に接続しています。GPIOピンは変更可能です。
詳細はこちらもご参照ください。
https://qiita.com/tt-yawata/items/92adb5ddb19ff1d07178

m5mpdclient.ino : 55行目

const gpio_num_t irPin = GPIO_NUM_21;

テストに使用しているリモコンはこちらです。
https://www.akiba-led.jp/product/1489
サンプルコードでは以下のようにマッピングしています。

ir_remote.png
m5mpdclient.ino : 61行目

// IR remote command for
// https://www.akiba-led.jp/product/1489
const String ir_play = "N00ffc23d"; // pause
const String ir_stop = "N00ff6897";
const String ir_next = "N00ff02fd";
const String ir_prev = "N00ff22dd";
const String ir_home = "N00ffa25d";
const String ir_end = "N00ffe21d";
const String ir_repeat = "N00ff906f";
const String ir_random = "N00ff629d";
const String ir_volup = "N00ffa857";
const String ir_voldown = "N00ffe01f";

リモコンコードはシリアルポートに出力されます。
他のリモコンを使用する際にそのリモコンのボタンを押してコードを確認できます。
シリアル出力が不要な場合はコメントアウトしてください。
m5mpdclient.ino : 734行目

    Serial.println(ircode);

###MPDサーバについて

RaspberryPiにてVolumio, moOde audio player,symphonic-mpdで動作確認しています。

  • volumio: playlistの管理がオリジナルのため、previous, stopコマンドが動作しません。
  • symphonic-mpd: デフォルトでは6600ポートが閉じられていますので設定変更が必要です。
  • moOde audio player: 特に設定はありません。

##注記

  • WiFi AP, mpdサーバの設定がコード埋め込みになっているなど使い勝手が良くないと思います。サンプルコードと思っていますので、ご自由に改造してください。(不具合もありそうですので、改良版を公開していただけるとうれしいです)
  • Volumoはwebsocket APIですので、専用のクライアントを作ったほうが良いと思っていますが手がついていません。
  • 画面は、表示内容やデザインなど改良が必要と思います。

ちょっと宣伝モード。弊社にて開発・製造しているTerra-BerryDAC/HPAと組み合わせたイメージです。
s-s-IMG_20181226_113632.jpg

##参考にさせていただいたサイト

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?