0

Feather GPS code from a Function outside loop
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather GPS code from a Function outside loop

by josephmartin on Fri Jun 14, 2019 12:13 am

I am trying to create a function to run the Feather GPS parsing code so that I can just call the function from the loop function. I just moved the code in the loop to a function
void GPSfunc()
{
//Copied code
}

and called this from the loop function. The first time I upload the code to the feather it works. When I add a simple Serial.println and upload instead of displaying the output of the GPS as it normally does it gives me the following:
Before Calling GPSFunc
G
Time: 23:0:0.0
Date: 0/0/200
Fix: 0 quality: 0
Before Calling GPSFunc
T
Time: 23:0:0.0
Date: 0/0/200
Fix: 0 quality: 0

The "Before Calling GPSFunc" is the println.

If I just move the code back to the loop and then move the println into the GPSFunc it works normally and prints the line. Is there some reason the GPS code is not working in a function outside the loop function?

Thanks

josephmartin
 
Posts: 1
Joined: Fri Jun 14, 2019 12:10 am

Re: Feather GPS code from a Function outside loop

by franklin97355 on Fri Jun 14, 2019 2:10 am

It would help if you would post your code for us to see. Please use code tags when posting code or logs to the forums. It preserves formatting and makes it easier for everyone to read the code. Click the code button above the reply box and past your code between the tags created.

franklin97355
 
Posts: 20636
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Feather GPS code from a Function outside loop

by XRAD on Fri Jun 14, 2019 9:35 am

As Franklin says, posting code will help out greatly.

Where is the function() you are calling? before the loop or after the loop()? Sometimes compile logic requires the function() to be before the setup() and loop()......

XRAD
 
Posts: 397
Joined: Sat Nov 19, 2016 3:28 pm

Please be positive and constructive with your questions and comments.