From fa181d1ded081651f000e10b05e0ea9ddce75ea1 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 17 Nov 2014 07:23:20 +0000 Subject: [PATCH] More CCR code cleanup Random constants are bad. Let's use the indices that we already calculated (and true and false if we mean boolean values). Signed-off-by: Dirk Hohndel --- gaspressures.c | 9 +++++---- profile.c | 12 ++++++------ profile.h | 3 --- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gaspressures.c b/gaspressures.c index fbb52a130..d8ad203f9 100644 --- a/gaspressures.c +++ b/gaspressures.c @@ -264,8 +264,9 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, entry = pi->entry + i; - if (diluent_flag) { // Find the cylinder index (cyl) .. - cyl = DILUENT_CYLINDER; // .. as well as the cylinder pressure + if (diluent_flag) { + // Find the cylinder index (cyl) and pressure + cyl = dive->diluent_cylinder_index; pressure = DILUENT_PRESSURE(entry); save_pressure = &(entry->diluentpressure[SENSOR_PR]); save_interpolated = &(entry->diluentpressure[INTERPOLATED_PR]); @@ -362,7 +363,7 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s unsigned pressure; if (diluent_flag) { // if this is a diluent cylinder: pressure = DILUENT_PRESSURE(entry); - cylinderid = DILUENT_CYLINDER; + cylinderid = dive->diluent_cylinder_index; } else { pressure = SENSOR_PRESSURE(entry); cylinderid = entry->cylinderindex; @@ -379,7 +380,7 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s /* track the segments per cylinder and their pressure/time integral */ if (cylinderid != cylinderindex) { if (diluent_flag) // For CCR dives: - cylinderindex = DILUENT_CYLINDER; // indicate diluent cylinder + cylinderindex = dive->diluent_cylinder_index; // indicate diluent cylinder else cylinderindex = entry->cylinderindex; current = pr_track_alloc(pressure, entry->sec); diff --git a/profile.c b/profile.c index 82d4b653d..ff6de402e 100644 --- a/profile.c +++ b/profile.c @@ -1015,13 +1015,13 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo } last_pi_entry_new = populate_plot_entries(dive, dc, pi); - 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, NONDILUENT); /* .. calculate missing pressure entries for all gasses except diluent */ - if (dc->dctype == CCR) /* For CCR dives.. */ - populate_pressure_information(dive, dc, pi, DILUENT); /* .. calculate missing diluent gas pressure entries */ + 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 */ + if (dc->dctype == CCR) /* For CCR dives.. */ + populate_pressure_information(dive, dc, pi, true); /* .. calculate missing diluent gas pressure entries */ - fill_o2_values(dc, pi, dive); /* .. and insert the O2 sensor data having 0 values. */ + fill_o2_values(dc, pi, dive); /* .. and insert the O2 sensor data having 0 values. */ calculate_sac(dive, pi); /* Calculate sac */ calculate_deco_information(dive, dc, pi, false); /* and ceiling information, using gradient factor values in Preferences) */ calculate_gas_information_new(dive, pi); /* Calculate gas partial pressures */ diff --git a/profile.h b/profile.h index ab5853d9e..69de6d352 100644 --- a/profile.h +++ b/profile.h @@ -88,9 +88,6 @@ int get_maxtime(struct plot_info *pi); * partial pressure graphs */ int get_maxdepth(struct plot_info *pi); -#define DILUENT_CYLINDER 1 -#define DILUENT 1 -#define NONDILUENT 0 #define SENSOR_PR 0 #define INTERPOLATED_PR 1 #define SENSOR_PRESSURE(_entry) (_entry)->pressure[SENSOR_PR]