Added serial command ids; id-to-folder mapping now works.

This commit is contained in:
2019-11-13 06:51:38 +01:00
parent 0531b599fe
commit e20e6b7d3e
4 changed files with 45 additions and 32 deletions

View File

@ -66,7 +66,7 @@ void Controller::_check_rfid() {
_no_rfid_card_count = 0;
String temp = String(uid, HEX);
String s_uid = "";
for (int i=0; i<(8-s_uid.length()); i++) {
for (int i=0; i<(8-temp.length()); i++) {
s_uid.concat("0");
}
s_uid.concat(temp);
@ -125,6 +125,8 @@ void Controller::_execute_serial_command(String cmd) {
_player->track_prev();
} else if (cmd.equals("n")) {
_player->track_next();
} else if (cmd.equals("ids")) {
_execute_command_ids();
} else {
ERROR("Unknown command: %s\n", cmd.c_str());
}
@ -134,15 +136,22 @@ void Controller::_execute_serial_command(String cmd) {
void Controller::_execute_command_ls(String path) {
INFO("Listing contents of %s:\n", path.c_str());
std::list<String> files = _player->ls(path);
for(std::list<String>::iterator it=files.begin(); it!=files.end(); it++) {
for(std::list<String>::iterator it=files.begin(); it!=files.end(); ++it) {
INFO(" %s\n", (*it).c_str());
}
}
void Controller::_execute_command_ids() {
for (std::map<String, String>::iterator it = _player->id_to_folder_map.begin(); it!=_player->id_to_folder_map.end(); ++it) {
INFO(" %s -> %s\n", it->first.c_str(), it->second.c_str());
}
}
void Controller::_execute_command_help() {
INFO("Valid commands are:");
INFO(" help - Displays this help\n");
INFO(" ls [dir] - Lists the contents of [dir] or, if not given, of /\n");
INFO(" ids - Lists all known ID-to-folder mappings\n");
INFO(" play [id] - Plays the album with the given id\n");
INFO(" sys [file]- Plays the file as system sound\n");
INFO(" stop - Stops playback\n");