From 2e7652b9d3ddee0ee7dddb532aa526b5e6506095 Mon Sep 17 00:00:00 2001 From: Matt Hawkins Date: Mon, 11 Nov 2024 20:25:58 +0000 Subject: [PATCH 1/2] Add volume up and down functions --- README.md | 6 ++++++ src/dfplayer/__init__.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index c93a8de..f6aafb8 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,12 @@ print(df.get_files_in_folder(4)) - set the volume of the module. - vol: Volume of the module. The range is 0 to 30. The DFPlayer doesn't remember these settings +```volume_up()``` +- increase the volume by 1 up to the maximum of 30. + +```volume_up()``` +- decrease the volume by 1 down to the minimum of 1. + ```get_volume()``` - returns the current volume setting of the module or -1 on communication error diff --git a/src/dfplayer/__init__.py b/src/dfplayer/__init__.py index 5d5c465..0ff6f08 100644 --- a/src/dfplayer/__init__.py +++ b/src/dfplayer/__init__.py @@ -60,6 +60,12 @@ def play(self,folder,file): def volume(self,vol): self.send_cmd(6,0,vol) + + def volume_up(self): + self.send_cmd(4,0,0) + + def volume_down(self): + self.send_cmd(5,0,0) def reset(self): self.send_cmd(12,0,1) From 755c93bf526ce464e338b8c962d4d505de75e149 Mon Sep 17 00:00:00 2001 From: Matt Hawkins Date: Mon, 11 Nov 2024 20:31:49 +0000 Subject: [PATCH 2/2] Corrected typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6aafb8..a4f5683 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ print(df.get_files_in_folder(4)) ```volume_up()``` - increase the volume by 1 up to the maximum of 30. -```volume_up()``` +```volume_down()``` - decrease the volume by 1 down to the minimum of 1. ```get_volume()```