Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem_Warning_Fixed
Diff: SD_PlayerSkeleton.cpp
- Revision:
- 6:6fe2b62f259d
- Parent:
- 5:7c8f0fc9dfb6
- Child:
- 7:930d50953ec2
--- a/SD_PlayerSkeleton.cpp Tue Nov 08 05:03:43 2016 +0000
+++ b/SD_PlayerSkeleton.cpp Wed Nov 09 13:19:52 2016 +0000
@@ -1,7 +1,7 @@
//--------------------------------------------------------------
// SD プレーヤー用抽象基底クラス
//
-// 2016/11/08, Copyright (c) 2016 MIKAMI, Naoki
+// 2016/11/09, Copyright (c) 2016 MIKAMI, Naoki
//--------------------------------------------------------------
#include "SD_PlayerSkeleton.hpp"
@@ -27,13 +27,13 @@
else reset_ = NULL;
}
+ // SD プレーヤーの処理の実行
void SD_PlayerSkeleton::Execute()
{
bool playAfterPause = false;
int32_t loopCount;
- while (!menu_.Touched(0)) // OPEN がタッチされるまで待つ
- CheckCtrl();
+ WaitTouched(0); // OPEN がタッチされるまで待つ
SelectFile();
bool whileFirst = true;
@@ -44,16 +44,12 @@
if (!whileFirst) // while ループで初回の処理ではない場合
{
menu_.Activate(1); // PLAY ボタン有効
- int touch10;
- while (!menu_.GetTouchedNumber(touch10))
- CheckCtrl();
- if (touch10 == 0) SelectFile();
+ if (WaitTouched() == 0) SelectFile();
}
whileFirst = false;
loopCount = SD_Open();
- while (!menu_.Touched(1)) // PLAY がタッチされるまで待つ
- CheckCtrl();
+ WaitTouched(1); // PLAY がタッチされるまで待つ
}
else // PAUSE 後の PLAY の場合
loopCount = SD_Open();
@@ -75,6 +71,7 @@
mySai_.PlayOut(); // Play 開始
+ // ファイルのデータがなくなるまで繰り返す
for (int k=0; k<loopCount; k++)
{
int touch42 = -1;
@@ -87,10 +84,7 @@
mySai_.PauseOut();
// PLAY か RESUME か STOP がタッチされるまで待つ
- int touch134 = -1;
- while (!menu_.GetTouchedNumber(touch134))
- CheckCtrl();
- switch (touch134)
+ switch (WaitTouched())
{
case 1: playAfterPause = true; // 最初から PLAY
break;
@@ -105,7 +99,7 @@
}
if (playAfterPause || stopOk) break;
- CheckCtrl();
+ DoIfHandled();
// アプリ固有の1フレーム分の信号処理(純粋仮想関数)
SignalProcessing();
}
@@ -120,7 +114,7 @@
}
}
- // 拡張子を除いたファイル名を取得
+ // 選択されたファイル名から拡張子を除いたものを取得
string SD_PlayerSkeleton::GetFileNameNoExt()
{
string fName = fileName_;
@@ -152,10 +146,18 @@
while (!menu_.Touched(1)); // PLAY ボタンがタッチされるまで繰り返す
}
- // パネル操作のチェック
- void SD_PlayerSkeleton::CheckCtrl()
+ // パネルが操作された場合の処理
+ void SD_PlayerSkeleton::DoIfHandled()
{
if (reset_ != NULL) reset_->Do();
Modefy(); // アプリ固有のパラメータ変更(仮想関数)
}
+
+ // メニュ-のボタンがタッチされるまで DoIfHandled() を実行しながら待つ
+ int SD_PlayerSkeleton::WaitTouched()
+ {
+ int touchNum;
+ while (!menu_.GetTouchedNumber(touchNum)) DoIfHandled();
+ return touchNum;
+ }
}