Skip to content

Commit

Permalink
Merge pull request openenergymonitor#47 from xkr47/patch-2
Browse files Browse the repository at this point in the history
Remove unnecessary variable
  • Loading branch information
glynhudson authored Dec 2, 2018
2 parents bd0c6ac + 387d598 commit 524c76a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions EmonLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

//-------------------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 524c76a

Please sign in to comment.