Skip to content

Commit

Permalink
Merge pull request #241: Issue 239: Starting Quiz or Memory game the …
Browse files Browse the repository at this point in the history
…"pling" is missing
  • Loading branch information
boerge1 authored Oct 13, 2024
2 parents 9a8c923 + bb82e72 commit 93e4881
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 39 deletions.
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.11 geä

# Change Log

## Version 3.2.1 (22.09.2024)
## Version 3.2.1 (12.10.2024)
- [Issue 239](https://github.com/tonuino/TonUINO-TNG/issues/239): Starting Quiz or Memory game the "pling" is missing
- [Issue 236](https://github.com/tonuino/TonUINO-TNG/issues/236): Improve hardware diagnostic on startup

## Version 3.2.0 (05.09.2024)
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.2.1 22.09.24\n"));
LOG(init_log, s_error, F("V3.2.1 12.10.24\n"));

#ifdef TonUINO_Classic
LOG(init_log, s_error, F("C "), lf_no);
Expand Down
30 changes: 14 additions & 16 deletions src/state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,19 +533,19 @@ bool Base::handleShortcut(uint8_t shortCut) {
#ifdef QUIZ_GAME
if (tonuino.getMyFolder().mode == pmode_t::quiz_game) {
LOG(state_log, s_debug, str_Base(), str_to(), str_Quiz());
transit<Quiz>();
transit<StartPlay<Quiz>>();
return true;
}
#endif // QUIZ_GAME
#ifdef MEMORY_GAME
if (tonuino.getMyFolder().mode == pmode_t::memory_game) {
LOG(state_log, s_debug, str_Base(), str_to(), str_Memory());
transit<Memory>();
transit<StartPlay<Memory>>();
return true;
}
#endif // MEMORY_GAME
LOG(state_log, s_debug, str_Base(), str_to(), str_StartPlay());
transit<StartPlay>();
transit<StartPlay<Play>>();
return true;
}
}
Expand All @@ -560,19 +560,19 @@ void Base::handleReadCard() {
#ifdef QUIZ_GAME
if (tonuino.getMyFolder().mode == pmode_t::quiz_game) {
LOG(state_log, s_debug, str_Base(), str_to(), str_Quiz());
transit<Quiz>();
transit<StartPlay<Quiz>>();
return;
}
#endif // QUIZ_GAME
#ifdef MEMORY_GAME
if (tonuino.getMyFolder().mode == pmode_t::memory_game) {
LOG(state_log, s_debug, str_Base(), str_to(), str_Memory());
transit<Memory>();
transit<StartPlay<Memory>>();
return;
}
#endif // MEMORY_GAME
LOG(state_log, s_debug, str_Base(), str_to(), str_StartPlay());
transit<StartPlay>();
transit<StartPlay<Play>>();
}
}

