Browse Source

Rename power settings

fastled
Xose Pérez 7 years ago
parent
commit
8461686a05
4 changed files with 29 additions and 20 deletions
  1. +12
    -8
      code/espurna/power.ino
  2. +10
    -5
      code/espurna/power_emon.ino
  3. +6
    -6
      code/espurna/power_hlw8012.ino
  4. +1
    -1
      code/html/index.html

+ 12
- 8
code/espurna/power.ino View File

@ -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();


+ 10
- 5
code/espurna/power_emon.ino View File

@ -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() {


+ 6
- 6
code/espurna/power_hlw8012.ino View File

@ -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();
}


+ 1
- 1
code/html/index.html View File

@ -798,7 +798,7 @@
<div class="pure-u-1 pure-u-md-3-4 hint">In percentage (%). You will need to use a calibrated multimeter to get this value and a mixed resistive and reactive load.</div>
</div>
<div class="pure-g module module-hlw module-v9261f">
<div class="pure-g module module-emon module-hlw module-v9261f">
<label class="pure-u-1 pure-u-md-1-4" for="pwrExpectedV">AC RMS Voltage</label>
<input class="pure-u-1 pure-u-md-3-4 pwrExpected" name="pwrExpectedV" type="text" size="8" tabindex="52" placeholder="0" />
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>


Loading…
Cancel
Save