From 387d59856cb62a4e53fe312a8a334c397617439a Mon Sep 17 00:00:00 2001 From: Jonas Berlin Date: Fri, 30 Nov 2018 07:55:19 +0200 Subject: [PATCH] Remove unnecessary variable We can just break out of the loop. --- EmonLib.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/EmonLib.cpp b/EmonLib.cpp index c77dcea..eb04dc8 100644 --- a/EmonLib.cpp +++ b/EmonLib.cpp @@ -77,15 +77,13 @@ void EnergyMonitor::calcVI(unsigned int crossings, unsigned int timeout) //------------------------------------------------------------------------------------------------------------------------- // 1) Waits for the waveform to be close to 'zero' (mid-scale adc) part in sin curve. //------------------------------------------------------------------------------------------------------------------------- - boolean st=false; //an indicator to exit the while loop - unsigned long start = millis(); //millis()-start makes sure it doesnt get stuck in the loop if there is an error. - while(st==false) //the while loop... + while(1) //the while loop... { startV = analogRead(inPinV); //using the voltage waveform - if ((startV < (ADC_COUNTS*0.55)) && (startV > (ADC_COUNTS*0.45))) st=true; //check its within range - if ((millis()-start)>timeout) st = true; + if ((startV < (ADC_COUNTS*0.55)) && (startV > (ADC_COUNTS*0.45))) break; //check its within range + if ((millis()-start)>timeout) break; } //-------------------------------------------------------------------------------------------------------------------------