自作楽器用音源モジュール作成(4)

Androidアプリの開発環境周辺で滞ってしまったので、ESP-WROOM-02のファームと半田付けを進めた。

Wifi-Serial Bridge

クエリはどうでもいいので受けたデータをそのまま数値変換してシリアルに流すモジュールにした。

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "Wifi-Serial Bridge";
const char *password = "password";

ESP8266WebServer server(80);

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
 * connected to this access point to see it.
 */

void handleRoot() {
  uint8_t argc = server.args();
  for(uint8_t i = 0 ; i < argc ; ++i){
    String data = server.arg(i);
    uint8_t num = 0x0;
    for(uint8_t i = 0 ; i < data.length() && i < 0xff ; ++i){
      char c = data.charAt(i);
      if('0' <= c && c <= '9')      num = (num << 4) | (c - '0');
      else if('A' <= c && c <= 'F') num = (num << 4) | (c - 'A' + 0xa);
      else if('a' <= c && c <= 'f') num = (num << 4) | (c - 'a' + 0xa);
      else {
        server.send(200, "text/html", "NG");
        return;
      }
      if(i & 0x1) {
        //Serial.print(num, HEX);
        Serial.write(num);
        num = 0x0;
      }
    }
  }
	server.send(200, "text/html", "OK");
}

void setup() {
	delay(1000);
	Serial.begin(115200);
	Serial.println();
	//Serial.print("Configuring access point...");

	WiFi.softAP(ssid, password);

	IPAddress myIP = WiFi.softAPIP();
	//Serial.print("AP IP address: ");
	//Serial.println(myIP);
	server.on("/", handleRoot);
	server.begin();
	//Serial.println("HTTP server started");
}

void loop() {
	server.handleClient();
}

前回のソースから大した変更はなし。ひとまずこれで動ける。

はんだづけ

f:id:tohkaf:20151210005433p:plain

自分用のPSoC4の基板は、他基板との接続(I2C)とシフトレジスタの接続(SPI)にそれぞれSCBを割いているのでUART TX/RXを適当な場所にジャンパした。

あいにくI2CはSDAがTX、SCLがRXなのでピンソケットの実装のみでOKだった。

f:id:tohkaf:20151210005555j:plain

固定穴のない基板をケースに入れられないのでSparkFunのVS1053bモジュールをフリップしてマウントする中間基板も作った。MIDI受信用にフォトカプラTLP521とかコントラスト用抵抗も用意した。

f:id:tohkaf:20151210005838j:plain


あとはボタンと、ケースに取り付ける部品の配線ではんだづけ作業は終わりそうだ。