Thank you Paul for explaining essential stuff to a noob.
It doesn't. It simply suspends reading data while if calls displayInfo().
This point i dont understand.
I got this code from the TinyGPS++ website.
I found it a little "ugly" to put the while loop in the main loop.
So i made a function.
The thing is that i dont call any function within the "while" or "if" loop.
Im sure there is a logical explaination why it still exits.
But i see the difference between the code on the TinyGPS++ website
and mine.
He put the gps.encode() loop in the main loop and calls a function which suspends the while loop
but i made a function instead with the gps.encode() loop inside which didnt have a break;
(Im just puzzled why it still leaves the loop).
However, even if i use the break; now it doesent seem to work.
After several loops my debugging shows that the Serial1.available() goes down to -1.
I was reading trough some comments on the TinyGPS++ website and i found this code:
static char GpsSentence[100];
static int GpsOffset = 0;
while (Serial1.available())
{
char c = Serial1.read();
if (c == '\n') // newline?
{
GpsSentence[GpsOffset] = 0;
GpsOffset = 0;
Serial.print("Got a new sentence: ");
Serial.println(GpsSentence);
}
else
{
GpsSentence[GpsOffset] = c;
GpsOffset++;
gps.encode(c);
}
}
With this it seems to work. (Until i unplug my USB and plug my 9 Volt wall power supply)
But i guess this is another story.... ![]()