diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-11-17 17:39:40 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-17 18:02:42 +0000 |
commit | d5d7fdc9af98756cd8b241502f6493c518d6fa0f (patch) | |
tree | d5d6695cbeea4ae2a311f57803c19a59c72442fc /profile.c | |
parent | 992e58eaf255973bcaeda1572c9bb86d16ed4adf (diff) | |
download | subsurface-d5d7fdc9af98756cd8b241502f6493c518d6fa0f.tar.gz |
For CCR dives, show plot for diluent and O2 cylinder pressures
Also fixes a bug in the diluent pressure interpolation
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -612,34 +612,40 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer * #undef INSERT_ENTRY -static void populate_cylinder_pressure_data(int idx, int start, int end, struct plot_info *pi) +static void populate_cylinder_pressure_data(int idx, int start, int end, struct plot_info *pi, bool o2flag) { int i; /* First: check that none of the entries has sensor pressure for this cylinder index */ for (i = 0; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; - if (entry->cylinderindex != idx) + if (entry->cylinderindex != idx && !o2flag) continue; - if (SENSOR_PRESSURE(entry)) + if (CYLINDER_PRESSURE(o2flag, entry)) return; } /* Then: populate the first entry with the beginning cylinder pressure */ for (i = 0; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; - if (entry->cylinderindex != idx) + if (entry->cylinderindex != idx && !o2flag) continue; - SENSOR_PRESSURE(entry) = start; + if (o2flag) + O2CYLINDER_PRESSURE(entry) = start; + else + SENSOR_PRESSURE(entry) = start; break; } /* .. and the last entry with the ending cylinder pressure */ for (i = pi->nr; --i >= 0; /* nothing */) { struct plot_data *entry = pi->entry + i; - if (entry->cylinderindex != idx) + if (entry->cylinderindex != idx && !o2flag) continue; - SENSOR_PRESSURE(entry) = end; + if (o2flag) + O2CYLINDER_PRESSURE(entry) = end; + else + SENSOR_PRESSURE(entry) = end; break; } } @@ -688,7 +694,7 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc if (!start || !end) continue; - populate_cylinder_pressure_data(i, start, end, pi); + populate_cylinder_pressure_data(i, start, end, pi, dive->cylinder[i].cylinder_use == OXYGEN); } /* @@ -1013,9 +1019,9 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo check_gas_change_events(dive, dc, pi); /* Populate the gas index from the gas change events */ setup_gas_sensor_pressure(dive, dc, pi); /* Try to populate our gas pressure knowledge */ - populate_pressure_information(dive, dc, pi, false); /* .. calculate missing pressure entries for all gasses except diluent */ + populate_pressure_information(dive, dc, pi, false); /* .. calculate missing pressure entries for all gasses except o2 */ if (dc->dctype == CCR) /* For CCR dives.. */ - populate_pressure_information(dive, dc, pi, true); /* .. calculate missing diluent gas pressure entries */ + populate_pressure_information(dive, dc, pi, true); /* .. calculate missing o2 gas pressure entries */ fill_o2_values(dc, pi, dive); /* .. and insert the O2 sensor data having 0 values. */ calculate_sac(dive, pi); /* Calculate sac */ |