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 217: Improve and fix handling of some DF Player #218

Merged
merged 2 commits into from
Jul 31, 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,9 +90,10 @@ Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.10 geä

# Change Log

## Version 3.1.11 (30.07.2024)
## Version 3.1.11 (31.07.2024)
- [Issue 212](https://github.com/tonuino/TonUINO-TNG/issues/212): Sleep Timer Modification card doesn't work properly with NeoPixel Ring
- [Issue 215](https://github.com/tonuino/TonUINO-TNG/issues/215): New optional Feature: Support BT Modul
- [Issue 217](https://github.com/tonuino/TonUINO-TNG/issues/217): Improve and fix handling of some DF Player

## Version 3.1.10 (27.06.2024)
- [Issue 210](https://github.com/tonuino/TonUINO-TNG/issues/210): Make text in the admin menu for switching volume button more clearer
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.11 30.07.24\n"));
LOG(init_log, s_error, F("V3.1.11 31.07.24\n"));

#ifdef TonUINO_Classic
LOG(init_log, s_error, F("C "), lf_no);
Expand Down
13 changes: 12 additions & 1 deletion src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,18 @@
* um einen speziellen Chip auf dem DfMiniMp3 Player zu ünterstützen bitte in eine der nächste Zeilen den Kommentar entfernen
*
* GD3200B: bad behavior of getFolderTrackCount() - ignores the parameter folder
* bad behavior of callback OnPlayFinished - it is also called on advertise tracks
* MH2024K16SS: no checksums
* LISP3: bad behavior of callback OnPlayFinished - it is also called on advertise tracks (also on some MH2024K24SS)
* LISP3: bad behavior of callback OnPlayFinished - it is also called on advertise tracks
* MP3-TF-16P V3.0 with MH2024K24SS:
* very slow
* bad behavior of callback OnPlayFinished - it is also called on advertise tracks
* LKP Player: no ACK for requests (use Mp3ChipIncongruousNoAck for them)
*/
//#define DFMiniMp3_T_CHIP_GD3200B
//#define DFMiniMp3_T_CHIP_MH2024K16SS
//#define DFMiniMp3_T_CHIP_LISP3
//#define DFMiniMp3_T_CHIP_MH2024K24SS_MP3_TF_16P_V3_0
#define DFMiniMp3_T_CHIP_Mp3ChipIncongruousNoAck

// ######################################################################
Expand Down Expand Up @@ -377,7 +382,13 @@ inline constexpr uint8_t dfPlayer_transmitPin = 3;
inline constexpr uint8_t maxTracksInFolder = 255;
inline constexpr uint8_t dfPlayer_busyPin = 4;
inline constexpr levelType dfPlayer_busyPinType = levelType::activeHigh;
#if defined(DFMiniMp3_T_CHIP_MH2024K24SS_MP3_TF_16P_V3_0)
inline constexpr unsigned long dfPlayer_timeUntilStarts = 2500;
#elif defined(DFMiniMp3_T_CHIP_GD3200B)
inline constexpr unsigned long dfPlayer_timeUntilStarts = 1500;
#else
inline constexpr unsigned long dfPlayer_timeUntilStarts = 1000;
#endif

// ####### tonuino #####################################

Expand Down
7 changes: 4 additions & 3 deletions src/mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ void Mp3Notify::PrintlnSourceAction(DfMp3_PlaySources source, const __FlashStrin
}

void Mp3Notify::OnPlayFinished(DfMp3&, DfMp3_PlaySources /*source*/, uint16_t track) {
LOG(mp3_log, s_debug, F("Track beendet: "), track);
LOG(mp3_log, s_info, F("Track beendet: "), track);
if (track == lastTrackFinished)
return;
else
lastTrackFinished = track;
#ifdef DFMiniMp3_T_CHIP_LISP3
#ifdef DFMiniMp3_IGNORE_ONPLAYFINISHED_FOR_ADV
if (Tonuino::getTonuino().getMp3().resetPlayingAdv())
return;
#endif
Expand Down Expand Up @@ -88,7 +88,7 @@ void Mp3::waitForTrackToStart() {

void Mp3::playAdvertisement(uint16_t track, bool olnyIfIsPlaying) {
LOG(mp3_log, s_info, F("play adv: "), track);
#ifdef DFMiniMp3_T_CHIP_LISP3
#ifdef DFMiniMp3_IGNORE_ONPLAYFINISHED_FOR_ADV
advPlaying = true;
#endif
if (isPlaying()) {
Expand All @@ -101,6 +101,7 @@ void Mp3::playAdvertisement(uint16_t track, bool olnyIfIsPlaying) {
}
else {
Base::playFolderTrack(1, 1);
delay(dfPlayer_timeUntilStarts);
}
waitForTrackToStart();
LOG(mp3_log, s_debug, F("playAdvertisement: "), track);
Expand Down
8 changes: 6 additions & 2 deletions src/mp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class Mp3Notify;
#define DFMiniMp3_T_CHIP_VARIANT Mp3ChipIncongruousNoAck
#endif

#if defined(DFMiniMp3_T_CHIP_GD3200B) or defined(DFMiniMp3_T_CHIP_LISP3) or defined(DFMiniMp3_T_CHIP_MH2024K24SS_MP3_TF_16P_V3_0)
#define DFMiniMp3_IGNORE_ONPLAYFINISHED_FOR_ADV
#endif

// define a handy type using serial and our notify class
#ifdef DFMiniMp3_T_CHIP_VARIANT
using DfMp3 = DFMiniMp3<SerialType, Mp3Notify, DFMiniMp3_T_CHIP_VARIANT, 4000>;
Expand Down Expand Up @@ -209,7 +213,7 @@ class Mp3: public DfMp3 {
void clearAllQueue() { clearFolderQueue(); clearMp3Queue(); }
bool isPlayingFolder() { return playing == play_folder; }
bool isPlayingMp3 () { return playing == play_mp3 ; }
#ifdef DFMiniMp3_T_CHIP_LISP3
#ifdef DFMiniMp3_IGNORE_ONPLAYFINISHED_FOR_ADV
bool resetPlayingAdv() { bool ret = advPlaying; advPlaying = false; return ret; }
#endif
// firstTrack and lastTrack -> index in folder starting with 1
Expand Down Expand Up @@ -293,7 +297,7 @@ class Mp3: public DfMp3 {
Timer startTrackTimer{};
Timer missingOnPlayFinishedTimer{};
bool isPause{};
#ifdef DFMiniMp3_T_CHIP_LISP3
#ifdef DFMiniMp3_IGNORE_ONPLAYFINISHED_FOR_ADV
bool advPlaying{false};
#endif

Expand Down