From 70b54c489f921e56b07877ae04c04242469b9f2f Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sun, 1 Mar 2020 23:42:15 +0300 Subject: [PATCH] fixup struct members, dual no longer allocates debouncer --- code/espurna/button.ino | 49 ++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/code/espurna/button.ino b/code/espurna/button.ino index 7df0476f..915f9680 100644 --- a/code/espurna/button.ino +++ b/code/espurna/button.ino @@ -91,12 +91,12 @@ unsigned char buttonCount() { #if MQTT_SUPPORT -std::bitset _buttons_mqtt_retain( - (1 == BUTTON_MQTT_RETAIN) ? 0xFFFFFFFFUL : 0UL -); std::bitset _buttons_mqtt_send_all( (1 == BUTTON_MQTT_SEND_ALL_EVENTS) ? 0xFFFFFFFFUL : 0UL ); +std::bitset _buttons_mqtt_retain( + (1 == BUTTON_MQTT_RETAIN) ? 0xFFFFFFFFUL : 0UL +); void buttonMQTT(unsigned char id, uint8_t event) { char payload[4] = {0}; @@ -130,7 +130,7 @@ void _buttonWebSocketOnConnected(JsonObject& root) { JsonArray& schema = module.createNestedArray("_schema"); - schema.add("Pin"); + schema.add("Pin"); // GPIO id? schema.add("Mode"); schema.add("Relay"); @@ -150,17 +150,18 @@ void _buttonWebSocketOnConnected(JsonObject& root) { for (unsigned char i=0; i(GPIO_NONE), BUTTON_PUSHBUTTON, actions, relayID, delays); - return _buttons.size() - 1; -} - void buttonSetup() { + // Backwards compatibility + moveSetting("btnDelay", "btnDblDel"); + // Special hardware cases #if (BUTTON_EVENTS_SOURCE == BUTTON_EVENTS_SOURCE_ITEAD_SONOFF_DUAL) || \ @@ -299,10 +291,13 @@ void buttonSetup() { BUTTON_MODE_NONE, BUTTON_MODE_NONE, BUTTON_MODE_NONE ); + const auto delays = button_event_delays_t(); + for (unsigned char id = 0; id < buttons; ++id) { - buttonAdd( - GPIO_NONE, BUTTON_PUSHBUTTON, - actions, getSetting({"btnRelay", id}, _buttonRelay(id)) + _buttons.emplace_back( + nullptr, BUTTON_PUSHBUTTON, + actions, getSetting({"btnRelay", id}, _buttonRelay(id)), + delays ); }