great! it works.. happy++
The explanation:
There is the variable named inSetup.
Somewhere (outside any function) in the top of the sketch that variable is declared and at the same time initialized (given a value).
bool inSetup = true;
In the rest of the sketch, that variable's value is never changed: The value of inSetup is always the same, all the time. It's value simply remains the same.
In every Arduino-sketch you're obligated to define two special functions, namely: setup() and loop(). If you don't have them in your sketch, the sketch would not compile.
The setup() function is executed only once. It is called at the beginning of any Arduino sketch. It's used to do things that only need to be done one time, like setting pins to input or output, or perhaps even displaying a startup text on a connected display.
The loop() function holds the code that is executed repeatedly. All of it's code is run, and when all that code is done executing (and the loop-code is finished), the Arduino just starts all that loop-code anew. Normally, it keeps on doing that until the power goes off.
In your sketch's loop() function, there is a call to: goGetValveTimes();.
Code in the loop() is executed over and over again. That means, that also goGetValveTimes() is executed over and over again.
Now suppose your LCD is full of text, already been displayed in other parts of the code.
Every loop() cycle will make a call to goGetValveTimes().
In that function named goGetValveTimes() is that block of code that is executed:
if (inSetup) {
lcd.print(F(" Updating "));
lcd.setCursor(0, 1);
lcd.print(F(" Valve Data: "));
lcd.print(valveIndex);
}
Code inside that block is always executed. It sets the cursor, and prints the valve data line.
It is always executed because the variable inSetup is always true.
Therefore no matter what was on your LCD, in every loop() cycle, that line on the display is overwritten with the valve data.. just as it is instructed to do.
Another way to fix the problem, while keeping that block of code (displaying the valve data), is to set the value of variable inSetup to false at the right moment.
That way the code block is not executed anymore, and will no longer keep overwriting your text already on the display.
Probably the best moment to do that, is at the end of the setup() function. like so:
void setup()
{
// at the end of your setup() function it would then look like this:
goGetValveTimes();
}
lcd.clear();
inSetup = false;
}
I believe that explains what was going on in your sketch..