Expand Down Expand Up @@ -655,19 +655,19 @@ void Idle::react(command_e const &cmd_e) {
#ifdef QUIZ_GAME
if (tonuino.getMyFolder().mode == pmode_t::quiz_game) {
LOG(state_log, s_debug, str_Base(), str_to(), str_Quiz());
transit<Quiz>();
transit<StartPlay<Quiz>>();
return;
}
#endif // QUIZ_GAME
#ifdef MEMORY_GAME
if (tonuino.getMyFolder().mode == pmode_t::memory_game) {
LOG(state_log, s_debug, str_Base(), str_to(), str_Memory());
transit<Memory>();
transit<StartPlay<Memory>>();
return;
}
#endif // MEMORY_GAME
LOG(state_log, s_debug, str_Idle(), str_to(), str_StartPlay());
transit<StartPlay>();
transit<StartPlay<Play>>();
return;
}
break;
Expand All @@ -676,7 +676,7 @@ void Idle::react(command_e const &cmd_e) {
case command::specialStart:
tonuino.setMyFolder({specialStartShortcutFolder, pmode_t::einzel, specialStartShortcutTrack, 0}, true /*myFolderIsCard*/);
LOG(state_log, s_debug, str_Idle(), str_to(), str_StartPlay());
transit<StartPlay>();
transit<StartPlay<Play>>();
break;
#endif
default:
Expand Down Expand Up @@ -870,20 +870,20 @@ void Pause::react(card_e const &c_e) {

// #######################################################

void StartPlay::entry() {
template<class P> void StartPlay<P>::entry() {
LOG(state_log, s_info, str_enter(), str_StartPlay());
mp3.enqueueMp3FolderTrack(mp3Tracks::t_262_pling);
timer.stop();
}

void StartPlay::react(command_e const &/*cmd_e*/) {
template<class P> void StartPlay<P>::react(command_e const &/*cmd_e*/) {
if (timer.isActive()) {
if (timer.isExpired()) {
LOG(state_log, s_debug, str_StartPlay(), str_to(), str_Play());
if ((settings.pauseWhenCardRemoved==1) && chip_card.isCardRemoved() && tonuino.playingCard())
if (is_same_type<P, Play>::value && (settings.pauseWhenCardRemoved==1) && chip_card.isCardRemoved() && tonuino.playingCard())
transit<Pause>();
else
transit<Play>();
transit<P>();
return;
}
}
Expand All @@ -899,7 +899,6 @@ void Quiz::entry() {
LOG(state_log, s_info, str_enter(), str_Quiz());
tonuino.disableStandbyTimer();
tonuino.resetActiveModifier();
tonuino.playFolder();
numAnswer = tonuino.getMyFolder().special;
numSolution = tonuino.getMyFolder().special2;
if (numAnswer != 0 and numAnswer != 2 and numAnswer != 4) {
Expand Down Expand Up @@ -1141,7 +1140,6 @@ void Memory::entry() {
LOG(state_log, s_info, str_enter(), str_Memory());
tonuino.disableStandbyTimer();
tonuino.resetActiveModifier();
tonuino.playFolder();
first = 0;
second = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Idle: public Base
void react(card_e const &) override;
};

class StartPlay: public Base
template<class P> class StartPlay: public Base
{
public:
void entry() override;
Expand Down
9 changes: 8 additions & 1 deletion src/tonuino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,14 @@ void Tonuino::loop() {
#endif // NEO_RING_EXT
if (SM_tonuino::is_in_state<Idle>())
ring.call_on_idle();
else if (SM_tonuino::is_in_state<StartPlay>())
else if (SM_tonuino::is_in_state<StartPlay<Play>>()
#ifdef QUIZ_GAME
|| SM_tonuino::is_in_state<StartPlay<Quiz>>()
#endif
#ifdef MEMORY_GAME
|| SM_tonuino::is_in_state<StartPlay<Memory>>()
#endif
)
ring.call_on_startPlay();
else if (SM_tonuino::is_in_state<Play>())
ring.call_on_play();
Expand Down
4 changes: 2 additions & 2 deletions test/src/modifier_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ TEST_F(tonuino_test_fixture, ToddlerMode_in_idle) {
EXPECT_TRUE(SM_tonuino::is_in_state<Idle>());

card_in({ 3, pmode_t::einzel, 4, 0 });
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());
leave_start_play();
EXPECT_TRUE(SM_tonuino::is_in_state<Play>());
EXPECT_TRUE(getMp3().is_playing_folder());
Expand Down Expand Up @@ -291,7 +291,7 @@ TEST_F(tonuino_test_fixture, ToddlerMode_in_play) {
EXPECT_TRUE(SM_tonuino::is_in_state<Play>());

card_in({ 3, pmode_t::einzel, 4, 0 });
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());
leave_start_play();
EXPECT_TRUE(SM_tonuino::is_in_state<Play>());
EXPECT_TRUE(getMp3().is_playing_folder());
Expand Down
6 changes: 3 additions & 3 deletions test/src/tonuino_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ class tonuino_fixture: public ::testing::Test {
void goto_play(const folderSettings& card, uint16_t track_count = 99) {
goto_idle();
card_in(card, track_count);
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());

// play t_262_pling
execute_cycle();
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());
EXPECT_TRUE(getMp3().is_playing_mp3());
EXPECT_EQ(getMp3().df_mp3_track, static_cast<uint16_t>(mp3Tracks::t_262_pling));

Expand Down Expand Up @@ -422,7 +422,7 @@ class tonuino_fixture: public ::testing::Test {
void leave_start_play() {
// play t_262_pling
execute_cycle();
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());
EXPECT_TRUE(getMp3().is_playing_mp3());
EXPECT_EQ(getMp3().df_mp3_track, static_cast<uint16_t>(mp3Tracks::t_262_pling));

Expand Down
28 changes: 14 additions & 14 deletions test/src/tonuino_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_F(tonuino_test_fixture, sunny_day_play) {
Print::clear_output();

card_in(card, track_count);
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());

leave_start_play();

Expand Down Expand Up @@ -272,7 +272,7 @@ TEST_F(tonuino_test_fixture, shortcutx_in_idle) {
// button shortcutx
button_for_command(cmd, state_for_command::idle_pause);

EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());

leave_start_play();

Expand Down Expand Up @@ -305,7 +305,7 @@ TEST_F(tonuino_test_fixture, shortcutx_in_pause) {
// button shortcut
button_for_command(cmd, state_for_command::idle_pause);

EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());

leave_start_play();

Expand Down Expand Up @@ -341,7 +341,7 @@ TEST_F(tonuino_test_fixture, shortcut3x3_in_idle) {
reset_value_for_3x3();
execute_cycle();

ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << index;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << index;

leave_start_play();

Expand Down Expand Up @@ -372,7 +372,7 @@ TEST_F(tonuino_test_fixture, shortcut3x3_in_idle) {
reset_value_for_3x3();
execute_cycle();

ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << index;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << index;

leave_start_play();

Expand Down Expand Up @@ -406,7 +406,7 @@ TEST_F(tonuino_test_fixture, shortcut3x3_in_pause) {
reset_value_for_3x3();
execute_cycle();

ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << index;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << index;

leave_start_play();

Expand Down Expand Up @@ -437,7 +437,7 @@ TEST_F(tonuino_test_fixture, shortcut3x3_in_pause) {
reset_value_for_3x3();
execute_cycle();

ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << index;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << index;

leave_start_play();

Expand Down Expand Up @@ -471,7 +471,7 @@ TEST_F(tonuino_test_fixture, shortcut3x3_in_play) {
reset_value_for_3x3();
execute_cycle();

ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << index;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << index;

leave_start_play();

Expand Down Expand Up @@ -502,7 +502,7 @@ TEST_F(tonuino_test_fixture, shortcut3x3_in_play) {
reset_value_for_3x3();
execute_cycle();

ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << index;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << index;

leave_start_play();

Expand Down Expand Up @@ -819,7 +819,7 @@ TEST_F(tonuino_test_fixture, pause_if_card_removed_works) {
Print::clear_output();

card_in(card, track_count);
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());

leave_start_play();

Expand Down Expand Up @@ -892,14 +892,14 @@ TEST_F(tonuino_test_fixture, pause_if_card_removed_card_out_early) {
Print::clear_output();

card_in(card, track_count);
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());

// card out
card_out();

// play t_262_pling
execute_cycle_for_ms(time_check_play);
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay>());
EXPECT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>());
EXPECT_TRUE(getMp3().is_playing_mp3());
EXPECT_EQ(getMp3().df_mp3_track, static_cast<uint16_t>(mp3Tracks::t_262_pling));

Expand Down Expand Up @@ -1001,7 +1001,7 @@ TEST_F(tonuino_test_fixture, pause_if_card_removed_card_in_with_other) {
Print::clear_output();

card_in(data.card1, track_count);
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << "Index: " << ind;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << "Index: " << ind;

leave_start_play();

Expand All @@ -1018,7 +1018,7 @@ TEST_F(tonuino_test_fixture, pause_if_card_removed_card_in_with_other) {

// card in other card --> StartPlay
card_in(data.card2, track_count);
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay>()) << "Index: " << ind;
ASSERT_TRUE(SM_tonuino::is_in_state<StartPlay<Play>>()) << "Index: " << ind;

leave_start_play();

Expand Down

0 comments on commit 93e4881

Please sign in to comment.