Name | micropython-dfmini JSON |
Version |
1.0.0
JSON |
| download |
home_page | |
Summary | Library to use the DFPlayer mini mp3 player module with micropython |
upload_time | 2022-12-30 14:15:47 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | MIT License Copyright (c) 2022 redoxcode Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
dfmini
dfplayer
mp3
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## Description
A micropython library to control the [DFPlayer mini](https://www.dfrobot.com/product-1121.html) mp3 player module.
This library focuses on the most essential functions. Some advanced functions of the DFPlayer, like the equalizer modes are not implemented yet.
Further this library is made to use the folders function of the dfmini. You can use up to 99 folders and 255 files per folder.
The files on your micro sd card need to be structured like this:
.
├── 01
│ ├── 001.mp3
│ ├── 002.mp3
│ └── ...
├── 02
│ ├── 001.mp3
│ ├── 002.mp3
│ └── ...
├── 03
│ ├── 001.mp3
│ ├── 002.mp3
│ └── ...
└── ...
There should be no gaps in the numbering scheme.
It might be best to prepare the whole file structure on your harddrive first and then copy them in one go on a freshly formated micro sd card, as the DFPlayer might get confused from artifacts left on the sd cards filesystem.
You can use the files in [/sample_files](https://github.com/redoxcode/micropython-dfplayer/tree/main/sample_files) to test your module.
Sometimes the module isn't able to keep up if you try to send commands to fast, so some delay between the commands is needed.
## Examples
### Play a file from a folder
```Python
import time
from dfplayer import DFPlayer
df=DFPlayer(uart_id=1,tx_pin_id=4,rx_pin_id=5)
#wait some time till the DFPlayer is ready
time.sleep(0.2)
#change the volume (0-30). The DFPlayer doesn't remember these settings
df.volume(25)
time.sleep(0.2)
#play file ./01/001.mp3
df.play(1,1)
```
### Find the number of files in a folder
If a folder doesn't exist, get_files_in_folder will return -1
```Python
import time
from dfplayer import DFPlayer
df=DFPlayer(uart_id=1,tx_pin_id=4,rx_pin_id=5)
#wait some time till the DFPlayer is ready
time.sleep(0.2)
print(df.get_files_in_folder(1))
time.sleep(0.2)
print(df.get_files_in_folder(4))
```
## API
### class DFPlayer(uart_id,tx_pin_id=None,rx_pin_id=None)
- uart_id: Uart channel you want to use (0 or 1 for pi pico)
- tx_pin_id: Pin id for uart tx if your board supports changing the pins of the uart channel.
- tx_pin_id: Pin id for uart rx if your board supports changing the pins of the uart channel.
```play(folder,file)```
- play a file from a folder (stops all previous playback)
- folder: Folder number of the file you want to play
- file: File number of the file you want to play
```stop()```
- stop all playback
```volume(vol)```
- set the volume of the module
- vol: Volume of the module. The range is 0 to 30. The DFPlayer doesn't remember these settings
```get_volume()```
- returns the current volume setting of the module
```ìs_playing()```
- returns if currently some playback is running
```get_files_in_folder(folder)```
- returns the number of files in a folder or -1 if the folder doesn't exist
- folder: folder to get the number of files in
```reset()```
- reset the module
```send_cmd(cmd,param1=0,param2=0)```
- sends a command byte with 2 bytes for parameters to the module. This can be used to send commands not yet implemented in this library. Use the modules [documentation](https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299) as reference.
- cmd: cammand byte (0-255)
- param1: parameter 1 or MSB of a 2 byte parameter
- param2: parameter 2 or LSB of a 2 byte parameter
```send_query(cmd,param1=0,param2=0)```
- like send_cmd, but returns the bytes the module sends as answer to the query
- cmd: cammand byte (0-255)
- param1: parameter 1 or MSB of a 2 byte parameter
- param2: parameter 2 or LSB of a 2 byte parameter
Raw data
{
"_id": null,
"home_page": "",
"name": "micropython-dfmini",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "dfmini,dfplayer,mp3",
"author": "",
"author_email": "redoxcode <redoxcode@github.com>",
"download_url": "https://files.pythonhosted.org/packages/22/5c/cc89f21df1ad56559c48062e467132b78e6e4d00183c772c123ebf9b86c4/micropython-dfmini-1.0.0.tar.gz",
"platform": null,
"description": "## Description\nA micropython library to control the [DFPlayer mini](https://www.dfrobot.com/product-1121.html) mp3 player module.\n\nThis library focuses on the most essential functions. Some advanced functions of the DFPlayer, like the equalizer modes are not implemented yet.\n\nFurther this library is made to use the folders function of the dfmini. You can use up to 99 folders and 255 files per folder.\nThe files on your micro sd card need to be structured like this:\n\n\t.\n\t\u251c\u2500\u2500 01\n\t\u2502\u00a0\u00a0 \u251c\u2500\u2500 001.mp3\n\t\u2502\u00a0\u00a0 \u251c\u2500\u2500 002.mp3\n\t\u2502\u00a0\u00a0 \u2514\u2500\u2500 ...\n\t\u251c\u2500\u2500 02\n\t\u2502\u00a0\u00a0 \u251c\u2500\u2500 001.mp3\n\t\u2502\u00a0\u00a0 \u251c\u2500\u2500 002.mp3\n\t\u2502\u00a0\u00a0 \u2514\u2500\u2500 ...\n\t\u251c\u2500\u2500 03\n\t\u2502\u00a0\u00a0 \u251c\u2500\u2500 001.mp3\n\t\u2502\u00a0\u00a0 \u251c\u2500\u2500 002.mp3\n\t\u2502\u00a0\u00a0 \u2514\u2500\u2500 ...\n\t\u2514\u2500\u2500 ...\n\nThere should be no gaps in the numbering scheme.\nIt might be best to prepare the whole file structure on your harddrive first and then copy them in one go on a freshly formated micro sd card, as the DFPlayer might get confused from artifacts left on the sd cards filesystem.\nYou can use the files in [/sample_files](https://github.com/redoxcode/micropython-dfplayer/tree/main/sample_files) to test your module.\n\nSometimes the module isn't able to keep up if you try to send commands to fast, so some delay between the commands is needed.\n\n## Examples\n\n### Play a file from a folder\n```Python\nimport time\nfrom dfplayer import DFPlayer\ndf=DFPlayer(uart_id=1,tx_pin_id=4,rx_pin_id=5)\n#wait some time till the DFPlayer is ready\ntime.sleep(0.2)\n#change the volume (0-30). The DFPlayer doesn't remember these settings\ndf.volume(25)\ntime.sleep(0.2)\n#play file ./01/001.mp3\ndf.play(1,1)\n```\n### Find the number of files in a folder\nIf a folder doesn't exist, get_files_in_folder will return -1\n```Python\nimport time\nfrom dfplayer import DFPlayer\ndf=DFPlayer(uart_id=1,tx_pin_id=4,rx_pin_id=5)\n#wait some time till the DFPlayer is ready\ntime.sleep(0.2)\nprint(df.get_files_in_folder(1))\ntime.sleep(0.2)\nprint(df.get_files_in_folder(4))\n```\n\n## API\n### class DFPlayer(uart_id,tx_pin_id=None,rx_pin_id=None)\n- uart_id: Uart channel you want to use (0 or 1 for pi pico)\n- tx_pin_id: Pin id for uart tx if your board supports changing the pins of the uart channel. \n- tx_pin_id: Pin id for uart rx if your board supports changing the pins of the uart channel. \n\n```play(folder,file)```\n- play a file from a folder (stops all previous playback)\n- folder: Folder number of the file you want to play\n- file: File number of the file you want to play\n\n```stop()```\n- stop all playback\n\n```volume(vol)```\n- set the volume of the module\n- vol: Volume of the module. The range is 0 to 30. The DFPlayer doesn't remember these settings\n\n```get_volume()```\n- returns the current volume setting of the module\n\n```\u00ecs_playing()```\n- returns if currently some playback is running\n\n```get_files_in_folder(folder)```\n- returns the number of files in a folder or -1 if the folder doesn't exist\n- folder: folder to get the number of files in\n\n```reset()```\n- reset the module\n\n```send_cmd(cmd,param1=0,param2=0)```\n- sends a command byte with 2 bytes for parameters to the module. This can be used to send commands not yet implemented in this library. Use the modules [documentation](https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299) as reference.\n- cmd: cammand byte (0-255)\n- param1: parameter 1 or MSB of a 2 byte parameter\n- param2: parameter 2 or LSB of a 2 byte parameter\n\n```send_query(cmd,param1=0,param2=0)```\n- like send_cmd, but returns the bytes the module sends as answer to the query\n- cmd: cammand byte (0-255)\n- param1: parameter 1 or MSB of a 2 byte parameter\n- param2: parameter 2 or LSB of a 2 byte parameter\n\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2022 redoxcode Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Library to use the DFPlayer mini mp3 player module with micropython",
"version": "1.0.0",
"split_keywords": [
"dfmini",
"dfplayer",
"mp3"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "3fb990c689cccab3ae2eeab1180d1aac",
"sha256": "f0c81efc4a89b3fb30d876855de913253346ed1f8e5b01b0bfe7e23dffa0966e"
},
"downloads": -1,
"filename": "micropython_dfmini-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3fb990c689cccab3ae2eeab1180d1aac",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5147,
"upload_time": "2022-12-30T14:15:45",
"upload_time_iso_8601": "2022-12-30T14:15:45.809749Z",
"url": "https://files.pythonhosted.org/packages/a4/f9/e37641fe96e4143db92f222bd4e66ae3cf7c99e806a6ea2bbb829f1a10b5/micropython_dfmini-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "8ebe6ea97d0d14ffed8ec0023ce6b65d",
"sha256": "b3748dd7c7633a74e37466e4ce3e131ab4d95d5ec73c83dc1bc30c8937a3b12a"
},
"downloads": -1,
"filename": "micropython-dfmini-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "8ebe6ea97d0d14ffed8ec0023ce6b65d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4200,
"upload_time": "2022-12-30T14:15:47",
"upload_time_iso_8601": "2022-12-30T14:15:47.589697Z",
"url": "https://files.pythonhosted.org/packages/22/5c/cc89f21df1ad56559c48062e467132b78e6e4d00183c772c123ebf9b86c4/micropython-dfmini-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-30 14:15:47",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "micropython-dfmini"
}