16 #ifndef DFRobotDFPlayerMini_cpp 17 #define DFRobotDFPlayerMini_cpp 20 #define DFPLAYER_EQ_NORMAL 0 21 #define DFPLAYER_EQ_POP 1 22 #define DFPLAYER_EQ_ROCK 2 23 #define DFPLAYER_EQ_JAZZ 3 24 #define DFPLAYER_EQ_CLASSIC 4 25 #define DFPLAYER_EQ_BASS 5 27 #define DFPLAYER_DEVICE_U_DISK 1 28 #define DFPLAYER_DEVICE_SD 2 29 #define DFPLAYER_DEVICE_AUX 3 30 #define DFPLAYER_DEVICE_SLEEP 4 31 #define DFPLAYER_DEVICE_FLASH 5 33 #define DFPLAYER_RECEIVED_LENGTH 10 34 #define DFPLAYER_SEND_LENGTH 10 40 #define DFPlayerCardInserted 2 41 #define DFPlayerCardRemoved 3 42 #define DFPlayerCardOnline 4 43 #define DFPlayerPlayFinished 5 44 #define DFPlayerError 6 48 #define SerialWrongStack 3 49 #define CheckSumNotMatch 4 50 #define FileIndexOut 5 51 #define FileMismatch 6 54 #define Stack_Header 0 55 #define Stack_Version 1 56 #define Stack_Length 2 57 #define Stack_Command 3 59 #define Stack_Parameter 5 60 #define Stack_CheckSum 7 66 unsigned long _timeOutTimer;
67 unsigned long _timeOutDuration = 500;
69 uint8_t _received[DFPLAYER_RECEIVED_LENGTH];
70 uint8_t _sending[DFPLAYER_SEND_LENGTH] = {0x7E, 0xFF, 06, 00, 01, 00, 00, 00, 00, 0xEF};
72 uint8_t _receivedIndex=0;
75 void sendStack(uint8_t command);
76 void sendStack(uint8_t command, uint16_t argument);
77 void sendStack(uint8_t command, uint8_t argumentHigh, uint8_t argumentLow);
82 void uint16ToArray(uint16_t value,uint8_t *array);
84 uint16_t arrayToUint16(uint8_t *array);
86 uint16_t calculateCheckSum(uint8_t *buffer);
93 uint8_t device = DFPLAYER_DEVICE_SD;
98 uint8_t _handleCommand;
99 uint16_t _handleParameter;
100 bool _isAvailable =
false;
101 bool _isSending =
false;
103 bool handleMessage(uint8_t type, uint16_t parameter = 0);
104 bool handleError(uint8_t type, uint16_t parameter = 0);
106 uint8_t readCommand();
108 bool begin(
Stream& stream,
bool isACK =
true,
bool doReset =
true);
110 bool waitAvailable();
118 void setTimeOut(
unsigned long timeOutDuration);
124 void play(
int fileNumber=1);
130 void volume(uint8_t volume);
134 void loop(
int fileNumber);
136 void outputDevice(uint8_t device);
146 void playFolder(uint8_t folderNumber, uint8_t fileNumber);
148 void outputSetting(
bool enable, uint8_t gain);
150 void enableLoopAll();
152 void disableLoopAll();
154 void playMp3Folder(
int fileNumber);
156 void advertise(
int fileNumber);
158 void playLargeFolder(uint8_t folderNumber, uint16_t fileNumber);
160 void stopAdvertise();
164 void loopFolder(
int folderNumber);
182 int readFileCounts(uint8_t device);
184 int readCurrentFileNumber(uint8_t device);
186 int readFileCountsInFolder(
int folderNumber);
188 int readFileCounts();
190 int readFolderCounts();
192 int readCurrentFileNumber();
Definition: DFRobotDFPlayerMini.h:63