Skip to content

Commit

Permalink
Moved query for external wind to OnSensorUpdate and used Haeding from…
Browse files Browse the repository at this point in the history
… Larus

The previously used track is not available on the ground, giving the impression that the wind arrows are not responding. Furthermore, Larus' heading is certainly much more accurate.

I moved the if statement to OnSensorUpdate because high wind accuracy is desired. This is not guaranteed with OnCalculatedUpdate.

including relative wind vector

Including relative wind vector from external device like Larus, Anemoi, etc. If external wind is not available calculated wind from XCSoar/OpenSoar is displayed.

conversion of basic.track.Degrees() to integer removed

- conversion of basic.track.Degrees() to integer removed
- checked for the calculated wind, whether the external wind is definitely invalid
  • Loading branch information
Blaubart committed Apr 5, 2024
1 parent 2e08510 commit 0d2b33c
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions src/Device/Driver/FreeVario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,38 @@ FreeVarioDevice::ParseNMEA(const char *_line, NMEAInfo &info)
}

/*
* Send total_energy_vario to FreeVario device on every sensor update.
* Is needed to have a good refresh rate on the external device showing the
* vario values
* Send total_energy_vario, external wind direction and external wind speed to
* FreeVario device on every sensor update. Is needed to have a good refresh
* rate on the external device showing the vario and external wind values.
*/
void
FreeVarioDevice::OnSensorUpdate(const MoreData &basic)
{
NullOperationEnvironment env;
char nmeaOutbuffer[80];

if (basic.total_energy_vario_available.IsValid()) {
sprintf(nmeaOutbuffer,"PFV,VAR,%f", basic.total_energy_vario);
PortWriteNMEA(port, nmeaOutbuffer, env);
}
if (basic.total_energy_vario_available.IsValid()) {
sprintf(nmeaOutbuffer,"PFV,VAR,%f", basic.total_energy_vario);
PortWriteNMEA(port, nmeaOutbuffer, env);
}

if (basic.external_wind_available.IsValid() && basic.attitude.heading_available){
double relWindDirection = basic.external_wind.bearing.Degrees() - basic.attitude.heading.Degrees() + 180;
double norm = basic.external_wind.norm;
sprintf(nmeaOutbuffer,"PFV,AWD,%f", relWindDirection);
PortWriteNMEA(port, nmeaOutbuffer, env);
sprintf(nmeaOutbuffer,"PFV,AWS,%f", norm);
PortWriteNMEA(port, nmeaOutbuffer, env);
}

if (basic.external_instantaneous_wind_available.IsValid() && basic.attitude.heading_available){
double relWindDirection = basic.external_instantaneous_wind.bearing.Degrees() - basic.attitude.heading.Degrees() + 180;
double norm = basic.external_instantaneous_wind.norm;
sprintf(nmeaOutbuffer,"PFV,CWD,%f", relWindDirection);
PortWriteNMEA(port, nmeaOutbuffer, env);
sprintf(nmeaOutbuffer,"PFV,CWS,%f", norm);
PortWriteNMEA(port, nmeaOutbuffer, env);
}

// TODO(August2111): basic.netto_variable has no timestamp unfortunately?
// if (basic.netto_vario_available.IsValid()) {
Expand All @@ -268,7 +286,6 @@ FreeVarioDevice::OnSensorUpdate(const MoreData &basic)
// }
}


/*
* Always send the calculated updated values to the FreeVario to have a good
* refresh rate on the external device
Expand All @@ -280,7 +297,15 @@ FreeVarioDevice::OnCalculatedUpdate(const MoreData &basic,
NullOperationEnvironment env;

char nmeaOutbuffer[80];

if (!basic.external_instantaneous_wind_available.IsValid() && calculated.wind.IsNonZero() && basic.track_available){
double relWindDirection = calculated.wind.bearing.Degrees() - basic.track.Degrees() + 180;
double norm = calculated.wind.norm;
sprintf(nmeaOutbuffer,"PFV,AWD,%f", relWindDirection);
PortWriteNMEA(port, nmeaOutbuffer, env);
sprintf(nmeaOutbuffer,"PFV,AWS,%f", norm);
PortWriteNMEA(port, nmeaOutbuffer, env);
}

if (basic.baro_altitude_available.IsValid()){
sprintf(nmeaOutbuffer,"PFV,HIG,%f", basic.baro_altitude);
PortWriteNMEA(port, nmeaOutbuffer, env);
Expand Down

0 comments on commit 0d2b33c

Please sign in to comment.