Repository: miczflor/rpi-jukebox-rfid
Issue: 🐛 | VolumeUp / VolumeDown not working properly with GPIO Buttons since 2.1

## Bug
Since 2.1 and the new gpio buttons implementation the VolumeUp VolumeDown commands are not working properly. When I start and have a base sound level of 15 and I push the button up, it will become 63.

### What I did
I made a clean install (buster) to verify #1078 and ran into this issue. Having set up all as default and the buttons connected to the pins as mentioned in the old default setup guide.

### What happened
Sound is increased / decreased by wrong values

### Further information that might help
Debugged the playout_controls.sh and found out, that in the line with `VOLPERCENT=´expr ${VOLPERCENT} + \\( ${AUDIOVOLCHANGESTEP} \\* ${VALUE} \\)´` value seems to be the value of the defined pin (e.g. 16 or 19 for VolumeUp or VolumeDown)

## Software

### Base image and version
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

### Branch / Release
master /fresh version 2.1

### Installscript
* scripts/installscripts/buster-install-default.sh

## Hardware

### RaspberryPi version

Raspberry Pi 3 Model B Rev 1.2

### RFID Reader
`16c0:27db HXGCoLtd Keyboard`

### Soundcard
i.e. `0d8c:0014 C-Media Electronics, Inc. Audio Adapter (Unitek Y-247A)`

### Other notable hardware
default gpio_settings but with enabled VolumeUp / VolumeDown buttons


Changed files:
components/gpio_control/test/test_SimpleButton.py, components/gpio_control/GPIODevices/simple_button.py

diff --git a/components/gpio_control/GPIODevices/simple_button.py b/components/gpio_control/GPIODevices/simple_button.py
index 730f6573..250a5973 100644
--- a/components/gpio_control/GPIODevices/simple_button.py
+++ b/components/gpio_control/GPIODevices/simple_button.py
@@ -74,10 +74,11 @@ class SimpleButton:
                               bouncetime=self.bouncetime)
 
     def callbackFunctionHandler(self, *args):
-        logger.info('args: {}'.format(*args))
         if (len(args) > 0 and args[0] == self.pin):
+            logger.debug('args before: {}'.format(args))
             args = args[1:]
-			
+            logger.debug('args after: {}'.format(args))
+
         if self.hold_repeat:
             return self.holdAndRepeatHandler(*args)
         logger.info('{}: executre callback'.format(self.name))
diff --git a/components/gpio_control/test/test_SimpleButton.py b/components/gpio_control/test/test_SimpleButton.py
index 7e6aefa0..87a3afe6 100644
--- a/components/gpio_control/test/test_SimpleButton.py
+++ b/components/gpio_control/test/test_SimpleButton.py
@@ -10,6 +10,8 @@ mockedAction = MagicMock()
 
 @pytest.fixture
 def simple_button():
+    mockedAction.reset_mock()
+
     return SimpleButton(pin, action=mockedAction, name='TestButton',
                         bouncetime=500, edge=GPIO.FALLING)
 
@@ -22,16 +24,30 @@ class TestButton:
                      bouncetime=500, edge=GPIO.FALLING)
 
     def test_callback(self, simple_button):
-        simple_button.callbackFunctionHandler()(simple_button.pin)
-        mockedAction.asser_called_once()
+        simple_button.callbackFunctionHandler(simple_button.pin)
+        mockedAction.assert_called_once_with()
+
+    def test_callback_without_pin_argument(self, simple_button):
+        simple_button.callbackFunctionHandler()
+        mockedAction.assert_called_once_with()
+
+    def test_callback_with_wrong_pin_argument(self, simple_button):
+        simple_button.callbackFunctionHandler(simple_button.pin + 1)
+        mockedAction.assert_called_once_with(simple_button.pin + 1)
+
+    def test_callback_with_more_arguments(self, simple_button):
+        simple_button.callbackFunctionHandler(simple_button.pin, 5)
+        mockedAction.assert_called_once_with(5)
 
     def test_change_when_pressed(self, simple_button):
-        mockedAction.asser_called_once()
+        simple_button.callbackFunctionHandler(simple_button.pin, 5)
+
         newMockedAction = MagicMock()
         simple_button.when_pressed = newMockedAction
-        simple_button.callbackFunctionHandler()(simple_button.pin)
-        newMockedAction.asser_called_once()
-        mockedAction.asser_called_once()
+        simple_button.callbackFunctionHandler(simple_button.pin)
+
+        newMockedAction.assert_called_once_with()
+        mockedAction.assert_called_once_with(5)
 
     def test_hold(self, simple_button):
         GPIO.LOW = 0