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 1 year has passed since last update.

TFT_eSPIで複数ページ構成のプログラムを作ろう5

Posted at

TFT_eSPIで複数ページ構成のプログラムを作ろう4 の続きです。

路線に応じた駅名の表示が出来るようにします。

駅名表示を追加する

BVEのメトロ総合プラグインにおいて出力される駅名情報は、重複しており、コードにより区分されます。

駅名表示 【新方式】 一覧

http://www.nozomi.vc/71_ats/metro/station2.htm
今回は、路線の選択は自身で行う方法としました。

char rou;

を追加し識別します。

路線選定

  if (page == '8') { //first page function touch screen
    uint16_t x, y;
    static uint16_t color;
    int pressed = tft.getTouch(&x, &y);
    if (pressed) {
      if ((x > 45) && (x < 230)) {
        if ((y > 55) && (y < 105)) {
          rou = 1;
        }
      }
    }

駅選定

  tft.drawString(" 東  武 ", 80  , 70);
  tft.drawString(" 西  武 ", 320  , 70);
  tft.drawString(" 営  団 ", 80  , 125);
  tft.drawString(" 営  団 2 ", 320  , 125);
  tft.drawString("東急・横高", 70  , 180);
  tft.drawString("銀 座 線 ", 320  , 180);
  tft.drawString("非 表 示 ", 320  , 235);
        if (rou == 1) {
          if (dai2 == 2) {
            tft.drawString("   浅草        ", 100, 38);
          }

以上により路線に応じて駅名表示を行うようになりました。
さらに行先や終着駅における終着戸開けなどを追加しました。

音声再生機能を追加する

DFROBOTMP3ボイスモジュールDFR0534 を使用して自動放送を再現してみます。

DFR0534MP3 を保存し、シリアル通信で再生させます。

play(0x0x);

上記コードでMP3を再生できます。

宣言文

void play(unsigned char Track)
{
  unsigned char play[6] = {0xAA, 0x07, 0x02, 0x00, Track, Track + 0xB3};
//  Serial2.write(play, 6);
}

プログラム文

今までと同じく、タッチパネルの指定個所をタッチすることで、MP3を再生できるようになりました。

    if (pressed) {
      if ((x > 45) && (x < 230)) {
        if ((y > 55) && (y < 105)) {
          play(0x01);
        }
      }
    }

以上により自動放送が再生できるようになりました。

シリアル通信のポート部分をコメントアウトしています。

完成プログラム

動作の様子

作ったプログラムの動作の様子は以下になります。

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?