Skip to content

Commit 04cd047

Browse files
committed
Added chip variant function
1 parent d2fef15 commit 04cd047

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

src/DFPlayerMini_Fast.cpp

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ bool DFPlayerMini_Fast::begin(Stream &stream, bool debug, unsigned long threshol
7777

7878

7979

80+
/**************************************************************************/
81+
/*!
82+
@brief Set the chip variant status and delay.
83+
@param delayMs
84+
The delay in milliseconds for the send stack to allow the
85+
chip variant to process commands. The default is 1000
86+
(1 second).
87+
*/
88+
/**************************************************************************/
89+
void DFPlayerMini_Fast::setChipVariant(unsigned long delayMs = 1000)
90+
{
91+
isChipVariant = true; // Set the chip variant status for Mp3 Chip MH2024K-16SS
92+
stackDelay = delayMs; // Set the delay in milliseconds
93+
}
94+
95+
96+
97+
8098
/**************************************************************************/
8199
/*!
82100
@brief Play the next song in chronological order.
@@ -924,15 +942,26 @@ void DFPlayerMini_Fast::findChecksum(stack& _stack)
924942
/**************************************************************************/
925943
void DFPlayerMini_Fast::sendData()
926944
{
945+
// Wait for spacing only if chip variant
946+
if(isChipVariant)
947+
{
948+
delay(stackDelay);
949+
}
927950
_serial->write(sendStack.start_byte);
928951
_serial->write(sendStack.version);
929952
_serial->write(sendStack.length);
930953
_serial->write(sendStack.commandValue);
931954
_serial->write(sendStack.feedbackValue);
932955
_serial->write(sendStack.paramMSB);
933956
_serial->write(sendStack.paramLSB);
934-
_serial->write(sendStack.checksumMSB);
935-
_serial->write(sendStack.checksumLSB);
957+
958+
// Send checksum only if not chip variant
959+
if (!isChipVariant)
960+
{
961+
_serial->write(sendStack.checksumMSB);
962+
_serial->write(sendStack.checksumLSB);
963+
}
964+
936965
_serial->write(sendStack.end_byte);
937966

938967
if (_debug)
@@ -1198,8 +1227,14 @@ void DFPlayerMini_Fast::printStack(stack _stack)
11981227
Serial.print(_stack.feedbackValue, HEX); Serial.print(' ');
11991228
Serial.print(_stack.paramMSB, HEX); Serial.print(' ');
12001229
Serial.print(_stack.paramLSB, HEX); Serial.print(' ');
1201-
Serial.print(_stack.checksumMSB, HEX); Serial.print(' ');
1202-
Serial.print(_stack.checksumLSB, HEX); Serial.print(' ');
1230+
1231+
// Print checksum only if not chip variant
1232+
if (!isChipVariant)
1233+
{
1234+
_serial->write(sendStack.checksumMSB);
1235+
_serial->write(sendStack.checksumLSB);
1236+
}
1237+
12031238
Serial.println(_stack.end_byte, HEX);
12041239
}
12051240

src/DFPlayerMini_Fast.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class DFPlayerMini_Fast
149149

150150

151151
bool begin(Stream& stream, bool debug=false, unsigned long threshold=100);
152+
void setChipVariant(unsigned long delayMs = 1000);
152153

153154
void playNext();
154155
void playPrevious();
@@ -212,6 +213,8 @@ class DFPlayerMini_Fast
212213
private:
213214
FireTimer timoutTimer;
214215
unsigned long _threshold;
216+
bool isChipVariant; // Flag indicating if the current chip is the MH2024K-16SS variant
217+
unsigned long stackDelay; // Delay for chip variant due to slower processing speed of the MH2024K-16SS
215218

216219
/** MP3 response packet parsing states */
217220
enum fsm {

0 commit comments

Comments
 (0)