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
Dependents: DISCO-F746_WAV_PLAYER WAV
Diff: FileSelectorWav.hpp
- Revision:
- 0:d310bb78455d
- Child:
- 2:511479736d6e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FileSelectorWav.hpp Mon Aug 15 04:38:45 2016 +0000
@@ -0,0 +1,71 @@
+//--------------------------------------------------------------
+// FileSelector class ---- Header ----
+// SD カード内のファイル名の一覧を表示し,ファイルを選択する
+//
+// 2016/07/27, Copyright (c) 2016 MIKAMI, Naoki
+//--------------------------------------------------------------
+
+#ifndef FILE_SELECTOR_HPP
+#define FILE_SELECTOR_HPP
+
+#include "F746_GUI.hpp"
+#include "SD_WavReader.hpp"
+#include <algorithm> // sort() で使用
+#include <string>
+
+namespace Mikami
+{
+ class FileSelector
+ {
+ public:
+ FileSelector(uint8_t x0, uint8_t y0, int maxFiles,
+ 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),
+ fileNames_(maxFiles),
+ rect_(NULL), lcd_(GuiBase::GetLcdPtr()),
+ sdReader_(reader), prevFileCount_(0), prev_(-1) {}
+
+ virtual ~FileSelector()
+ { delete rect_; }
+
+ bool CreateTable();
+
+ // ファイルを選択する
+ bool Select(string &fileName);
+
+ // ファイルの一覧の表示
+ void DisplayFileList(bool sortEnable = true);
+
+ // ファイルの一覧の消去
+ void Erase(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
+ uint32_t color = GuiBase::ENUM_BACK);
+
+ private:
+ const uint8_t X_, Y_, W_H_, V_L_;
+ const int MAX_FILES_;
+ const int MAX_NAME_LENGTH_;
+ const uint32_t BASE_COLOR_;
+ const uint32_t TOUCHED_COLOR_;
+
+ Array<string> fileNames_;
+ ButtonGroup *rect_;
+ Array<Label *> fileNameLabels_;
+ LCD_DISCO_F746NG *lcd_;
+ SD_WavReader &sdReader_;
+ int fileCount_, prevFileCount_;
+ int prev_;
+
+ // Label を生成
+ void CreateLabels();
+
+ // 拡張子を削除した文字列を取得
+ string GetFileNameNoExt(int n);
+
+ // disallow copy constructor and assignment operator
+ FileSelector(const FileSelector&);
+ FileSelector& operator=(const FileSelector&);
+ };
+}
+#endif // FILE_SELECTOR_HPP