From 38baf8599c6c2c972a1a3e718fcd4681e0d4b807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 8 Dec 2017 17:17:50 +0100 Subject: [PATCH] Remove reset flag from MedianFilter::result --- code/espurna/libs/MedianFilter.h | 4 +--- code/espurna/power.ino | 12 +++++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/espurna/libs/MedianFilter.h b/code/espurna/libs/MedianFilter.h index de4aaaf6..be7239b2 100644 --- a/code/espurna/libs/MedianFilter.h +++ b/code/espurna/libs/MedianFilter.h @@ -38,7 +38,7 @@ class MedianFilter { return max; } - virtual double result(bool do_reset = false) { + virtual double result() { double sum = 0; @@ -66,8 +66,6 @@ class MedianFilter { } - if (do_reset) reset(); - return sum; } diff --git a/code/espurna/power.ino b/code/espurna/power.ino index 066018ed..f8ab8725 100644 --- a/code/espurna/power.ino +++ b/code/espurna/power.ino @@ -201,10 +201,10 @@ void _powerReport() { // Get the fitered values #if POWER_HAS_ACTIVE double max_power = _filter_active.max(); - _power_current = _filter_current.result(true); - _power_voltage = _filter_voltage.result(true); - _power_active = _filter_active.result(true); - _power_apparent = _filter_apparent.result(true); + _power_current = _filter_current.result(); + _power_voltage = _filter_voltage.result(); + _power_active = _filter_active.result(); + _power_apparent = _filter_apparent.result(); if (_power_active > _power_apparent) _power_apparent = _power_active; _power_reactive = (_power_apparent > _power_active) ? sqrt(_power_apparent * _power_apparent - _power_active * _power_active) : 0; _power_factor = (_power_apparent > 0) ? _power_active / _power_apparent : 1; @@ -212,7 +212,7 @@ void _powerReport() { double power = _power_active; #else double max_power = _filter_current.max() * _power_voltage; - _power_current = _filter_current.result(true); + _power_current = _filter_current.result(); _power_apparent = _power_current * _power_voltage; double power = _power_apparent; #endif @@ -283,6 +283,8 @@ void _powerReport() { } #endif + _powerReset(); + } void _powerConfigure() {