mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
Core: extend last gas mix instead of defaulting to air.
Instead of defaulting to air when we run out of gas mixes to assign to cylinders, use the last gas mix provided by the dive computer. If no gas mixes are provided at all, then default to air. This prevents Subsurface from "inventing" gas mixes which are not reported by the dive computer. It also works very nicely with a sidemount configuration where the dive computer typically reports two cylinders but only a single gas mix. Signed-off-by: Micha WERLE <micha@michaelwerle.com>
This commit is contained in:
parent
5c2e4c395b
commit
c7171179b3
1 changed files with 8 additions and 5 deletions
|
@ -113,14 +113,16 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||||
report_error("Warning: different number of gases (%d) and cylinders (%d)", ngases, ntanks);
|
report_error("Warning: different number of gases (%d) and cylinders (%d)", ngases, ntanks);
|
||||||
} else if (ntanks > ngases) {
|
} else if (ntanks > ngases) {
|
||||||
shown_warning = true;
|
shown_warning = true;
|
||||||
report_error("Warning: smaller number of gases (%d) than cylinders (%d). Assuming air.", ngases, ntanks);
|
report_error("Warning: smaller number of gases (%d) than cylinders (%d).", ngases, ntanks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool no_volume = true;
|
bool no_volume = true;
|
||||||
|
cylinder_t cyl = empty_cylinder;
|
||||||
|
struct gasmix last_mix = gasmix_air; /* default to air */
|
||||||
|
|
||||||
clear_cylinder_table(&dive->cylinders);
|
clear_cylinder_table(&dive->cylinders);
|
||||||
for (i = 0; i < ngases || i < ntanks; i++) {
|
for (i = 0; i < MAX(ngases, ntanks); i++) {
|
||||||
cylinder_t cyl = empty_cylinder;
|
cyl = empty_cylinder;
|
||||||
if (i < ngases) {
|
if (i < ngases) {
|
||||||
dc_gasmix_t gasmix = { 0 };
|
dc_gasmix_t gasmix = { 0 };
|
||||||
int o2, he;
|
int o2, he;
|
||||||
|
@ -147,9 +149,10 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
|
||||||
}
|
}
|
||||||
he = 0;
|
he = 0;
|
||||||
}
|
}
|
||||||
cyl.gasmix.o2.permille = o2;
|
last_mix.o2.permille = o2;
|
||||||
cyl.gasmix.he.permille = he;
|
last_mix.he.permille = he;
|
||||||
}
|
}
|
||||||
|
cyl.gasmix = last_mix;
|
||||||
|
|
||||||
if (rc == DC_STATUS_UNSUPPORTED)
|
if (rc == DC_STATUS_UNSUPPORTED)
|
||||||
// Gasmix is inactive
|
// Gasmix is inactive
|
||||||
|
|
Loading…
Reference in a new issue