Browse Source

Option to reset energy count #671

rfm69
Xose Pérez 6 years ago
parent
commit
ec56573741
8 changed files with 3208 additions and 3159 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +27
    -0
      code/espurna/sensor.ino
  3. +6
    -0
      code/espurna/sensors/EmonSensor.h
  4. +4
    -0
      code/espurna/sensors/HLW8012Sensor.h
  5. +3158
    -3157
      code/espurna/static/index.html.gz.h
  6. +3
    -0
      code/html/custom.js
  7. +8
    -0
      code/html/index.html
  8. +2
    -2
      code/platformio.ini

BIN
code/espurna/data/index.html.gz View File


+ 27
- 0
code/espurna/sensor.ino View File

@ -597,12 +597,34 @@ void _sensorConfigure() {
delSetting("pwrRatioC"); delSetting("pwrRatioC");
} }
if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy();
}
sensor->setVoltage(getSetting("pwrVoltage", EMON_MAINS_VOLTAGE).toInt()); sensor->setVoltage(getSetting("pwrVoltage", EMON_MAINS_VOLTAGE).toInt());
} }
#endif // EMON_ANALOG_SUPPORT #endif // EMON_ANALOG_SUPPORT
#if EMON_ADC121_SUPPORT
if (_sensors[i]->getID() == SENSOR_EMON_ADC121_ID) {
EmonADC121Sensor * sensor = (EmonADC121Sensor *) _sensors[i];
if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy();
}
}
#endif
#if EMON_ADS1X15_SUPPORT
if (_sensors[i]->getID() == SENSOR_EMON_ADS1X15_ID) {
EmonADS1X15Sensor * sensor = (EmonADS1X15Sensor *) _sensors[i];
if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy();
}
}
#endif
#if HLW8012_SUPPORT #if HLW8012_SUPPORT
@ -626,6 +648,10 @@ void _sensorConfigure() {
setSetting("pwrRatioP", sensor->getPowerRatio()); setSetting("pwrRatioP", sensor->getPowerRatio());
} }
if (getSetting("pwrResetE", 0).toInt() == 1) {
sensor->resetEnergy();
}
if (getSetting("pwrResetCalibration", 0).toInt() == 1) { if (getSetting("pwrResetCalibration", 0).toInt() == 1) {
sensor->resetRatios(); sensor->resetRatios();
delSetting("pwrRatioC"); delSetting("pwrRatioC");
@ -649,6 +675,7 @@ void _sensorConfigure() {
delSetting("pwrExpectedC"); delSetting("pwrExpectedC");
delSetting("pwrExpectedV"); delSetting("pwrExpectedV");
delSetting("pwrResetCalibration"); delSetting("pwrResetCalibration");
delSetting("pwrResetE");
saveSettings(); saveSettings();
} }


+ 6
- 0
code/espurna/sensors/EmonSensor.h View File

@ -42,6 +42,12 @@ class EmonSensor : public I2CSensor {
_dirty = true; _dirty = true;
} }
void resetEnergy() {
for (unsigned char i=0; i<_channels; i++) {
_energy[i] = 0;
}
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
void setVoltage(double voltage) { void setVoltage(double voltage) {


+ 4
- 0
code/espurna/sensors/HLW8012Sensor.h View File

@ -48,6 +48,10 @@ class HLW8012Sensor : public BaseSensor {
_hlw8012->resetMultipliers(); _hlw8012->resetMultipliers();
} }
void resetEnergy() {
_hlw8012->resetEnergy();
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
void setSEL(unsigned char sel) { void setSEL(unsigned char sel) {


+ 3158
- 3157
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 3
- 0
code/html/custom.js View File

@ -434,6 +434,9 @@ function doUpdate() {
$("input[name='pwrResetCalibration']"). $("input[name='pwrResetCalibration']").
prop("checked", false). prop("checked", false).
iphoneStyle("refresh"); iphoneStyle("refresh");
$("input[name='pwrResetE']").
prop("checked", false).
iphoneStyle("refresh");
// Change handling // Change handling
numChanged = 0; numChanged = 0;


+ 8
- 0
code/html/index.html View File

@ -1117,6 +1117,14 @@
<div class="pure-u-1 pure-u-lg-3-4 hint">Move this switch to ON and press "Save" to revert to factory calibration values.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Move this switch to ON and press "Save" to revert to factory calibration values.</div>
</div> </div>
<div class="pure-g module module-hlw module-emon">
<label class="pure-u-1 pure-u-lg-1-4">Reset energy</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="pwrResetE" tabindex="56" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Move this switch to ON and press "Save" to set energy count to 0.</div>
</div>
</fieldset> </fieldset>
</div> </div>


+ 2
- 2
code/platformio.ini View File

@ -4,8 +4,8 @@ src_dir = espurna
data_dir = espurna/data data_dir = espurna/data
[common] [common]
platform = espressif8266@1.6.0
; platform = espressif8266@1.5.0
; platform = espressif8266@1.6.0
platform = espressif8266@1.5.0
; platform = https://github.com/platformio/platform-espressif8266.git#v1.5.0 ; platform = https://github.com/platformio/platform-espressif8266.git#v1.5.0
build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS} build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS}
debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM


Loading…
Cancel
Save