I currently have some code which returns GPS co-ordinates in GNSS NEMA format which i have found a function to convert this. The issue i have is my understanding of C is limited and i don’t know how to call this and looking for advice.
I have the following variables correctly populating;
Gga gga = Gga(_gps);
if (gga.parse()) {
utcTime = gga.utcTime;
longitude = gga.longitude;
latitude = gga.latitude;
}
Rmc rmc = Rmc(_gps);
if (rmc.parse()) {
utcTime = rmc.utcTime;
longitude = rmc.longitude;
latitude = rmc.latitude;
}
What i want to do is modify the longitude and latitude values using the following function but i am not sure how i modify my code above to actually call this?
Any help or guidance would be much appreciated
float conv_coords(float in_coords) {
//Initialize the location.
float f = in_coords;
// Get the first two digits by turning f into an integer, then doing an integer divide by 100;
// firsttowdigits should be 77 at this point.
int firsttwodigits = ((int)f)/100; //This assumes that f < 10000.
float nexttwodigits = f - (float)(firsttwodigits*100);
float theFinalAnswer = (float)(firsttwodigits + nexttwodigits/60.0);
return theFinalAnswer;
}