Fixed advent mode and persistence stuff.
This commit is contained in:
parent
4eef69516e
commit
51bef05465
@ -142,7 +142,8 @@ void Controller::_check_rfid() {
|
||||
if (time.tm_mon == 11) { // tm_mon is "months since january", so 11 means december.
|
||||
pl->advent_shuffle(time.tm_mday);
|
||||
} else {
|
||||
// TODO
|
||||
DEBUG("Album is in advent mode, but it isn't december (yet). Not playing.\n");
|
||||
return;
|
||||
}
|
||||
} else if (data.indexOf("[random]") != -1 && pl->is_fresh()) {
|
||||
pl->shuffle();
|
||||
|
@ -317,12 +317,19 @@ void Playlist::shuffle(uint8_t random_offset) {
|
||||
}
|
||||
|
||||
void Playlist::advent_shuffle(uint8_t day) {
|
||||
if (day > 24) day = 24;
|
||||
TRACE("advent_shuffle running...\n");
|
||||
|
||||
// Not enough songs till the current day? Play all songs in the default order.
|
||||
if (day > _files.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We are in the "different playlist every day" mode. So we don't persist it in order to not miss changes.
|
||||
persistence = PERSIST_NONE;
|
||||
|
||||
if (day > _files.size()) return;
|
||||
|
||||
_files.insert(_files.begin(), _files[day - 1]);
|
||||
_files.erase(_files.begin() + day - 1, _files.end());
|
||||
_files.erase(_files.begin() + day, _files.end());
|
||||
}
|
||||
|
||||
void Playlist::reset() {
|
||||
|
@ -109,7 +109,6 @@ Playlist* PlaylistManager::get_playlist_for_folder(String folder) {
|
||||
p = new Playlist(folder);
|
||||
_playlists[folder] = p;
|
||||
if (p->persistence == PERSIST_PERMANENTLY) {
|
||||
// TODO Load persistence from file
|
||||
String search = folder;
|
||||
search += "=";
|
||||
SPIMaster::select_sd();
|
||||
@ -197,7 +196,10 @@ String PlaylistManager::create_mapping_txt() {
|
||||
}
|
||||
|
||||
void PlaylistManager::persist(Playlist* p) {
|
||||
if (p->persistence != PERSIST_PERMANENTLY) return;
|
||||
if (p->persistence == PERSIST_NONE) {
|
||||
_playlists.erase(p->path());
|
||||
return;
|
||||
} else if (p->persistence == PERSIST_PERMANENTLY) {
|
||||
|
||||
String search = p->path();
|
||||
search += '=';
|
||||
@ -231,4 +233,7 @@ void PlaylistManager::persist(Playlist* p) {
|
||||
dst.println(p->get_position());
|
||||
dst.close();
|
||||
SPIMaster::select_sd(false);
|
||||
|
||||
_playlists.erase(p->path());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user