TinyGPS++ custom field - error when try to round to integer value.

Hello.

I have wind sensor connected to my Arduino and i use TinyGPS++ library

I use custom fields to get a date

TinyGPSPlus gps;

TinyGPSCustom WindDirection(gps, "WIMWV", 1); 
TinyGPSCustom WindSpeed(gps, "WIMWV", 3); 
TinyGPSCustom Temperature(gps, "YXXDR", 2);

If i want to print it - i use code:

  Serial.print(F("Wind direction = ")); Serial.print(WindDirection.value()); 
  Serial.print(F(" Wind speed (knots), = ")); Serial.print(WindSpeed.value());

Printing ok, with decimal point.

But if i try this

// variable declaration 
int Wind_SPD=0;  
int Wind_DIR=0; 

--------------------------

IN MAIN LOOP
-------------------------  

if (WindDirection.isUpdated())
        {
         MyStatus=100;
         Wind_SPD=round(WindSpeed.value);  
         Wind_DIR=round(WindDirection.value);         
        }

[code]

I have a error:
[i]wind_1_0.ino: In function 'void loop()':
wind_1_0:104: error: invalid use of member (did you forget the '&' ?)
wind_1_0:104: error: invalid use of member (did you forget the '&' ?)
wind_1_0:104: error: invalid use of member (did you forget the '&' ?)
wind_1_0:105: error: invalid use of member (did you forget the '&' ?)
wind_1_0:105: error: invalid use of member (did you forget the '&' ?)
wind_1_0:105: error: invalid use of member (did you forget the '&' ?)[/i]


If i try this:

[code]
if (WindDirection.isUpdated())
        {
         MyStatus=100;
         Wind_SPD=int(WindSpeed.value);  
         Wind_DIR=int(WindDirection.value);         
        }

i have a error:
wind_1_0:105: error: invalid use of member (did you forget the '&' ?)

And if i try this

if (WindDirection.isUpdated())
        {
         MyStatus=100;
         Wind_SPD=round(WindSpeed);  
         Wind_DIR=round(WindDirection);         
        }

i have a error
wind_1_0.ino: In function 'void loop()':
wind_1_0:104: error: no match for 'operator>=' in 'WindSpeed >= 0'
wind_1_0:104: error: no match for 'operator+' in 'WindSpeed + 5.0e-1'
wind_1_0:104: error: no match for 'operator-' in 'WindSpeed - 5.0e-1'
wind_1_0:105: error: no match for 'operator>=' in 'WindDirection >= 0'
wind_1_0:105: error: no match for 'operator+' in 'WindDirection + 5.0e-1'
wind_1_0:105: error: no match for 'operator-' in 'WindDirection - 5.0e-1'

So...
How i can get a integer value from custom field returned by TINy GPS ++

Thanks.

Sorry my bad english[/code][/code]

Wind_SPD=round(WindSpeed.value);  
         Wind_DIR=round(WindDirection.value);

"value" appears to be a function.
To get the value of a function, you have to call it.

Wind_SPD=round(WindSpeed.value());  
         Wind_DIR=round(WindDirection.value());

Not working :frowning:

I use code:

    Wind_SPD=round(WindSpeed.value());  
    Wind_DIR=round(WindDirection.value());

And now error is

wind_1_0.ino: In function 'void loop()':
wind_1_0:106: error: invalid operands of types 'const char*' and 'double' to binary 'operator+'
wind_1_0:106: error: invalid operands of types 'const char*' and 'double' to binary 'operator-'
wind_1_0:107: error: invalid operands of types 'const char*' and 'double' to binary 'operator+'
wind_1_0:107: error: invalid operands of types 'const char*' and 'double' to binary 'operator-'

Hi there!

Try to do this through variables (not sure about data type):

ws = WindSpeed.value();
wd = WindDirection.value();

Wind_SPD=round( ws);  
Wind_DIR=round( wd);

It could be that it's impossible to use .value function inside other function directly.

wind_1_0:106: error: invalid operands of types 'const char*' and 'double' to binary 'operator+'

Pretty massive clue.

Thanks all

Work with this:

    Wind_SPD=atoi(WindSpeed.value());  
    Wind_DIR=atoi(WindDirection.value());

That's rounding down, always.