This really isn't a bug problem. I just want to understand something about TinyGPS.
I have a GPS receiver connected to a hardware serial port on my T4.0.
This is a snippet of the code:
Everything is working as it should. I get the right numbers on the LCD display. And it updates every second.
Now, my question is about the first line and the "while (Serial2.available())". The GPS is sending a burst of data once a second. This takes only a small fraction of the second, and nothing else happens until the next burst.
I assume that the "while" statement falls through when there is no data on the serial port. Or am I wrong on this? If I move the lines of code shown in bold outside the "while", then the display is not updated every second.
At this point in the sketch all I need is the date and time. Previous to this is another "while" where I collect and average the latitude and longitude (variables flat and flong) (that would probably be best in the setup function) so I know that the "while" eventually drops through.
I want to be able to do other things during the time that the GPS is quiet, so why does it not update the display every second as the "while" drops through? This makes me wonder if things would get done properly if they are outside the "while".
Is there another GPS driver that would work better?
[Edit] I jut noticed that the display is NOT updating every second like I thought, but every so often it skips a second or two.
I have a GPS receiver connected to a hardware serial port on my T4.0.
This is a snippet of the code:
while (Serial2.available())
{
c = Serial2.read();
if(gps.encode(c))
{
gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths,&fix_age);
UTChours = hour+minute*1.66666666666666666666e-2+second*2.77777777777777777777e-4
+hundredths*2.77777777777777777777e-6; //UTC hour
getLST(UTChours,day, month, year, flong, LST);
getRaDec( LST, flat, RightAscension, Declination);
setDisplay(mode,UTChours,LST,RightAscension,Declination);
}
}
Everything is working as it should. I get the right numbers on the LCD display. And it updates every second.
Now, my question is about the first line and the "while (Serial2.available())". The GPS is sending a burst of data once a second. This takes only a small fraction of the second, and nothing else happens until the next burst.
I assume that the "while" statement falls through when there is no data on the serial port. Or am I wrong on this? If I move the lines of code shown in bold outside the "while", then the display is not updated every second.
At this point in the sketch all I need is the date and time. Previous to this is another "while" where I collect and average the latitude and longitude (variables flat and flong) (that would probably be best in the setup function) so I know that the "while" eventually drops through.
I want to be able to do other things during the time that the GPS is quiet, so why does it not update the display every second as the "while" drops through? This makes me wonder if things would get done properly if they are outside the "while".
Is there another GPS driver that would work better?
[Edit] I jut noticed that the display is NOT updating every second like I thought, but every so often it skips a second or two.
Last edited: