From 20577e0d5b24889a4cb0f04c7a1789c8fbe60105 Mon Sep 17 00:00:00 2001 From: halfbakery Date: Mon, 22 Jun 2020 17:21:13 +0200 Subject: [PATCH] Interlock mode can be set upon compilation --- tasmota/my_user_config.h | 6 ++++++ tasmota/settings.ino | 31 +++++++++++++++++++++++++++---- tasmota/support_command.ino | 3 ++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 4f5623de19c3..190769c90510 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -280,6 +280,12 @@ #define APP_DISABLE_POWERCYCLE false // [SetOption65] Disable fast power cycle detection for device reset #define DEEPSLEEP_BOOTCOUNT false // [SetOption76] Enable incrementing bootcount when deepsleep is enabled +#define APP_INTERLOCK_MODE false // [Interlock] Relay interlock mode +#define APP_INTERLOCK_GROUP_1 0xFF // [Interlock] Relay bitmask for interlock group 1 (0x00 if undef) +//#define APP_INTERLOCK_GROUP_2 0x00 // [Interlock] Relay bitmask for interlock group 2 (0x00 if undef) +//#define APP_INTERLOCK_GROUP_3 0x00 // [Interlock] Relay bitmask for interlock group 3 (0x00 if undef) +//#define APP_INTERLOCK_GROUP_4 0x00 // [Interlock] Relay bitmask for interlock group 4 (0x00 if undef) + // -- Lights -------------------------------------- #define WS2812_LEDS 30 // [Pixels] Number of WS2812 LEDs to start with (max is 512) #define LIGHT_MODE true // [SetOption15] Switch between commands PWM or COLOR/DIMMER/CT/CHANNEL diff --git a/tasmota/settings.ino b/tasmota/settings.ino index d7ede5f2518f..116ba274cd08 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -765,8 +765,20 @@ void SettingsDefaultSet2(void) } // Module -// flag.interlock |= 0; - Settings.interlock[0] = 0xFF; // Legacy support using all relays in one interlock group + flag.interlock |= APP_INTERLOCK_MODE; + for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; } +#ifdef APP_INTERLOCK_GROUP_1 + Settings.interlock[0] = APP_INTERLOCK_GROUP_1; // Legacy support using all relays in one interlock group +#endif +#ifdef APP_INTERLOCK_GROUP_2 + Settings.interlock[1] = APP_INTERLOCK_GROUP_2; +#endif +#ifdef APP_INTERLOCK_GROUP_3 + Settings.interlock[2] = APP_INTERLOCK_GROUP_3; +#endif +#ifdef APP_INTERLOCK_GROUP_4 + Settings.interlock[3] = APP_INTERLOCK_GROUP_4; +#endif Settings.module = MODULE; Settings.fallback_module = FALLBACK_MODULE; ModuleDefault(WEMOS); @@ -1188,8 +1200,19 @@ void SettingsDelta(void) Settings.param[P_MDNS_DELAYED_START] = 0; } if (Settings.version < 0x0604010B) { - Settings.interlock[0] = 0xFF; // Legacy support using all relays in one interlock group - for (uint32_t i = 1; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; } + for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; } +#ifdef APP_INTERLOCK_GROUP_1 + Settings.interlock[0] = APP_INTERLOCK_GROUP_1; // Legacy support using all relays in one interlock group +#endif +#ifdef APP_INTERLOCK_GROUP_2 + Settings.interlock[1] = APP_INTERLOCK_GROUP_2; +#endif +#ifdef APP_INTERLOCK_GROUP_3 + Settings.interlock[2] = APP_INTERLOCK_GROUP_3; +#endif +#ifdef APP_INTERLOCK_GROUP_4 + Settings.interlock[3] = APP_INTERLOCK_GROUP_4; +#endif } if (Settings.version < 0x0604010D) { Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET; // SetOption36 diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index e23fda355db6..612f4dbce667 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1627,7 +1627,8 @@ void CmndInterlock(void) } ResponseAppend_P(PSTR("\"}")); } else { - Settings.flag.interlock = 0; // CMND_INTERLOCK - Enable/disable interlock + // never ever reset interlock mode inadvertently if we forced it upon compilation + Settings.flag.interlock = APP_INTERLOCK_MODE; // CMND_INTERLOCK - Enable/disable interlock ResponseCmndStateText(Settings.flag.interlock); } }