From 4790339a7624e46d2ff62ad9c1899d8f58f3b065 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 15 Nov 2021 18:09:34 +0100 Subject: [PATCH] only update if changed --- DCCWaveform.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 99a59a3..e13fda4 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -36,6 +36,7 @@ volatile uint8_t DCCWaveform::numAckSamples=0; uint8_t DCCWaveform::trailingEdgeCounter=0; static unsigned long lastLCDCurrentDisplay=0; #define LCD_SAMPLE_PERIOD 2000 // milliseconds +static uint16_t lastLCDCurrent=0xFFFF; void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver) { mainTrack.motorDriver=mainDriver; @@ -186,7 +187,11 @@ void DCCWaveform::checkPowerOverload(bool ackManagerActive) { } if (isMainTrack && now - lastLCDCurrentDisplay > LCD_SAMPLE_PERIOD) { lastLCDCurrentDisplay=now; - LCD(2,F("I= %dmA"), mainTrack.getCurrentmA()); + uint16_t c=mainTrack.getCurrentmA(); + if (c != lastLCDCurrent) { + lastLCDCurrent=c; + LCD(2,F("I=%dmA"), c); + } } } // For each state of the wave nextState=stateTransform[currentState]