I2C-LCD display causes incorrect results on interrupt driven inputs

@Koepel Thanks for catching that line. It was for debug, The display would have shown INF for values on the display then entered an infinite loop. That came out in the complete rewrite.

Now what I do is:

o ISR increments a counter (yes, important to be volatile!)
o set the count to 0
o wait for count to be non-zero
o note time start
o again set the count to zero
o wait the sample period
o capture the count as it will change over the next 47mSecs
o calculate the frequency
o calculate the liters per minute
o update the averaging variables.
o display the output.

What is amazing is that the time in the loop not waiting for the sample period goes from 1mSec for output to the terminal to 47mSec for the 32 characters sent to the display. This is not a particularly efficient library.

Since I could measure the not-in-sample-time time I could compensate the average frequency and total pulse count.

The results are satisfying, though not perfect.

The next steps are:
o finish the Processin.org code half written to capture the output to a file.
o build the sensor test setup. (bucket to bucket: plumbing, electrical, etc.)
o test the sensor.

Any ideas why these four lines of code take 46mSec? @Koepel

  lcd.setCursor(0,0);
  lcd.print(outline);
  lcd.setCursor(0,1);
  lcd.print(outline2);

OSD
FrequencyOfPulses005.ino (4.6 KB)