Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue_193: Hoerbuch mode: after playing last track it does not change to first track on next start #194

Merged
merged 2 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.6 geän

# Change Log

## Version 3.1.7 (08.04.2024)
## Version 3.1.7 (11.04.2024)
- [Issue 193](https://github.com/tonuino/TonUINO-TNG/issues/193): Hoerbuch mode: after playing last track it does not change to first track on next start
- [Issue 190](https://github.com/tonuino/TonUINO-TNG/issues/190): Neo Pixel Ring: Add the possibility to have 2 rings remains
- [Issue 188](https://github.com/tonuino/TonUINO-TNG/issues/188): Pause when card removed modus: do not go to Play via button if card is not present

Expand Down
2 changes: 1 addition & 1 deletion TonUINO-TNG.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void setup()
LOG(init_log, s_error, F("TonUINO Version 3.1 - refactored by Boerge1\n"));
LOG(init_log, s_error, F("created by Thorsten Voß and licensed under GNU/GPL."));
LOG(init_log, s_error, F("Information and contribution at https://tonuino.de.\n"));
LOG(init_log, s_error, F("V3.1.7 08.04.24\n"));
LOG(init_log, s_error, F("V3.1.7 11.04.24\n"));

Tonuino::getTonuino().setup();
}
Expand Down
7 changes: 4 additions & 3 deletions src/tonuino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,14 @@ void Tonuino::nextTrack(uint8_t tracks, bool fromOnPlayFinished) {
LOG(play_log, s_info, F("nextTrack"));
if (activeModifier->handleNext())
return;
if (fromOnPlayFinished && mp3.isPlayingFolder() && myFolder.mode == pmode_t::hoerbuch_1) {
if (fromOnPlayFinished && mp3.isPlayingFolder() && (myFolder.mode == pmode_t::hoerbuch || myFolder.mode == pmode_t::hoerbuch_1)) {
const uint8_t trackToSave = (mp3.getCurrentTrack() < numTracksInFolder) ? mp3.getCurrentTrack()+1 : 1;
settings.writeFolderSettingToFlash(myFolder.folder, trackToSave);
mp3.clearFolderQueue();
if (myFolder.mode == pmode_t::hoerbuch_1)
mp3.clearFolderQueue();
}
mp3.playNext(tracks, fromOnPlayFinished);
if (mp3.isPlayingFolder() && (myFolder.mode == pmode_t::hoerbuch || myFolder.mode == pmode_t::hoerbuch_1)) {
if (not fromOnPlayFinished && mp3.isPlayingFolder() && (myFolder.mode == pmode_t::hoerbuch || myFolder.mode == pmode_t::hoerbuch_1)) {
settings.writeFolderSettingToFlash(myFolder.folder, mp3.getCurrentTrack());
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/src/mp3_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class mp3_test_fixture: public ::testing::Test {
{
mp3.reset_to_initial_state();
mp3.clearAllQueue();
folderSettings card = { 1, pmode_t::album, 0, 0 };
tonuino.setMyFolder(card, true);
}

void execute_cycle() {
Expand Down
4 changes: 2 additions & 2 deletions test/src/tonuino_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ class tonuino_fixture: public ::testing::Test {
}
}

void goto_play(const folderSettings& card) {
void goto_play(const folderSettings& card, uint16_t track_count = 99) {
goto_idle();
card_in(card);
card_in(card, track_count);
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());

// play t_262_pling
Expand Down
55 changes: 55 additions & 0 deletions test/src/tonuino_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,3 +1121,58 @@ TEST_F(tonuino_test_fixture, next_previous_in_play_hoerbuch) {

}

// =================== end of hoerbuch
TEST_F(tonuino_test_fixture, end_play_hoerbuch) {
const uint8_t folder = 5;
uint8_t track_count = 10;
folderSettings card = { folder, pmode_t::hoerbuch, 0, 0 };
getSettings().writeFolderSettingToFlash(folder, track_count); // last track
goto_play(card, track_count);
EXPECT_EQ(getSettings().readFolderSettingFromFlash(folder), track_count);
Print::clear_output();

// nothing happen on next button
button_for_command(command::next, state_for_command::play);
execute_cycle_for_ms(time_check_play);
EXPECT_TRUE(getMp3().is_playing_folder());
EXPECT_EQ(getMp3().df_folder, card.folder);
EXPECT_EQ(getMp3().df_folder_track, track_count);
EXPECT_EQ(getSettings().readFolderSettingFromFlash(folder), track_count);

// end if finished
getMp3().end_track();
execute_cycle();
EXPECT_TRUE(getMp3().is_stopped());
EXPECT_TRUE(SM_tonuino::is_in_state<Idle>());
EXPECT_EQ(getSettings().readFolderSettingFromFlash(folder), 1);

card_out();
}

TEST_F(tonuino_test_fixture, end_play_hoerbuch_1) {
const uint8_t folder = 5;
uint8_t track_count = 10;
folderSettings card = { folder, pmode_t::hoerbuch_1, 0, 0 };
getSettings().writeFolderSettingToFlash(folder, track_count); // last track
goto_play(card, track_count);
EXPECT_EQ(getSettings().readFolderSettingFromFlash(folder), track_count);
Print::clear_output();

// nothing happen on next button
button_for_command(command::next, state_for_command::play);
execute_cycle_for_ms(time_check_play);
EXPECT_TRUE(getMp3().is_playing_folder());
EXPECT_EQ(getMp3().df_folder, card.folder);
EXPECT_EQ(getMp3().df_folder_track, track_count);
EXPECT_EQ(getSettings().readFolderSettingFromFlash(folder), track_count);

// end if finished
getMp3().end_track();
execute_cycle();
EXPECT_TRUE(getMp3().is_stopped());
EXPECT_TRUE(SM_tonuino::is_in_state<Idle>());
EXPECT_EQ(getSettings().readFolderSettingFromFlash(folder), 1);

card_out();
}