DFPlayerMini_Fast
Classes | Public Member Functions | Public Attributes | List of all members
DFPlayerMini_Fast Class Reference

Class for interacting with DFPlayerMini MP3 player. More...

#include <DFPlayerMini_Fast.h>

Classes

struct  stack
 

Public Member Functions

bool begin (Stream &stream, bool debug=false, unsigned long threshold=100)
 Configure the class. More...
 
void playNext ()
 Play the next song in chronological order.
 
void playPrevious ()
 Play the previous song in chronological order.
 
void play (uint16_t trackNum)
 Play a specific track. More...
 
void stop ()
 Stop the current playback.
 
void playFromMP3Folder (uint16_t trackNum)
 Play a specific track in the folder named "MP3". More...
 
void playAdvertisement (uint16_t trackNum)
 Interrupt the current track with a new track. More...
 
void stopAdvertisement ()
 Stop the interrupting track.
 
void incVolume ()
 Increment the volume by 1 out of 30.
 
void decVolume ()
 Decrement the volume by 1 out of 30.
 
void volume (uint8_t volume)
 Set the volume to a specific value out of 30. More...
 
void EQSelect (uint8_t setting)
 Set the EQ mode. More...
 
void loop (uint16_t trackNum)
 Loop a specific track. More...
 
void playbackSource (uint8_t source)
 Specify the playback source. More...
 
void standbyMode ()
 Put the MP3 player in standby mode (this is NOT sleep mode).
 
void normalMode ()
 Pull the MP3 player out of standby mode.
 
void reset ()
 Reset all settings to factory default.
 
void resume ()
 Resume playing current track.
 
void pause ()
 Pause playing current track.
 
void playFolder (uint8_t folderNum, uint8_t trackNum)
 Play a specific track from a specific folder. More...
 
void volumeAdjustSet (uint8_t gain)
 Specify volume gain. More...
 
void startRepeatPlay ()
 Play all tracks.
 
void stopRepeatPlay ()
 Stop repeat play.
 
void repeatFolder (uint16_t folder)
 Play all tracks in a given folder. More...
 
void randomAll ()
 Play all tracks in a random order.
 
void startRepeat ()
 Repeat the current track.
 
void stopRepeat ()
 Stop repeat play of the current track.
 
void startDAC ()
 Turn on DAC.
 
void stopDAC ()
 Turn off DAC.
 
void sleep ()
 Put the MP3 player into sleep mode.
 
void wakeUp ()
 Pull the MP3 player out of sleep mode.
 
bool isPlaying ()
 Determine if a track is currently playing. More...
 
int16_t currentVolume ()
 Determine the current volume setting. More...
 
int16_t currentEQ ()
 Determine the current EQ setting. More...
 
int16_t currentMode ()
 Determine the current mode. More...
 
int16_t currentVersion ()
 Determine the current firmware version. More...
 
int16_t numUsbTracks ()
 Determine the number of tracks accessible via USB. More...
 
int16_t numSdTracks ()
 Determine the number of tracks accessible via SD card. More...
 
int16_t numFlashTracks ()
 Determine the number of tracks accessible via flash. More...
 
int16_t currentUsbTrack ()
 Determine the current track played via USB. More...
 
int16_t currentSdTrack ()
 Determine the current track played via SD card. More...
 
int16_t currentFlashTrack ()
 Determine the current track played via flash. More...
 
int16_t numTracksInFolder (uint8_t folder)
 Determine the number of tracks in the specified folder. More...
 
int16_t numFolders ()
 Determine the number of folders available. More...
 
void setTimeout (unsigned long threshold)
 Set the timout value for MP3 player query responses. More...
 
void findChecksum (stack &_stack)
 Determine and insert the checksum of a given config/command packet into that same packet struct. More...
 
void sendData ()
 Send a config/command packet to the MP3 player.
 
void flush ()
 Clear out the serial input buffer connected to the MP3 player.
 
int16_t query (uint8_t cmd, uint8_t msb=0, uint8_t lsb=0)
 Query the MP3 player for specific information. More...
 
bool parseFeedback ()
 Parse MP3 player query responses. More...
 
void printStack (stack _stack)
 Print the entire contents of the specified config/command packet for debugging purposes. More...
 
void printError ()
 Print the error description if an error has been received.
 

Public Attributes

Stream * _serial
 
struct DFPlayerMini_Fast::stack sendStack
 
struct DFPlayerMini_Fast::stack recStack
 
bool _debug
 

Detailed Description

Class for interacting with DFPlayerMini MP3 player.

Member Function Documentation

◆ begin()

bool DFPlayerMini_Fast::begin ( Stream &  stream,
bool  debug = false,
unsigned long  threshold = 100 
)

Configure the class.

Parameters
streamA reference to the Serial instance (hardware or software) used to communicate with the MP3 player.
debugBoolean used to specify if debug prints should be automatically printed to the serial monitor.
thresholdNumber of ms allowed for the MP3 player to respond (timeout) to a query.
Returns
True.

◆ play()

void DFPlayerMini_Fast::play ( uint16_t  trackNum)

Play a specific track.

Parameters
trackNumThe track number to play.

◆ playFromMP3Folder()

void DFPlayerMini_Fast::playFromMP3Folder ( uint16_t  trackNum)

