Skip to content

Commit 38d1d58

Browse files
authored
Fixes Display showing always all zeros (#511)
1 parent 4294ef1 commit 38d1d58

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

nodemanager/Child.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ void Child::setValue(const char* value) {
105105
// store a new value and update the total
106106
void Child::_setValueNumber(double value) {
107107
if (isnan(value)) return;
108+
// this is the first measure after a send(), reset _value and _total
109+
if (_samples == 0) {
110+
_value = 0;
111+
_total = 0;
112+
}
108113
if (_value_processing != NONE) _total = _total + value;
109114
// keep track of the samples
110115
_samples++;
@@ -211,15 +216,12 @@ void Child::print(Print& device) {
211216
void Child::reset() {
212217
if (_format != STRING) {
213218
if (_value_processing != NONE) {
214-
// reset the counters
215-
_total = 0;
216-
_value = 0;
217219
#if NODEMANAGER_EEPROM == ON
218220
// if the value is supposed to be persisted in EEPROM, save it
219221
if (_persist_value) saveValue();
220222
#endif
221223
}
222-
} else _value_string = "";
224+
}
223225
_samples = 0;
224226
}
225227

sensors/Display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Display: public Sensor {
3636
// prevent reporting to the gateway at each display update
3737
setReportTimerMode(DO_NOT_REPORT);
3838
// refresh the display every minute by default
39-
setMeasureTimerValue(TIME_INTERVAL);
39+
setMeasureTimerMode(TIME_INTERVAL);
4040
setMeasureTimerValue(60UL);
4141
};
4242

0 commit comments

Comments
 (0)