DFPlayer¶
Module for DFplayer Mini Player.
Datasheet: http://www.picaxe.com/docs/spe033.pdf
-
class
devices.dfplayer.dfplayer.DFPlayer(uart, busy: int)¶ Bases:
objectClass for DFplayer Mini Player.
-
is_busy()¶ Return True if track is playing.
-
next_track()¶ Play next track.
-
pause()¶ Pause player.
-
play_track(track: int)¶ Play track.
Parameters: track – track in [0, 255]. Tracks should be in “mp3” directory and have names “001.mp3”, “002.mp3”, etc. Track is the order number of track. The order number depends of order of writing file to sdcard. It is recomended to write files separately from the first to the last one.
-
reset()¶ Reset player.
-
send(command: bytes)¶ Send command to DFPlayer by uart.
-
set_volume(volume: int)¶ Set volume to player.
Parameters: volume – volume in [0, 30]
-
-
class
devices.dfplayer.dfplayer.MP3(player: devices.dfplayer.dfplayer.DFPlayer, client: object, class_: str = 'mp3')¶ Bases:
objectMP3 player that can be managed remotely and localy.
-
loop()¶ Loop.
-
on_message(package)¶ Message handler.
-
play(track, volume=None)¶ Play track without blocking thread.
Parameters: - track – track in [0, 255].
- volume – volume in [0, 30] or None for use previous value.
-
play_block(track, volume=None)¶ Play track with blocking thread.
Parameters: - track – track in [0, 255].
- volume – volume in [0, 30] or None for use previous value.
-
send_done()¶ Send done package.
-
set_volume(volume)¶ Set volume to player.
Parameters: volume – volume in [0, 30]
-
-
devices.dfplayer.dfplayer._count_control_sum(command: bytes)¶ Count control sum.
The control sum of command is a sum of all command bytes substracted from 2^16.
control_sum = 2^16 - (b0 + b1 + … b6).