mirror of
https://github.com/DFRobot/DFRobotDFPlayerMini.git
synced 2026-03-03 07:14:01 +01:00
Merge pull request #5 from jandelgado/make_call_to_init_optional
Made the call to init() in DFRobotDFPlayerMini::begin() optional.
This commit is contained in:
@@ -88,7 +88,7 @@ bool DFRobotDFPlayerMini::waitAvailable(){
|
||||
return _handleType != TimeOut;
|
||||
}
|
||||
|
||||
bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK){
|
||||
bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK, bool doReset){
|
||||
if (isACK) {
|
||||
enableACK();
|
||||
}
|
||||
@@ -97,11 +97,18 @@ bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK){
|
||||
}
|
||||
|
||||
_serial = &stream;
|
||||
_timeOutDuration += 3000;
|
||||
reset();
|
||||
waitAvailable();
|
||||
_timeOutDuration -= 3000;
|
||||
delay(200);
|
||||
|
||||
if (doReset) {
|
||||
_timeOutDuration += 3000;
|
||||
reset();
|
||||
waitAvailable();
|
||||
_timeOutDuration -= 3000;
|
||||
delay(200);
|
||||
} else {
|
||||
// assume same state as with reset(): online
|
||||
_handleType = DFPlayerCardOnline;
|
||||
}
|
||||
|
||||
return (readType() == DFPlayerCardOnline) || !isACK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user