- Why are there no {} in "while" and "if" ? Is this kind of sloppy shortcut programming?
In my mind, yes. The {} are only required when there is more than one statement in the block. But, I always use them for for and while statements, and almost always use them for if statements.
- Why is my "gps.encode(Serial1.read());" also exiting the "while" loop? Because it gets smaller than zero?
It doesn't. It simply suspends reading data while if calls displayInfo().
- Even if i use " if (gps.encode(Serial1.read()))" in the while loop my code doesn't work as it should.
Because you are not using it correctly.
if(gps.encode(Serial1.read())); // If TRUE exit the while loop
Why do you assume that? What you do if the statement is true is ;. What you do if the statement is false is nothing. ; and nothing amount to the same thing.
if(gps.encode(Serial1.read()))
break; // If TRUE exit the while loop
Now, it will exit the while loop.