Play a specific track in the folder named "MP3".

Parameters
trackNumThe track number to play.

◆ playAdvertisement()

void DFPlayerMini_Fast::playAdvertisement ( uint16_t  trackNum)

Interrupt the current track with a new track.

Parameters
trackNumThe track number to play.

◆ volume()

void DFPlayerMini_Fast::volume ( uint8_t  volume)

Set the volume to a specific value out of 30.

Parameters
volumeThe volume level (0 - 30).

◆ EQSelect()

void DFPlayerMini_Fast::EQSelect ( uint8_t  setting)

Set the EQ mode.

Parameters
settingThe desired EQ ID.

◆ loop()

void DFPlayerMini_Fast::loop ( uint16_t  trackNum)

Loop a specific track.

Parameters
trackNumThe track number to play.

◆ playbackSource()

void DFPlayerMini_Fast::playbackSource ( uint8_t  source)

Specify the playback source.

Parameters
sourceThe playback source ID.

◆ playFolder()

void DFPlayerMini_Fast::playFolder ( uint8_t  folderNum,
uint8_t  trackNum 
)

Play a specific track from a specific folder.

Parameters
folderNumThe folder number.
trackNumThe track number to play.

◆ volumeAdjustSet()

void DFPlayerMini_Fast::volumeAdjustSet ( uint8_t  gain)

Specify volume gain.

Parameters
gainThe specified volume gain.

◆ repeatFolder()

void DFPlayerMini_Fast::repeatFolder ( uint16_t  folder)

Play all tracks in a given folder.

Parameters
folderNumThe folder number.

◆ isPlaying()

bool DFPlayerMini_Fast::isPlaying ( )

Determine if a track is currently playing.

Returns
True if a track is currently playing, false if not, -1 if error.

◆ currentVolume()

int16_t DFPlayerMini_Fast::currentVolume ( )

Determine the current volume setting.

Returns
Volume level (0-30), -1 if error.

◆ currentEQ()

int16_t DFPlayerMini_Fast::currentEQ ( )

Determine the current EQ setting.

Returns
EQ setting, -1 if error.

◆ currentMode()

int16_t DFPlayerMini_Fast::currentMode ( )

Determine the current mode.

Returns
Mode, -1 if error.

◆ currentVersion()

int16_t DFPlayerMini_Fast::currentVersion ( )

Determine the current firmware version.

Returns
Firmware version, -1 if error.

◆ numUsbTracks()

int16_t DFPlayerMini_Fast::numUsbTracks ( )

Determine the number of tracks accessible via USB.

Returns
Number of tracks accessible via USB, -1 if error.

◆ numSdTracks()

int16_t DFPlayerMini_Fast::numSdTracks ( )

Determine the number of tracks accessible via SD card.

Returns
Number of tracks accessible via SD card, -1 if error.

◆ numFlashTracks()

int16_t DFPlayerMini_Fast::numFlashTracks ( )

Determine the number of tracks accessible via flash.

Returns
Number of tracks accessible via flash, -1 if error.

◆ currentUsbTrack()

int16_t DFPlayerMini_Fast::currentUsbTrack ( )

Determine the current track played via USB.

Returns
Current track played via USB, -1 if error.

◆ currentSdTrack()

int16_t DFPlayerMini_Fast::currentSdTrack ( )

Determine the current track played via SD card.

Returns
Current track played via SD card, -1 if error.

◆ currentFlashTrack()

int16_t DFPlayerMini_Fast::currentFlashTrack ( )

Determine the current track played via flash.

Returns
Current track played via flash, -1 if error.

◆ numTracksInFolder()

int16_t DFPlayerMini_Fast::numTracksInFolder ( uint8_t  folder)

Determine the number of tracks in the specified folder.

Parameters
folderThe folder number.
Returns
Number of tracks in the specified folder, -1 if error.

◆ numFolders()

int16_t DFPlayerMini_Fast::numFolders ( )

Determine the number of folders available.

Returns
Number of folders available, -1 if error.

◆ setTimeout()

void DFPlayerMini_Fast::setTimeout ( unsigned long  threshold)

Set the timout value for MP3 player query responses.

Parameters
thresholdNumber of ms allowed for the MP3 player to respond (timeout) to a query.

◆ findChecksum()

void DFPlayerMini_Fast::findChecksum ( stack _stack)

Determine and insert the checksum of a given config/command packet into that same packet struct.

Parameters
_stackReference to a struct containing the config/command packet to calculate the checksum over.

◆ query()

int16_t DFPlayerMini_Fast::query ( uint8_t  cmd,
uint8_t  msb = 0,
uint8_t  lsb = 0 
)

Query the MP3 player for specific information.

Parameters
cmdThe command/query ID.
msbThe payload/parameter MSB.
lsbThe payload/parameter LSB.
Returns
Query response, -1 if error.

◆ parseFeedback()

bool DFPlayerMini_Fast::parseFeedback ( )

Parse MP3 player query responses.

Returns
True if success, false if error.

◆ printStack()

void DFPlayerMini_Fast::printStack ( stack  _stack)

Print the entire contents of the specified config/command packet for debugging purposes.

Parameters
_stackStruct containing the config/command packet to print.

The documentation for this class was generated from the following files: