LoginSignup
0
0

More than 5 years have passed since last update.

APPTVRepeater (ESP8266) > ソフトウェア v0.1, v0.2 > 上ボタン押下の送信は成功

Last updated at Posted at 2017-09-23
動作確認
- ESP-WROOM-02 (以下、ESP8266)
- ユニーバサル基板実装
- Arduino IDE 1.6.6
- Canon IXY 3

開始: ESP8266 > 検討 > APPTVRepeater > 英語リスニング補助ツール (定数時間の巻き戻し機能)

APPTVRepeater > ハードウェアの準備 > 赤外線送信基板の実装 (x2)と動作確認
の続き。

リモコンの登録

Apple TVで赤外線通信の試験を行うには、そのリモコンを登録しないといけないことが分かった。

Apple TVの
設定 > 一般 > リモコン > リモコンを追加 > 開始
にて
上、下、左、右、SELECT、MENU
を順番に長押しする。

この機能を使って、上ボタン押下送信テストをした。

上ボタン押下の送信コード

色々情報があったが、以下を送れば良さそう。
(参考: https://en.wikipedia.org/wiki/Apple_Remote の Technical details)

0x87EE790a

上記はそれぞれの値を以下の計算から求めた。

#include <stdio.h>
#include <stdint.h>

#define BIT_VENDOR (11)
#define BIT_COMMAND_PAGE (5)
#define BIT_DEVICE_ID (8)
#define BIT_CONTROL_COMMAND (7)
#define BIT_ODD_PARITY (1)

int calc_oddParity(uint32_t target)
{
    uint32_t temp = target;
    int cnt = 0;
    for(int loop=0; loop<32; loop++) {
        cnt += ((temp & 0x01) > 0);
        temp >>= 1;
    }
    if (cnt % 2 == 0) {
        return 1;
    } else {
        return 0;   
    }
}

void print_32bit()
{
    int vendor = 0x43F; // apple
    int cmdpage = 0x0e; // page for up command
    int devid = 0x79; // device id
    int ctrlcmd = 0x05; // up command
    int odd;
    uint32_t snd;

    snd = vendor;

    snd <<= BIT_COMMAND_PAGE;
    snd |= cmdpage;

    snd <<= BIT_DEVICE_ID;
    snd |= devid;

    snd <<= BIT_CONTROL_COMMAND;
    snd |= ctrlcmd;

    snd <<= BIT_ODD_PARITY;

    //snd = 0x101 << 1; // debug

    snd |= calc_oddParity(snd);


    printf("%x\n", snd);
}

int main() {
    print_32bit();

    return 0;
}
run
87ee790a

device idは適当に79とした。

ESP8266プログラム

esp8266_170923_APPTVrepeater
#include <ESP8266WiFi.h>
#include "AppleRemoteSender.h"

/*
 * v0.2 Sep. 23, 2017
 *   - send UP signal to register the remote controller
 * v0.1 Sep. 23, 2017
 *   - turn on/off the IR pin to check the device
 */

static const int kPinIR = 4;

void setup() {
  WiFi.disconnect(); // watch dog reset対処
  Serial.begin(115200);
  pinMode(kPinIR, OUTPUT);

  APPTV_setup(kPinIR);
}

void loop() {
  static int cnt = 0;

  delay(1000); // msec

  //cnt++;
  //if (cnt == 10) {
    Serial.println(F("PLAY")); // F() to reduce RAM usage
    cnt = 0;

    for(int loop=0; loop < 10; loop++) {
      APPTV_Upper(kPinIR);
      delay(100); // msec
    }
  //}
}

上記のAPPTV_Upper(kPinIR);の処理は、別のタブにて実装している。
コードが未整備のため、公開向けでないため未掲載。
整理して公開はしたいと思う。

APPTV_Upper()にて0x87ee790aをWikipediaのタイミングにてLSBで送信する。

基板の動作確認

APPTVRepeater > ハードウェアの準備 > 赤外線送信基板の実装 (x2)と動作確認
で実装した二枚の基板は両方とも動作した。

2.5m程度の距離でも上ボタン押下は認識されている。

0
0
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
0
0