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

Added new "single track" modifier, fixed bug in dealing with duplicate OnPlayFinished events #58

Open
wants to merge 10 commits into
base: DEV
Choose a base branch
from

Conversation

joachimeichborn
Copy link

The new modifier stops playing after the current track has ended, no matter what mode is configured and how many tracks may be left in the folder.
The bug in handling duplicate OnPlayFinished events caused that handleNext methods from modifiers were called multiple times.
Apart from that, I improved logging and introduced mode and modifiers enums to make the code easier to understand for new developers - and to get a grasp of what is going on myself. With the plain integer numbers that were used previously I found itsometimes confusing because it's not directly visible if the number encodes a mode or a modifier.

Added context information to every Serial.print call where it was missing. Previously sometimes plain numbers were logged without any hint what they could mean.
Introduced enums to be used instead of magic ints to increase the comprehensibility of the code
Replaced if statements with switch, removed redundancies
Added a new modifier that TonUINO stops playing after the current track
The test was done after the call to the active modifier, so this was called twice. This can lead to unexpected behaviour of the modifiers. In fact the check can be moved to the Mp3Notify class. That way we also don't have to create random track numbers if the next button is pressed.
Added preprocessor directives that allow to simply activate a power led
@joachimeichborn
Copy link
Author

I forgot to mention that I have not added the required new mp3-file 0977_modifier_single_track.mp3 as I don't have access to a mac. So this would have to be added while merging the changes.

If buttons four and five are pressed long while nothing is played, the system behaves as if the non-modifier card that was used the last time was used again. So it's possible to continue a card after the system went into sleep without having to use the card.
Set five button mode, changed button five pin, removed mp3.sleep
@hvdh2
Copy link
Contributor

hvdh2 commented Mar 5, 2020

I already made a pull request to introduce enums for playback modes over a year ago. The code is very poorly readable without. Sadly, it still isn't merged yet.

@@ -114,6 +123,38 @@ class Mp3Notify {
}
};

enum Mode {
// Hörspielmodus: eine zufällige Datei aus dem Ordner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to have the comments right of the enums.

mfrc522.PCD_StopCrypto1();
adminMenu(true);
break;
case SLEEP_TIMER:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the old single line code here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants