revised version of F746_SD_GraphicEqualizer
Dependencies: BSP_DISCO_F746NG F746_GUI F746_SAI_IO FrequencyResponseDrawer LCD_DISCO_F746NG SDFileSystem_Warning_Fixed TS_DISCO_F746NG mbed
Fork of F746_SD_GraphicEqualizer by
Diff: MyClasses_Functions/FileSelectorWav.hpp
- Revision:
- 10:fc6367c2ffcf
- Parent:
- 8:12aa05f3cc24
- Child:
- 12:87f6955b5a80
diff -r 0d5bd1539291 -r fc6367c2ffcf MyClasses_Functions/FileSelectorWav.hpp --- a/MyClasses_Functions/FileSelectorWav.hpp Mon May 09 13:48:33 2016 +0000 +++ b/MyClasses_Functions/FileSelectorWav.hpp Wed Jun 22 03:50:38 2016 +0000 @@ -16,6 +16,7 @@ #include <algorithm> // sort() で使用 #include <string> + namespace Mikami { class FileSelector @@ -25,7 +26,7 @@ int maxNameLength, SD_WavReader &reader) : X_(x0), Y_(y0), W_H_(24), V_L_(36), MAX_FILES_(maxFiles), MAX_NAME_LENGTH_(maxNameLength), - BASE_COLOR_(0xFF80FFA0), TOUCHED_COLOR_(0xFF80FFFF), + BASE_COLOR_(0xFFDBAD17), TOUCHED_COLOR_(0xFFF8F8FB), fileNames_(new string[maxFiles]), sortedFileNames_(new string[maxFiles]), nonString_(NULL), rect_(NULL), fileNameLabels_(NULL), @@ -42,7 +43,15 @@ delete[] sortedFileNames_; delete[] fileNames_; } - +// ren: show a string + void ren_Msg(int pos, char msg[]) + { int lin, y_pos[7]= {0,70,130,160,190,220,250}; + if(pos<0) lin=0; + else if (pos>6) lin=6; + else lin=pos; + Label renLabel(240, y_pos[lin], msg, Label::CENTER,Font20); + } + bool CreateTable() { DIR* dp = opendir("/sd"); @@ -50,7 +59,8 @@ if (dp != NULL) { dirent* entry; - for (int n=0; n<256; n++) + // ren: change n<256 to n<2560 + for (int n=0; n<2560; n++) { entry = readdir(dp); if (entry == NULL) break; @@ -60,13 +70,24 @@ (strName.find(".WAV") != string::npos) ) { sdReader_.Open(strName); // ファイルオープン - +/**{ +char tmpmsg[500]; +sprintf(tmpmsg, "1..found a file: %s", strName.c_str()); +ren_Msg(1,tmpmsg); +sprintf(tmpmsg, "2..fileCount_: %d", fileCount_); +ren_Msg(2,tmpmsg); +}**/ // PCM,16 ビットステレオ,標本化周波数 44.1 kHz 以外のファイルは除外 if (sdReader_.IsWavFile()) { fileNames_[fileCount_] = strName; fileCount_++; } +/**{ +char tmpmsg[500]; +sprintf(tmpmsg, "fileCount_: %d", fileCount_); +ren_Msg(3, tmpmsg); +}**/ sdReader_.Close(); } @@ -87,16 +108,17 @@ if (rect_ != NULL) delete rect_; rect_ = new ButtonGroup(X_, Y_, W_H_, W_H_, fileCount_, nonString_, 0, V_L_-W_H_, 1, - -1, Font12, 0, GuiBase::ENUM_BACK, + -1, true,Font12, 0, GuiBase::ENUM_BACK, BASE_COLOR_, TOUCHED_COLOR_); for (int n=0; n<fileCount_; n++) rect_->Erase(n); CreateLabels(); prevFileCount_ = fileCount_; + return true; } // ファイルを選択する - bool Select(string &fileName) + bool Select(string fileList[],int *idx) { int n; if (rect_->GetTouchedNumber(n)) @@ -105,7 +127,10 @@ if ((prev_ >= 0) && (prev_ != n)) fileNameLabels_[prev_]->Draw(GetFileNameNoExt(prev_)); prev_ = n; - fileName = sortedFileNames_[n]; + *idx = n; + for (int n=0; n<fileCount_; n++) fileList[n] = sortedFileNames_[n]; +// fileName = sortedFileNames_[n]; +//printf("\nSelected file : %s", fileName); return true; } else