From 8461686a0555d5192f01b90e7680ee32a91a04b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 20 Sep 2017 11:24:29 +0200 Subject: [PATCH] Rename power settings --- code/espurna/power.ino | 20 ++++++++++++-------- code/espurna/power_emon.ino | 15 ++++++++++----- code/espurna/power_hlw8012.ino | 12 ++++++------ code/html/index.html | 2 +- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/code/espurna/power.ino b/code/espurna/power.ino index d7720bf3..8a970830 100644 --- a/code/espurna/power.ino +++ b/code/espurna/power.ino @@ -281,14 +281,18 @@ void powerConfigure() { void powerSetup() { // backwards compatibility - moveSetting("pwMainsVoltage", "powerVoltage"); - moveSetting("emonMains", "powerVoltage"); - moveSetting("emonVoltage", "powerVoltage"); - moveSetting("pwCurrentRatio", "powerRatioC"); - moveSetting("emonRatio", "powerRatioC"); - moveSetting("powPowerMult", "powerRatioP"); - moveSetting("powCurrentMult", "powerRatioC"); - moveSetting("powVoltageMult", "powerRatioV"); + moveSetting("pwMainsVoltage", "pwrVoltage"); + moveSetting("emonMains", "pwrVoltage"); + moveSetting("emonVoltage", "pwrVoltage"); + moveSetting("pwCurrentRatio", "pwrRatioC"); + moveSetting("emonRatio", "pwrRatioC"); + moveSetting("powPowerMult", "pwrRatioP"); + moveSetting("powCurrentMult", "pwrRatioC"); + moveSetting("powVoltageMult", "pwrRatioV"); + moveSetting("powerVoltage", "pwrVoltage"); + moveSetting("powerRatioC", "pwrRatioC"); + moveSetting("powerRatioV", "pwrRatioV"); + moveSetting("powerRatioP", "pwrRatioP"); _powerSetupProvider(); diff --git a/code/espurna/power_emon.ino b/code/espurna/power_emon.ino index 8e233a9e..4e91e077 100644 --- a/code/espurna/power_emon.ino +++ b/code/espurna/power_emon.ino @@ -104,23 +104,28 @@ void _powerCalibrateProvider(unsigned char magnitude, double value) { if (value <= 0) return; if (magnitude == POWER_MAGNITUDE_ACTIVE) { double power = _powerActivePower(); - double ratio = getSetting("powerRatioC", EMON_CURRENT_RATIO).toFloat(); + double ratio = getSetting("pwrRatioC", EMON_CURRENT_RATIO).toFloat(); ratio = ratio * (value / power); _emon.setCurrentRatio(ratio); - setSetting("powerRatioC", ratio); + setSetting("pwrRatioC", ratio); + saveSettings(); + } + if (magnitude == POWER_MAGNITUDE_VOLTAGE) { + _power_voltage = value; + setSetting("pwrVoltage", value); saveSettings(); } } void _powerResetCalibrationProvider() { - delSetting("powerRatioC"); + delSetting("pwrRatioC"); _powerConfigureProvider(); saveSettings(); } void _powerConfigureProvider() { - _emon.setCurrentRatio(getSetting("powerRatioC", EMON_CURRENT_RATIO).toFloat()); - _power_voltage = getSetting("powerVoltage", POWER_VOLTAGE).toFloat(); + _emon.setCurrentRatio(getSetting("pwrRatioC", EMON_CURRENT_RATIO).toFloat()); + _power_voltage = getSetting("pwrVoltage", POWER_VOLTAGE).toFloat(); } void _powerSetupProvider() { diff --git a/code/espurna/power_hlw8012.ino b/code/espurna/power_hlw8012.ino index db04d235..8f6448f6 100644 --- a/code/espurna/power_hlw8012.ino +++ b/code/espurna/power_hlw8012.ino @@ -32,18 +32,18 @@ void ICACHE_RAM_ATTR _hlw_cf_isr() { void _hlwSetCalibration() { double value; - value = getSetting("powerRatioP", 0).toFloat(); + value = getSetting("pwrRatioP", 0).toFloat(); if (value > 0) _hlw8012.setPowerMultiplier(value); - value = getSetting("powerRatioC", 0).toFloat(); + value = getSetting("pwrRatioC", 0).toFloat(); if (value > 0) _hlw8012.setCurrentMultiplier(value); - value = getSetting("powerRatioV", 0).toFloat(); + value = getSetting("pwrRatioV", 0).toFloat(); if (value > 0) _hlw8012.setVoltageMultiplier(value); } void _hlwGetCalibration() { - setSetting("powerRatioP", _hlw8012.getPowerMultiplier()); - setSetting("powerRatioC", _hlw8012.getCurrentMultiplier()); - setSetting("powerRatioV", _hlw8012.getVoltageMultiplier()); + setSetting("pwrRatioP", _hlw8012.getPowerMultiplier()); + setSetting("pwrRatioC", _hlw8012.getCurrentMultiplier()); + setSetting("pwrRatioV", _hlw8012.getVoltageMultiplier()); saveSettings(); } diff --git a/code/html/index.html b/code/html/index.html index 2eda8792..b5290cab 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -798,7 +798,7 @@
In percentage (%). You will need to use a calibrated multimeter to get this value and a mixed resistive and reactive load.
-
+