Browse Source

Issue #194. Fix HLW8012 calibration

fastled
Xose Pérez 7 years ago
parent
commit
09082826e1
4 changed files with 13 additions and 15 deletions
  1. +3
    -0
      code/espurna/espurna.ino
  2. +4
    -3
      code/espurna/hlw8012.ino
  3. +0
    -8
      code/espurna/settings.ino
  4. +6
    -4
      code/espurna/web.ino

+ 3
- 0
code/espurna/espurna.ino View File

@ -158,6 +158,9 @@ void welcome() {
#if EMON_SUPPORT
DEBUG_MSG_P(PSTR(" EMON"));
#endif
#if HLW8012_SUPPORT
DEBUG_MSG_P(PSTR(" HLW8012"));
#endif
#if HOMEASSISTANT_SUPPORT
DEBUG_MSG_P(PSTR(" HOMEASSISTANT"));
#endif


+ 4
- 3
code/espurna/hlw8012.ino View File

@ -57,16 +57,17 @@ void hlw8012SaveCalibration() {
setSetting("powPowerMult", hlw8012.getPowerMultiplier());
setSetting("powCurrentMult", hlw8012.getCurrentMultiplier());
setSetting("powVoltageMult", hlw8012.getVoltageMultiplier());
saveSettings();
}
void hlw8012RetrieveCalibration() {
double value;
value = getSetting("powPowerMult", 0).toFloat();
if (value > 0) hlw8012.setPowerMultiplier((int) value);
if (value > 0) hlw8012.setPowerMultiplier(value);
value = getSetting("powCurrentMult", 0).toFloat();
if (value > 0) hlw8012.setCurrentMultiplier((int) value);
if (value > 0) hlw8012.setCurrentMultiplier(value);
value = getSetting("powVoltageMult", 0).toFloat();
if (value > 0) hlw8012.setVoltageMultiplier((int) value);
if (value > 0) hlw8012.setVoltageMultiplier(value);
}
void hlw8012SetExpectedActivePower(unsigned int power) {


+ 0
- 8
code/espurna/settings.ino View File

@ -314,14 +314,6 @@ String getSetting(const String& key) {
return getSetting(key, "");
}
bool setBoolSetting(const String& key, bool value, bool defaultValue) {
if (value == defaultValue) {
return delSetting(key);
} else {
return setSetting(key, value ? 1 : 0);
}
}
template<typename T> bool setSetting(const String& key, T value) {
return Embedis::set(key, String(value));
}


+ 6
- 4
code/espurna/web.ino View File

@ -246,13 +246,15 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
}
if (key == "powExpectedReset") {
hlw8012Reset();
changed = true;
if (value.toInt() == 1) {
hlw8012Reset();
changed = true;
}
}
#endif
if (key.startsWith("pow")) continue;
if (key.startsWith("pow")) continue;
#endif
#if DOMOTICZ_SUPPORT


Loading…
Cancel
Save