0
0

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.

APPTVRepeater (ESP8266) > ソフトウェア v0.5 > Apple Remote SenderはGitHubへ | メインプログラム修正

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

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

APPTVRepeater (ESP8266) > ソフトウェア v0.4 > Repeaterとしのて機能は実装完了
の続き。

Apple Remote Sender on GitHub

Apple Remote Senderの処理部分を以下に上げた。
GitHub

License: GPL v3.

もともとのコードがGPL v3なので、それにならってGPL v3とした。

元コードの作者に連絡済で、問題があれば対応をする。
(追記: 2017/10/06 作者からの連絡あり。問題はなさそう)。

メインプログラム v0.5

# define KEY_MENU (0x01)
# define KEY_PLAY (0x02)

のような定義はメインプログラムに置くものでもなかった。
Apple Remote Senderのヘッダーに移した。

それによりメインプログラムは以下のようになった。

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

//#define USE_REGISTER // to register to Apple TV at first

/*
 * v0.5 Sep. 23, 2017
 *   - move [KEY_XXX] definitions to [AppleRemoteSender.h]
 * v0.4 Sep. 23, 2017
 *   - repeat 5 seconds (LEFT and PLAY)
 * v0.3 Sep. 23, 2017
 *   - send keys to register ESP8266 remote controller to Apple TV
 * 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;

# define BACK_SEC (5)

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

  APPTV_setup(kPinIR);
}

static const int keylist[] = {
  KEY_UP,
  KEY_DOWN,
  KEY_LEFT,
  KEY_RIGHT,
  KEY_PLAY, // SELECT
  KEY_MENU,
};

void RegisterController(void)
{
  static int pos = 0;
  
  int size_key = sizeof(keylist) / sizeof(keylist[0]);
  
  delay(2000); // msec

  if (pos >= 0) {
    Serial.println(F("Send Key")); // F() to reduce RAM usage  
    for(int loop=0; loop < 20; loop++) {
      APPTV_SendKey(kPinIR, keylist[pos]);
      delay(100); // msec
    }
    pos++;
    if (pos == size_key) {
      pos = -1;
    }
  }
}

void RepeatSeconds()
{
    static int start = 1;

    if (start != 1) {
      return;
    }
    
    APPTV_SendKey(kPinIR, KEY_LEFT);
    delay(100); // msec

    delay(BACK_SEC * 1000 * 0.38); // msec (0.38: adjusted to 5 seconds interval)
  
    APPTV_SendKey(kPinIR, KEY_PLAY);
    delay(100); // msec

    start = 0;
}

void loop() {
  static int pos = 0;
  int size_key = sizeof(keylist) / sizeof(keylist[0]);
  
  delay(2000); // msec

# ifdef USE_REGISTER
  RegisterController();
# else
  RepeatSeconds();
# endif
}
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?