mirror of
https://github.com/DFRobot/DFRobotDFPlayerMini.git
synced 2026-03-16 21:46: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(){
|
void DFRobotDFPlayerMini::sendStack(){
|
||||||
if (_sending[Stack_ACK]) {
|
if (_sending[Stack_ACK]) {
|
||||||
while (_isSending) {
|
while (_isSending) {
|
||||||
|
delay(0);
|
||||||
available();
|
available();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,11 +82,13 @@ void DFRobotDFPlayerMini::disableACK(){
|
|||||||
|
|
||||||
bool DFRobotDFPlayerMini::waitAvailable(){
|
bool DFRobotDFPlayerMini::waitAvailable(){
|
||||||
_isSending = true;
|
_isSending = true;
|
||||||
while (!available());
|
while (!available()){
|
||||||
|
delay(0);
|
||||||
|
}
|
||||||
return _handleType != TimeOut;
|
return _handleType != TimeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK){
|
bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK, bool doReset){
|
||||||
if (isACK) {
|
if (isACK) {
|
||||||
enableACK();
|
enableACK();
|
||||||
}
|
}
|
||||||
@@ -94,11 +97,18 @@ bool DFRobotDFPlayerMini::begin(Stream &stream, bool isACK){
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serial = &stream;
|
_serial = &stream;
|
||||||
_timeOutDuration += 3000;
|
|
||||||
reset();
|
if (doReset) {
|
||||||
waitAvailable();
|
_timeOutDuration += 3000;
|
||||||
_timeOutDuration -= 3000;
|
reset();
|
||||||
delay(200);
|
waitAvailable();
|
||||||
|
_timeOutDuration -= 3000;
|
||||||
|
delay(200);
|
||||||
|
} else {
|
||||||
|
// assume same state as with reset(): online
|
||||||
|
_handleType = DFPlayerCardOnline;
|
||||||
|
}
|
||||||
|
|
||||||
return (readType() == DFPlayerCardOnline) || !isACK;
|
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){
|
bool DFRobotDFPlayerMini::handleError(uint8_t type, uint16_t parameter){
|
||||||
handleMessage(type, parameter);
|
handleMessage(type, parameter);
|
||||||
_isSending = false;
|
_isSending = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DFRobotDFPlayerMini::readCommand(){
|
uint8_t DFRobotDFPlayerMini::readCommand(){
|
||||||
@@ -195,6 +206,7 @@ bool DFRobotDFPlayerMini::validateStack(){
|
|||||||
|
|
||||||
bool DFRobotDFPlayerMini::available(){
|
bool DFRobotDFPlayerMini::available(){
|
||||||
while (_serial->available()) {
|
while (_serial->available()) {
|
||||||
|
delay(0);
|
||||||
if (_receivedIndex == 0) {
|
if (_receivedIndex == 0) {
|
||||||
_received[Stack_Header] = _serial->read();
|
_received[Stack_Header] = _serial->read();
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -394,7 +406,6 @@ int DFRobotDFPlayerMini::readVolume(){
|
|||||||
|
|
||||||
uint8_t DFRobotDFPlayerMini::readEQ(){
|
uint8_t DFRobotDFPlayerMini::readEQ(){
|
||||||
sendStack(0x44);
|
sendStack(0x44);
|
||||||
while (!available());
|
|
||||||
if (waitAvailable()) {
|
if (waitAvailable()) {
|
||||||
return read();
|
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(){
|
int DFRobotDFPlayerMini::readFileCounts(){
|
||||||
readFileCounts(DFPLAYER_DEVICE_SD);
|
return readFileCounts(DFPLAYER_DEVICE_SD);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DFRobotDFPlayerMini::readCurrentFileNumber(){
|
int DFRobotDFPlayerMini::readCurrentFileNumber(){
|
||||||
readCurrentFileNumber(DFPLAYER_DEVICE_SD);
|
return readCurrentFileNumber(DFPLAYER_DEVICE_SD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class DFRobotDFPlayerMini {
|
|||||||
|
|
||||||
uint8_t readCommand();
|
uint8_t readCommand();
|
||||||
|
|
||||||
bool begin(Stream& stream, bool isACK = true);
|
bool begin(Stream& stream, bool isACK = true, bool doReset = true);
|
||||||
|
|
||||||
bool waitAvailable();
|
bool waitAvailable();
|
||||||
|
|
||||||
@@ -187,6 +187,8 @@ class DFRobotDFPlayerMini {
|
|||||||
|
|
||||||
int readFileCounts();
|
int readFileCounts();
|
||||||
|
|
||||||
|
int readFolderCounts();
|
||||||
|
|
||||||
int readCurrentFileNumber();
|
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
|
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.
|
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)
|
By [Angelo qiao](Angelo.qiao@dfrobot.com)
|
||||||
|
|
||||||
GNU Lesser General Public License.
|
GNU Lesser General Public License.
|
||||||
@@ -15,7 +15,7 @@ DFPlayer - A Mini MP3 Player For Arduino
|
|||||||
|
|
||||||
/***********Notice and Trouble shooting***************
|
/***********Notice and Trouble shooting***************
|
||||||
1.Connection and Diagram can be found here
|
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.
|
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("Unable to begin:"));
|
||||||
Serial.println(F("1.Please recheck the connection!"));
|
Serial.println(F("1.Please recheck the connection!"));
|
||||||
Serial.println(F("2.Please insert the SD card!"));
|
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."));
|
Serial.println(F("DFPlayer Mini online."));
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name=DFRobotDFPlayerMini
|
name=DFRobotDFPlayerMini
|
||||||
version=1.0.1
|
version=1.0.2
|
||||||
author=DFRobot
|
author=DFRobot
|
||||||
maintainer=Angelo <angelo.qiao@dfrobot.com>
|
maintainer=Angelo <angelo.qiao@dfrobot.com>
|
||||||
sentence=Driver for DFPlayer Mini from DFRobot
|
sentence=Driver for DFPlayer Mini from DFRobot
|
||||||
|
|||||||
Reference in New Issue
Block a user