|
1 |
| -# DFPlayer-serial |
| 1 | +# DFPlayer-async |
2 | 2 |
|
3 |
| -Driver to communicate with the DFRobot DFPlayer Mini MP3 Player. |
| 3 | +An async no_std Rust driver for the DFPlayer Mini MP3 module, designed for embedded systems. |
4 | 4 |
|
5 |
| -Supports only embassy for now. |
| 5 | +## About |
| 6 | + |
| 7 | +This driver is based on the excellent work from [dfplayer-serial](https://github.com/Laboratorios-Gensokyo/dfplayer-serial) by José Fernando Morales Vargas. Published with the original author's kind permission as the original repository is currently not maintained. |
| 8 | + |
| 9 | +Based on the original driver, this version has been reworked. See tags for changes, in case You are interested. |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- **Async/await API** for embedded systems |
| 14 | +- **(Probaly) full command support** for DFPlayer Mini and compatible modules |
| 15 | +- **Proper error handling** and timeout management |
| 16 | +- **no_std compatible** for use in bare-metal environments |
| 17 | +- **Robust initialization sequence** with fallback mechanisms |
| 18 | +- Optional **logging via defmt** (enable the "defmt" feature) |
| 19 | + |
| 20 | +## Hardware Compatibility |
| 21 | + |
| 22 | +This driver has been tested with: |
| 23 | + |
| 24 | +- Original DFPlayer mini by DFRobot |
| 25 | +- AZDeliver DFPlayer mini clone |
| 26 | + |
| 27 | +Despite using different chips, both modules apparently follow the same protocol and work with this driver. Other compatible modules should work as well, but your mileage may vary. |
| 28 | + |
| 29 | +## Usage |
| 30 | + |
| 31 | +Add to your `Cargo.toml`: |
| 32 | + |
| 33 | +```toml |
| 34 | +[dependencies] |
| 35 | +dfplayer-async = "0.2.0" |
| 36 | +``` |
| 37 | + |
| 38 | +## Examples |
| 39 | + |
| 40 | +The repository contains complete working examples: |
| 41 | + |
| 42 | +- [`examples/src/basic.rs`](examples/src/basic.rs) - Shows how to initialize the driver and control playback, including: |
| 43 | + - Setting up the UART connection |
| 44 | + - Initializing the DFPlayer |
| 45 | + - Setting volume and equalizer |
| 46 | + - Playing tracks and handling the busy pin |
| 47 | + |
| 48 | +- [`examples/src/query.rs`](examples/src/query.rs) - Demonstrates how to query information from the device: |
| 49 | + - Getting the number of tracks on the SD card |
| 50 | + - Reading the current equalizer setting |
| 51 | + - Checking the current volume |
| 52 | + |
| 53 | +The examples assume a Raspberry Pi Pico with specific pin connections: |
| 54 | + |
| 55 | +- UART0 TX/RX on GPIO 17/16 |
| 56 | +- Busy Pin on GPIO 18 |
| 57 | + |
| 58 | +## Hardware Setup |
| 59 | + |
| 60 | +To use the DFPlayer Mini: |
| 61 | + |
| 62 | +1. Connect power (VCC and GND) |
| 63 | +2. Connect UART TX/RX lines (9600 baud, 8N1) |
| 64 | +3. Optionally connect the busy pin |
| 65 | +4. Connect a speaker to the output |
| 66 | +5. Insert an SD card with MP3 files |
| 67 | + |
| 68 | +## File Organization |
| 69 | + |
| 70 | +The DFPlayer expects MP3 files to be organized in a specific way. For basic usage: |
| 71 | + |
| 72 | +- Place files in the root directory of the SD card |
| 73 | +- Name them with a numerical prefix: `0001-song.mp3`, `0002-song.mp3`, etc. |
| 74 | + |
| 75 | +For more advanced organization, you can create folders and use the `play_from_folder` method. |
| 76 | + |
| 77 | +## License |
| 78 | + |
| 79 | +Licensed under the MIT License - see the LICENSE file for details. |
0 commit comments