From f2b98f7da3a02c646f416178ee791c8dd31a4cd9 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 30 Nov 2021 14:55:45 +0100 Subject: [PATCH] Add Xdrv function FUNC_BUTTON_MULTI_PRESSED --- tasmota/support_button.ino | 9 ++++++++- tasmota/tasmota.h | 2 +- tasmota/xdrv_04_light.ino | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tasmota/support_button.ino b/tasmota/support_button.ino index 3fbfff702..783ad475d 100644 --- a/tasmota/support_button.ino +++ b/tasmota/support_button.ino @@ -167,7 +167,7 @@ void ButtonHandler(void) { if (PinUsed(GPIO_KEY1, button_index)) { button_present = 1; #ifdef ESP32 -#ifndef CONFIG_IDF_TARGET_ESP32C3 +#ifndef CONFIG_IDF_TARGET_ESP32C3 if (bitRead(Button.touch_mask, button_index)) { // Touch uint32_t _value = touchRead(Pin(GPIO_KEY1, button_index)); button = NOT_PRESSED; @@ -313,6 +313,13 @@ void ButtonHandler(void) { } } } + + XdrvMailbox.index = button_index; + XdrvMailbox.payload = Button.press_counter[button_index]; + if (XdrvCall(FUNC_BUTTON_MULTI_PRESSED)) { + // Serviced + } else + #ifdef ROTARY_V1 if (!RotaryButtonPressed(button_index)) { #endif diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index f6a2b113d..77cbd00ce 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -341,7 +341,7 @@ enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_PIN_STATE, FUNC_MODULE_INIT, FU FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA, FUNC_SET_POWER, FUNC_SET_DEVICE_POWER, FUNC_SHOW_SENSOR, FUNC_ANY_KEY, FUNC_ENERGY_EVERY_SECOND, FUNC_ENERGY_RESET, - FUNC_RULES_PROCESS, FUNC_TELEPERIOD_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_BUTTON_PRESSED, + FUNC_RULES_PROCESS, FUNC_TELEPERIOD_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_BUTTON_PRESSED, FUNC_BUTTON_MULTI_PRESSED, FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_CONSOLE_BUTTON, FUNC_WEB_ADD_MANAGEMENT_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON, FUNC_WEB_ADD_HANDLER, FUNC_SET_CHANNELS, FUNC_SET_SCHEME, FUNC_HOTPLUG_SCAN, FUNC_DEVICE_GROUP_ITEM }; diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index a4f2c3e7e..f032b8b67 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -3205,6 +3205,9 @@ bool Xdrv04(uint8_t function) case FUNC_SET_POWER: LightSetPower(); break; + case FUNC_BUTTON_MULTI_PRESSED: + result = XlgtCall(FUNC_BUTTON_MULTI_PRESSED); + break; case FUNC_COMMAND: result = DecodeCommand(kLightCommands, LightCommand, kLightSynonyms); if (!result) {