diff --git a/SonoffHMLOX.ino b/SonoffHMLOX.ino index 4ada2e4..ec076f3 100644 --- a/SonoffHMLOX.ino +++ b/SonoffHMLOX.ino @@ -76,7 +76,8 @@ enum TransmitStates_e { enum GPIO14Modes_e { GPIO14Mode_OFF, GPIO14Mode_KEY, - GPIO14Mode_SWITCH + GPIO14Mode_SWITCH_ABSOLUT, + GPIO14Mode_SWITCH_TOGGLE }; struct globalconfig_t { @@ -390,14 +391,17 @@ void loop() { CurrentSwitchGPIO14State = digitalRead(SwitchGPIOPin14); //GPIO14 als Schalter - if (GlobalConfig.GPIO14Mode == GPIO14Mode_SWITCH) { + if (GlobalConfig.GPIO14Mode == GPIO14Mode_SWITCH_ABSOLUT || GlobalConfig.GPIO14Mode == GPIO14Mode_SWITCH_TOGGLE) { if (CurrentSwitchGPIO14State != LastSwitchGPIOPin14State) { DEBUG("GPIO14 neuer Status = " + String(CurrentSwitchGPIO14State), "loop()", _slInformational); LastSwitchGPIOPin14State = CurrentSwitchGPIO14State; if (GlobalConfig.GPIO14asSender) { if (GlobalConfig.BackendType == BackendType_HomeMatic) setStateCUxD(HomeMaticConfig.ChannelNameSender + ".SET_STATE", (!CurrentSwitchGPIO14State ? "true" : "false")); } else { - switchRelay(!CurrentSwitchGPIO14State, TRANSMITSTATE); //HIGH = off, LOW = on + if (GlobalConfig.GPIO14Mode == GPIO14Mode_SWITCH_ABSOLUT) + switchRelay(!CurrentSwitchGPIO14State, TRANSMITSTATE); //HIGH = off, LOW = on + if (GlobalConfig.GPIO14Mode == GPIO14Mode_SWITCH_TOGGLE) + toggleRelay(TRANSMITSTATE); } } } diff --git a/Web.ino b/Web.ino index f6de9c8..cb4c710 100644 --- a/Web.ino +++ b/Web.ino @@ -11,7 +11,7 @@ const char HTTP_CALIB_INPUT[] PROGMEM = "
Last (W): | 0) { GlobalConfig.restoreOldRelayState = false; GlobalConfig.LEDDisabled = false; + GlobalConfig.GPIO14asSender = false; for (int i = 0; i < WebServer.args(); i++) { if (WebServer.argName(i) == "btnSave") sc = (WebServer.arg(i).toInt() == 1); @@ -278,22 +279,32 @@ void configHtml() { case GPIO14Mode_OFF: page.replace("{gpio14mode_off}", "selected"); page.replace("{gpio14mode_key}", ""); - page.replace("{gpio14mode_switch}", ""); + page.replace("{gpio14mode_switch_abs}", ""); + page.replace("{gpio14mode_switch_tog}", ""); break; case GPIO14Mode_KEY: page.replace("{gpio14mode_off}", ""); page.replace("{gpio14mode_key}", "selected"); - page.replace("{gpio14mode_switch}", ""); + page.replace("{gpio14mode_switch_abs}", ""); + page.replace("{gpio14mode_switch_tog}", ""); break; - case GPIO14Mode_SWITCH: + case GPIO14Mode_SWITCH_ABSOLUT: page.replace("{gpio14mode_off}", ""); page.replace("{gpio14mode_key}", ""); - page.replace("{gpio14mode_switch}", "selected"); + page.replace("{gpio14mode_switch_abs}", "selected"); + page.replace("{gpio14mode_switch_tog}", ""); + break; + case GPIO14Mode_SWITCH_TOGGLE: + page.replace("{gpio14mode_off}", ""); + page.replace("{gpio14mode_key}", ""); + page.replace("{gpio14mode_switch_abs}", ""); + page.replace("{gpio14mode_switch_tog}", "selected"); break; default: page.replace("{gpio14mode_off}", "selected"); page.replace("{gpio14mode_key}", ""); - page.replace("{gpio14mode_switch}", ""); + page.replace("{gpio14mode_switch_abs}", ""); + page.replace("{gpio14mode_switch_tog}", ""); break; } page.replace("{gpio14assender}", ((GlobalConfig.GPIO14asSender) ? "checked" : "")); diff --git a/WifiManager.ino b/WifiManager.ino index 6c4490f..2fe603f 100644 --- a/WifiManager.ino +++ b/WifiManager.ino @@ -96,20 +96,23 @@ bool doWifiConnect() { String gpio14 = ""; switch (GlobalConfig.GPIO14Mode) { case GPIO14Mode_OFF: - gpio14 = F(""); + gpio14 = F(""); break; case GPIO14Mode_KEY: - gpio14 = F(""); + gpio14 = F(""); + break; + case GPIO14Mode_SWITCH_ABSOLUT: + gpio14 = F(""); break; - case GPIO14Mode_SWITCH: - gpio14 = F(""); + case GPIO14Mode_SWITCH_TOGGLE: + gpio14 = F(""); break; default: gpio14 = F(""); break; } WiFiManagerParameter custom_gpio14mode("gpio14mode_switch", "GPIO14 Mode", "", 8, 2, gpio14.c_str()); - + char*chrGPIO14asSender = "0"; if (GlobalConfig.GPIO14asSender) chrGPIO14asSender = "1" ; WiFiManagerParameter custom_gpio14assender("custom_gpio14assender_switch", "GPIO14 nur Sender: ", chrGPIO14asSender, 8, 1); |