mindwidgets_df1201s¶
CircuitPython driver for DFRobot DFPlayer Pro (DF1201S) MP3 player with onboard storage
Author(s): Aaron Silinskas
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
- class mindwidgets_df1201s.DF1201S(uart: busio.UART)¶
Driver for DFRobot DFPlayer Pro (DF1201S) MP3 player with onboard storage.
Initialize the DFPlayer connection.
- Parameters
uart (busio.UART) – the serial connection to the DFPlayer
- PLAYMODE_PLAY_ONCE = 3¶
Play one sound and pause.
- Type
play_mode
- PLAYMODE_RANDOM = 4¶
Play a random sound.
- Type
play_mode
- PLAYMODE_REPEAT_ALL = 2¶
Repeat all sounds.
- Type
play_mode
- PLAYMODE_REPEAT_FOLDER = 5¶
Play all sounds in a folder.
- Type
play_mode
- PLAYMODE_REPEAT_ONE_SONG = 1¶
Repeat one sound.
- Type
play_mode
- decrease_volume(decrement: float) bool¶
Decrease the volume level.
Note
Persists after power off.
- Parameters
decrement (float) – the amount to decrement the volume, as a float between 0 and 1.
- Returns
True if the volume was decreased.
- disable_led() bool¶
Turn the builtin LED off.
Note
Persists after power off.
- Returns
True if the LED is off.
- disable_prompt() bool¶
Disable the sound that is played after power on.
Note
Persists after power off.
- Returns
True if the prompt is disabled.
- enable_led() bool¶
Turn the builtin LED on.
Note
Persists after power off.
- Returns
True if the LED is on.
- enable_prompt() bool¶
Enable the sound that is played after power on.
Note
Persists after power off.
- Returns
True if the prompt is enabled.
- fast_forward(seconds: int) bool¶
Fast forward the currently playing sound.
- Parameters
seconds (int) – the number of seconds to fast forward.
- Returns
True if fast forward was successful.
- fast_rewind(seconds: int) bool¶
Rewind the currently playing sound.
- Parameters
seconds (int) – the number of seconds to rewind.
- Returns
True if rewind was successful.
- fast_seek(seconds: int) bool¶
Start playing the current sound at a specific time offset.
Note
If the offset exceeds the sound length, this function still returns
Trueand the sound stops.- Parameters
seconds (int) – the time offset, in seconds.
- Returns
True if the current offset was set.
- increase_volume(increment: float) bool¶
Increase the volume level.
Note
Persists after power off.
- Parameters
increment (float) – the amount to increase the volume, as a float between 0 and 1.
- Returns
True if the volume was increased.
- play_file_name(file_name: str) bool¶
Play the sound with the given file name.
Note
Plays the first sound if the file name is invalid. I don’t see a way to turn off this behavior.
- Parameters
file_name (str) – the file name to play.
- Returns
True if the given file is playing, False if the first file if playing.
- play_file_number(file_number: int) bool¶
Play the sound at the given file number.
Note
Plays the first sound if the file number is invalid. I don’t see a way to turn off this behavior.
- Parameters
file_number (int) – the file number to play.
- Returns
True if the given file number is playing, False if the first file is playing.
- property play_mode: int¶
Returns the current play mode.
- Returns
One of the play mode constants,
PLAYMODE_REPEAT_ONE_SONG,PLAYMODE_REPEAT_ALL, orPLAYMODE_PLAY_ONCE.PLAYMODE_RANDOMcan be set, but this function will return -1. Bug in the device?PLAYMODE_REPEAT_FOLDERcan be set, but this function will return 3. Bug in the device?