Hi,
I am working on NEO6MV2 GPS module where I want to store coordinated in float variables. I am using TinyGPS library.
In order to do that, first I want to add extra decimal places in float value. This can be achieved by
Serial.print(12.224, 5) (Serial.print() - Arduino Reference)
However as I said I want to store this result in variable, how can I do that ?
I cannot make
return Serial.print(12.224, 5);
This is the original function:
float print_float(float val, float invalid, int len, int prec)
{
if (val == invalid)
{
while (len-- > 1)
Serial.print('*');
Serial.print(' ');
}
else
{
Serial.print(val, prec);
int vi = abs((int)val);
int flen = prec + (val < 0.0 ? 2 : 1); // . and -
flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
for (int i=flen; i<len; ++i)
Serial.print(' ');
}
smartdelay(0);
}
Instead of directly printing the data on serial monitor, how can I store its output in a variable ?
Need help,
Thanks