diff --git a/components/gpio_control/GPIODevices/simple_button.py b/components/gpio_control/GPIODevices/simple_button.py index 1256dc7cb..3055a15a5 100644 --- a/components/gpio_control/GPIODevices/simple_button.py +++ b/components/gpio_control/GPIODevices/simple_button.py @@ -106,11 +106,7 @@ def callbackFunctionHandler(self, *args): if inval != GPIO.LOW: return None - if self.hold_mode in ('Repeat', 'Postpone', 'SecondFunc', 'SecondFuncRepeat'): - return self.longPressHandler(*args) - else: - logger.info('{}: execute callback'.format(self.name)) - return self.when_pressed(*args) + return self._handleCallbackFunction(*args) @property def when_pressed(self): @@ -136,8 +132,8 @@ def when_pressed(self, func): def set_callbackFunction(self, callbackFunction): self.when_pressed = callbackFunction - def longPressHandler(self, *args): - logger.info('{}: longPressHandler, mode: {}'.format(self.name, self.hold_mode)) + def _handleCallbackFunction(self, *args): + logger.info('{}: handleCallbackFunction, mode: {}'.format(self.name, self.hold_mode)) # action(s) after hold_time if self.hold_mode == "Repeat": @@ -173,6 +169,9 @@ def longPressHandler(self, *args): while checkGpioStaysInState(self.hold_time, self.pin, GPIO.LOW): self.when_held(*args) + else: + self.when_pressed(*args) + def __del__(self): logger.debug('remove event detection') GPIO.remove_event_detect(self.pin)