Go to the documentation of this file.
17 #ifndef DFPLAYER_IMPLEMENTATION_H
18 #define DFPLAYER_IMPLEMENTATION_H
128 *volume = (uint8_t)tmp;
240 return (set & (0x01 << src)) ? 1 : 0;
dfplayer_mode_t
Enumeration of the playback modes supported by the DFPlayer.
static int dfplayer_set_volume(dfplayer_t *dev, uint8_t volume)
Sets the volume to the given value.
int dfplayer_step(dfplayer_t *dev, int step)
Step forward/backward following the currently used naming scheme.
void mutex_lock(mutex_t *mutex)
Locks a mutex, blocking.
static int dfplayer_next(dfplayer_t *dev)
Start playing the next song in the currently used naming scheme.
static void dfplayer_source_set_add(dfplayer_source_set_t set, dfplayer_source_t src)
Add the given source to the given source set.
#define EINVAL
Invalid argument.
#define DFPLAYER_CMD_SET_VOLUME
Set the volume to the given level.
#define DFPLAYER_CMD_FILENO_SDCARD
Get the currently select file number on the SD-Card.
dfplayer_file_t file
Currently played song.
mutex_t mutex
Used to mutual exclusive access.
static dfplayer_file_t dfplayer_get_played_file(dfplayer_t *dev)
Get the currently played file and the used naming scheme.
#define DFPLAYER_CMD_STANDBY_EXIT
Exit low power mode, back to normal mode.
static int dfplayer_set_source(dfplayer_t *dev, dfplayer_source_t src)
Apply the given source.
#define DFPLAYER_CMD_GET_MODE
Retrieve the current playback mode.
#define DFPLAYER_CMD_FILENO_USB
Get the currently select file number on the USB storage.
static int dfplayer_stop_advert(dfplayer_t *dev)
Stop playing a file from the ADVERT folder and resume previous playback.
@ DFPLAYER_SOURCE_NUMOF
Number of supported playback modes.
static int dfplayer_get_fileno_flash(dfplayer_t *dev, uint16_t *fileno)
Query the selected file on the NOR flash.
dfplayer_eq_t
Enumeration of the equalizer settings supported by the DFPlayer.
static int dfplayer_shuffle_all(dfplayer_t *dev)
Launch shuffle playback of all files.
static int dfplayer_get_fileno_usb(dfplayer_t *dev, uint16_t *fileno)
Query the selected file on the USB storage device.
int dfplayer_file_cmd(dfplayer_t *dev, uint8_t cmd, uint8_t p1, uint8_t p2)
Send a command selecting a playback file.
static int dfplayer_get_equalizer(dfplayer_t *dev, dfplayer_eq_t *equalizer)
Query the current equalizer setting of the DFPlayer Mini.
static int dfplayer_get_mode(dfplayer_t *dev, dfplayer_mode_t *mode)
Query the current playback mode of the DFPlayer Mini.
static int dfplayer_play(dfplayer_t *dev)
Start/resume playing.
Types used in the DFPlayer Mini Device Driver.
static int dfplayer_get_fileno_sdcard(dfplayer_t *dev, uint16_t *fileno)
Query the selected file on the SD card.
#define DFPLAYER_CMD_FILES_SDCARD
Get the total number of files on the SD card.
static int dfplayer_set_equalizer(dfplayer_t *dev, dfplayer_eq_t equalizer)
Apply the given equalizer setting.
static int dfplayer_enter_standby(dfplayer_t *dev)
Enter standby mode.
dfplayer_source_t
Enumeration of the different sources for playback supported.
@ DFPLAYER_EQ_NUMOF
Number of supported equalizer settings.
#define DFPLAYER_CMD_GET_VOLUME
Retrieve the current volume.
static int dfplayer_get_version(dfplayer_t *dev, uint16_t *version)
Query the software version running on the DFPlayer Mini.
static int dfplayer_files_sdcard(dfplayer_t *dev, uint16_t *files)
Query the number of files on the SD card.
static int dfplayer_exit_standby(dfplayer_t *dev)
Exit standby mode.
static int dfplayer_cmd(dfplayer_t *dev, uint8_t cmd)
Send a command without parameters to the DFPlayer Mini.
DFPlayer Mini Device Driver.
static int dfplayer_pause(dfplayer_t *dev)
Pause the playback.
static int dfplayer_query(dfplayer_t *dev, uint16_t *resp, uint8_t cmd)
Send a query and receive the response.
#define DFPLAYER_CMD_FILENO_FLASH
Get the currently select file number on the NOR flash.
#define DFPLAYER_CMD_REPEAT_FOLDER
Start repeat-playing the given folder (1-99)
static int dfplayer_repeat_folder(dfplayer_t *dev, uint8_t folder)
Start playing and repeating the specified folder.
static int dfplayer_files_usb(dfplayer_t *dev, uint16_t *files)
Query the number of files on the USB storage device.
static void dfplayer_source_set_rm(dfplayer_source_set_t set, dfplayer_source_t src)
Remove the given source to the given source set.
#define DFPLAYER_MAX_VOLUME
Maximum supported volume.
#define DFPLAYER_CMD_GET_VERSION
Retrieve the device's software version.
#define DFPLAYER_CMD_SET_SOURCE
Set the source to play files from.
#define DFPLAYER_CMD_REPEAT
0 = repeat currently played file, 1 = stop repeating
#define DFPLAYER_CMD_FILES_FLASH
Get the total number of files on NOR flash.
#define DFPLAYER_CMD_SET_EQUALIZER
Set the equalizer to the given setting.
static int dfplayer_prev(dfplayer_t *dev)
Start playing the previous song in the currently used naming scheme.
static int dfplayer_source_set_contains(dfplayer_source_set_t set, dfplayer_source_t src)
Check if the given source set contains the given source.
#define DFPLAYER_CMD_RANDOM
Start playing all files in random order.
static int dfplayer_get_volume(dfplayer_t *dev, uint8_t *volume)
Query the current volume of the DFPlayer Mini.
static int dfplayer_repeat(dfplayer_t *dev, bool repeat)
Enable or disable repeat playback.
#define DFPLAYER_CMD_ABORT_ADVERT
Play the given file (1-9999) from the folder "ADVERT", resume current playback afterwards.
#define DFPLAYER_CMD_PLAY
Start playing the selected file.
#define DFPLAYER_CMD_GET_EQUALIZER
Retrieve the current equalizer setting.
Constants used in the DFPlayer Mini Driver.
static int dfplayer_files_flash(dfplayer_t *dev, uint16_t *files)
Query the number of files on the NOR flash.
#define DFPLAYER_CMD_STANDBY_ENTER
Enter low power mode.
static int dfplayer_cmd_1param(dfplayer_t *dev, uint8_t cmd, uint8_t param)
Send a command with one parameter to the DFPlayer Mini.
Internal functions of DFPlayer Mini Device driver.
#define DFPLAYER_CMD_FILES_USB
Get the total number of files on USB storage.
Data structure representing a file on the DFPlayer.
uint8_t dfplayer_source_set_t
Set of DFPlayer playback sources.
void mutex_unlock(mutex_t *mutex)
Unlocks the mutex.
A DFPlayer Mini device descriptor.
#define DFPLAYER_CMD_PAUSE
Pause the playback.