mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:33:24 +00:00
libdc integration: correctly parse DC_FIELD_SALINITY response
libdivecomputer tries to be super careful in what it tells us. It only offers a density value if that is something that the dive computer explicitly supports, otherwise it just offers back a flag. We need to then update the density value ourselves. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ecfbf2a9ba
commit
795cf1bee2
2 changed files with 15 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
- core: correctly parse DC_FIELD_SALINITY response; fixes incorrect water type with some dive computers, including the Mares Smart
|
||||
- Desktop: Allow more than one media file to be imported from web
|
||||
- undo: Clear undo stack when the current file is closed
|
||||
---
|
||||
|
|
|
@ -677,8 +677,21 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
|||
download_error(translate("gettextFromC", "Error obtaining water salinity"));
|
||||
return rc;
|
||||
}
|
||||
if (rc == DC_STATUS_SUCCESS)
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
dive->dc.salinity = lrint(salinity.density * 10.0);
|
||||
if (dive->dc.salinity == 0) {
|
||||
// sometimes libdivecomputer gives us density values, sometimes just
|
||||
// a water type and a density of zero; let's make this work as best as we can
|
||||
switch (salinity.type) {
|
||||
case DC_WATER_FRESH:
|
||||
dive->dc.salinity = FRESHWATER_SALINITY;
|
||||
break;
|
||||
default:
|
||||
dive->dc.salinity = SEAWATER_SALINITY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double surface_pressure = 0;
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_ATMOSPHERIC, 0, &surface_pressure);
|
||||
|
|
Loading…
Add table
Reference in a new issue