From 5702fc5e26394f8bc219b1ad21292d364e13354b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 5 Jun 2019 16:14:50 +0200 Subject: [PATCH] Workaround issue #5161 Workaround issue #5161 --- sonoff/xnrg_01_hlw8012.ino | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sonoff/xnrg_01_hlw8012.ino b/sonoff/xnrg_01_hlw8012.ino index e26f195fb..f120b4725 100644 --- a/sonoff/xnrg_01_hlw8012.ino +++ b/sonoff/xnrg_01_hlw8012.ino @@ -67,6 +67,7 @@ uint8_t hlw_ui_flag = 1; uint8_t hlw_model_type = 0; uint8_t hlw_load_off = 1; uint8_t hlw_cf1_timer = 0; +uint8_t hlw_power_retry = 0; // Fix core 2.5.x ISR not in IRAM Exception #ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves exception @@ -126,8 +127,13 @@ void HlwEvery200ms(void) if (hlw_cf_power_pulse_length && energy_power_on && !hlw_load_off) { hlw_w = (hlw_power_ratio * Settings.energy_power_calibration) / hlw_cf_power_pulse_length; // W *10 energy_active_power = (float)hlw_w / 10; + hlw_power_retry = 1; // Workaround issue #5161 } else { - energy_active_power = 0; + if (hlw_power_retry) { + hlw_power_retry--; + } else { + energy_active_power = 0; + } } if (pin[GPIO_NRG_CF1] < 99) {