Add Xdrv function FUNC_BUTTON_MULTI_PRESSED

This commit is contained in:
Theo Arends 2021-11-30 14:55:45 +01:00
parent 6bd0140dd9
commit f2b98f7da3
3 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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 };

View File

@ -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) {