mirror of
https://github.com/DFRobot/DFRobotDFPlayerMini.git
synced 2026-03-16 13:36:49 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
beeba2c69d | ||
|
|
cfb9428978 | ||
|
|
c36911d7b3 | ||
|
|
0cf620c20d | ||
|
|
7b5087e1af | ||
|
|
c0bd68111b | ||
|
|
20343d62ed | ||
|
|
31d5ec18d6 | ||
|
|
6f4f402c71 | ||
|
|
c9f758979b | ||
|
|
6111ae2018 |
17
.travis.yml
Normal file
17
.travis.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
env:
|
||||
- BOARD=uno
|
||||
- BOARD=leonardo
|
||||
- BOARD=esp01
|
||||
|
||||
install:
|
||||
- python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
|
||||
|
||||
script:
|
||||
- cd examples/FullFunction
|
||||
- platformio ci -l ../.. FullFunction.ino --board=$BOARD
|
||||
- cd ../GetStarted
|
||||
- platformio ci -l ../.. getStarted.ino --board=$BOARD
|
||||
|
||||
@@ -33,6 +33,7 @@ uint16_t DFRobotDFPlayerMini::calculateCheckSum(uint8_t *buffer){
|
||||
void DFRobotDFPlayerMini::sendStack(){
|
||||
if (_sending[Stack_ACK]) {
|
||||
while (_isSending) {
|
||||
delay(0);
|
||||
available();
|
||||
}
|
||||
}
|
||||
@@ -81,11 +82,13 @@ void DFRobotDFPlayerMini::disableACK(){
|
||||
|
||||
bool DFRobotDFPlayerMini::waitAvailable(){
|
||||
_isSending = true;
|
||||
while (!available());
|
||||
while (!available()){
|
||||
delay(0);
|
||||
}
|
||||
return _handleType != TimeOut;
|
||||
}
|
||||
|
||||
bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK){
|
||||
bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK, bool doReset){
|
||||
if (isACK) {
|
||||
enableACK();
|
||||
}
|
||||
@@ -94,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;
|
||||
}
|
||||
|
||||
@@ -123,6 +133,7 @@ bool DFRobotDFPlayerMini::handleMessage(uint8_t type, uint16_t parameter){
|
||||
bool DFRobotDFPlayerMini::handleError(uint8_t type, uint16_t parameter){
|
||||
handleMessage(type, parameter);
|
||||
_isSending = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t DFRobotDFPlayerMini::readCommand(){
|
||||
@@ -195,6 +206,7 @@ bool DFRobotDFPlayerMini::validateStack(){
|
||||
|
||||
bool DFRobotDFPlayerMini::available(){
|
||||
while (_serial->available()) {
|
||||
delay(0);
|
||||
if (_receivedIndex == 0) {
|
||||
_received[Stack_Header] = _serial->read();
|
||||
#ifdef _DEBUG
|
||||
@@ -394,7 +406,6 @@ int DFRobotDFPlayerMini::readVolume(){
|
||||
|
||||
uint8_t DFRobotDFPlayerMini::readEQ(){
|
||||
sendStack(0x44);
|
||||
while (!available());
|
||||
if (waitAvailable()) {
|
||||
return read();
|
||||
}
|
||||
@@ -458,12 +469,22 @@ int DFRobotDFPlayerMini::readFileCountsInFolder(int folderNumber){
|
||||
}
|
||||
}
|
||||
|
||||
int DFRobotDFPlayerMini::readFolderCounts(){
|
||||
sendStack(0x4F);
|
||||
if (waitAvailable()) {
|
||||
return read();
|
||||
}
|
||||
else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int DFRobotDFPlayerMini::readFileCounts(){
|
||||
readFileCounts(DFPLAYER_DEVICE_SD);
|
||||
return readFileCounts(DFPLAYER_DEVICE_SD);
|
||||
}
|
||||
|
||||
int DFRobotDFPlayerMini::readCurrentFileNumber(){
|
||||
readCurrentFileNumber(DFPLAYER_DEVICE_SD);
|
||||
return readCurrentFileNumber(DFPLAYER_DEVICE_SD);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class DFRobotDFPlayerMini {
|
||||
|
||||
uint8_t readCommand();
|
||||
|
||||
bool begin(Stream& stream, bool isACK = true);
|
||||
bool begin(Stream& stream, bool isACK = true, bool doReset = true);
|
||||
|
||||
bool waitAvailable();
|
||||
|
||||
@@ -186,6 +186,8 @@ class DFRobotDFPlayerMini {
|
||||
int readFileCountsInFolder(int folderNumber);
|
||||
|
||||
int readFileCounts();
|
||||
|
||||
int readFolderCounts();
|
||||
|
||||
int readCurrentFileNumber();
|
||||
|
||||
|
||||
BIN
doc/FN-M16P+Embedded+MP3+Audio+Module+Datasheet.pdf
Normal file
BIN
doc/FN-M16P+Embedded+MP3+Audio+Module+Datasheet.pdf
Normal file
Binary file not shown.
@@ -1,11 +1,11 @@
|
||||
/***************************************************
|
||||
DFPlayer - A Mini MP3 Player For Arduino
|
||||
<https://www.dfrobot.com/index.php?route=product/product&product_id=1121>
|
||||
<https://www.dfrobot.com/index.php?route=product/product&search=mp3&description=true&product_id=1121>
|
||||
|
||||
***************************************************
|
||||
This example shows the basic function of library for DFPlayer.
|
||||
|
||||
Created 2016-12-07
|
||||
Created 2014-8-28
|
||||
By [Angelo qiao](Angelo.qiao@dfrobot.com)
|
||||
|
||||
GNU Lesser General Public License.
|
||||
@@ -15,7 +15,7 @@ DFPlayer - A Mini MP3 Player For Arduino
|
||||
|
||||
/***********Notice and Trouble shooting***************
|
||||
1.Connection and Diagram can be found here
|
||||
<https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299#Connection_Diagram>
|
||||
<>
|
||||
2.This code is tested on Arduino Uno, Leonardo, Mega boards.
|
||||
****************************************************/
|
||||
|
||||
@@ -40,7 +40,9 @@ void setup()
|
||||
Serial.println(F("Unable to begin:"));
|
||||
Serial.println(F("1.Please recheck the connection!"));
|
||||
Serial.println(F("2.Please insert the SD card!"));
|
||||
while(true);
|
||||
while(true){
|
||||
delay(0); // Code to compatible with ESP8266 watch dog.
|
||||
}
|
||||
}
|
||||
Serial.println(F("DFPlayer Mini online."));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name=DFRobotDFPlayerMini
|
||||
version=1.0.1
|
||||
version=1.0.2
|
||||
author=DFRobot
|
||||
maintainer=Angelo <angelo.qiao@dfrobot.com>
|
||||
sentence=Driver for DFPlayer Mini from DFRobot
|
||||
|
||||
Reference in New Issue
Block a user