From 432051a7ef19b7fe6df7e89e98877ffc439eacc3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 31 Oct 2020 12:04:28 +0100 Subject: [PATCH] Fix setting last module --- tasmota/support_tasmota.ino | 4 ++++ tasmota/tasmota.h | 1 + tasmota/xdrv_26_ariluxrf.ino | 4 ++-- tasmota/xdrv_35_pwm_dimmer.ino | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index efad19e99..4fe04263e 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -791,6 +791,10 @@ void PerformEverySecond(void) { TasmotaGlobal.uptime++; + if (LAST_MODULE_SET_TIME == TasmotaGlobal.uptime) { + Settings.last_module = Settings.module; // Needs to be done after AriluxRfInit() and PWMModulePreInit() + } + if (POWER_CYCLE_TIME == TasmotaGlobal.uptime) { UpdateQuickPowerCycle(false); } diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index 442bf93aa..9e62d284b 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -124,6 +124,7 @@ const uint8_t MAX_POWER_RETRY = 5; // Retry count allowing agreed power const uint8_t STATES = 20; // Number of states per second using 50 mSec interval const uint8_t IMMINENT_RESET_FACTOR = 10; // Factor to extent button hold time for imminent Reset to default 40 seconds using KEY_HOLD_TIME of 40 +const uint32_t LAST_MODULE_SET_TIME = 12; // Number of seconds to set last module to current module const uint32_t BOOT_LOOP_TIME = 10; // Number of seconds to stop detecting boot loops const uint32_t POWER_CYCLE_TIME = 8; // Number of seconds to reset power cycle boot loops const uint16_t SYSLOG_TIMER = 600; // Seconds to restore syslog_level diff --git a/tasmota/xdrv_26_ariluxrf.ino b/tasmota/xdrv_26_ariluxrf.ino index b9e2f6c56..a6e4378fd 100644 --- a/tasmota/xdrv_26_ariluxrf.ino +++ b/tasmota/xdrv_26_ariluxrf.ino @@ -149,7 +149,7 @@ void AriluxRfInit(void) if (Settings.last_module != Settings.module) { Settings.rf_code[1][6] = 0; Settings.rf_code[1][7] = 0; - Settings.last_module = Settings.module; +// Settings.last_module = Settings.module; // Will be done at LAST_MODULE_SET_TIME after restart as other drivers also test for module change } Arilux.rf_received_value = 0; @@ -179,7 +179,7 @@ bool Xdrv26(uint8_t function) if (PinUsed(GPIO_ARIRFRCV)) { AriluxRfHandler(); } break; case FUNC_EVERY_SECOND: - if (10 == TasmotaGlobal.uptime) { AriluxRfInit(); } // Needs rest before enabling RF interrupts + if (LAST_MODULE_SET_TIME -2 == TasmotaGlobal.uptime) { AriluxRfInit(); } // Needs rest before enabling RF interrupts break; } return result; diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index e2602c874..32ae4c36f 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -91,7 +91,7 @@ void PWMModulePreInit(void) if (Settings.last_module != Settings.module) { Settings.flag.pwm_control = true; // SetOption15 - Switch between commands PWM or COLOR/DIMMER/CT/CHANNEL Settings.bri_power_on = Settings.bri_preset_low = Settings.bri_preset_high = 0; - Settings.last_module = Settings.module; +// Settings.last_module = Settings.module; // Will be done at LAST_MODULE_SET_TIME after restart as other drivers also test for module change // Previous versions of PWM Dimmer used SetOption32 - Button held for factor times longer as the // hold time. The hold time is now fixed and SetOption32 is used as normal including to