summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/profile.c b/profile.c
index 86f7537af..3f24966e8 100644
--- a/profile.c
+++ b/profile.c
@@ -1011,16 +1011,16 @@ static void set_sac_color(struct graphics_context *gc, int sac, int avg_sac)
}
/* calculate the current SAC in ml/min and convert to int */
-#define GET_LOCAL_SAC(_entry1, _entry2, _dive) (int) \
+#define GET_LOCAL_SAC(_entry1, _entry2, _dive, _dc) (int) \
((GET_PRESSURE((_entry1)) - GET_PRESSURE((_entry2))) * \
(_dive)->cylinder[(_entry1)->cylinderindex].type.size.mliter / \
(((_entry2)->sec - (_entry1)->sec) / 60.0) / \
- depth_to_mbar(((_entry1)->depth + (_entry2)->depth) / 2.0, (_dive)))
+ depth_to_mbar(((_entry1)->depth + (_entry2)->depth) / 2.0, (_dive), (_dc)))
#define SAC_WINDOW 45 /* sliding window in seconds for current SAC calculation */
static void plot_cylinder_pressure(struct graphics_context *gc, struct plot_info *pi,
- struct dive *dive)
+ struct dive *dive, struct divecomputer *dc)
{
int i;
int last = -1, last_index = -1;
@@ -1050,12 +1050,12 @@ static void plot_cylinder_pressure(struct graphics_context *gc, struct plot_info
if (!last_entry) {
last = i;
last_entry = entry;
- sac = GET_LOCAL_SAC(entry, pi->entry + i + 1, dive);
+ sac = GET_LOCAL_SAC(entry, pi->entry + i + 1, dive, dc);
} else {
int j;
sac = 0;
for (j = last; j < i; j++)
- sac += GET_LOCAL_SAC(pi->entry + j, pi->entry + j + 1, dive);
+ sac += GET_LOCAL_SAC(pi->entry + j, pi->entry + j + 1, dive, dc);
sac /= (i - last);
if (entry->sec - last_entry->sec >= SAC_WINDOW) {
last++;
@@ -1400,12 +1400,12 @@ static void fill_missing_segment_pressures(pr_track_t *list)
* scale pressures, so it ends up being a unitless scaling
* factor.
*/
-static inline int pressure_time(struct dive *dive, struct plot_data *a, struct plot_data *b)
+static inline int pressure_time(struct dive *dive, struct divecomputer *dc, struct plot_data *a, struct plot_data *b)
{
int time = b->sec - a->sec;
int depth = (a->depth + b->depth)/2;
- return depth_to_mbar(depth, dive) * time;
+ return depth_to_mbar(depth, dive, dc) * time;
}
static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, pr_track_t **track_pr)
@@ -1453,7 +1453,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
magic = (segment->end - segment->start) / (double) segment->pressure_time;
/* Use that overall pressure change to update the current pressure */
- cur_pt = pressure_time(dive, entry-1, entry);
+ cur_pt = pressure_time(dive, &dive->dc, entry-1, entry);
pressure = cur_pr[cyl] + cur_pt * magic + 0.5;
INTERPOLATED_PRESSURE(entry) = pressure;
cur_pr[cyl] = pressure;
@@ -1768,7 +1768,7 @@ static void populate_pressure_information(struct dive *dive, struct divecomputer
struct plot_data *entry = pi->entry + i;
/* discrete integration of pressure over time to get the SAC rate equivalent */
- current->pressure_time += pressure_time(dive, entry-1, entry);
+ current->pressure_time += pressure_time(dive, dc, entry-1, entry);
/* track the segments per cylinder and their pressure/time integral */
if (entry->cylinderindex != cylinderindex) {
@@ -1814,7 +1814,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d
{
int i;
double amb_pressure;
- double surface_pressure = (dive->dc.surface_pressure.mbar ? dive->dc.surface_pressure.mbar : SURFACE_PRESSURE) / 1000.0;
+ double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, TRUE)) / 1000.0;
for (i = 1; i < pi->nr; i++) {
int fo2, fhe, j, t0, t1;
@@ -1822,7 +1822,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d
struct plot_data *entry = pi->entry + i;
int cylinderindex = entry->cylinderindex;
- amb_pressure = depth_to_mbar(entry->depth, dive) / 1000.0;
+ amb_pressure = depth_to_mbar(entry->depth, dive, dc) / 1000.0;
fo2 = dive->cylinder[cylinderindex].gasmix.o2.permille ? : O2_IN_AIR;
fhe = dive->cylinder[cylinderindex].gasmix.he.permille;
double ratio = (double)fhe / (1000.0 - fo2);
@@ -1876,7 +1876,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d
tissue_tolerance = 0;
for (j = t0+1; j <= t1; j++) {
int depth = interpolate(entry[-1].depth, entry[0].depth, j - t0, t1 - t0);
- double min_pressure = add_segment(depth_to_mbar(depth, dive) / 1000.0,
+ double min_pressure = add_segment(depth_to_mbar(depth, dive, dc) / 1000.0,
&dive->cylinder[cylinderindex].gasmix, 1, entry->po2 * 1000, dive);
tissue_tolerance = min_pressure;
}
@@ -2039,7 +2039,7 @@ void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale)
plot_temperature_profile(gc, pi);
/* Cylinder pressure plot */
- plot_cylinder_pressure(gc, pi, dive);
+ plot_cylinder_pressure(gc, pi, dive, dc);
/* Text on top of all graphs.. */
plot_temperature_text(gc, pi);