summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Henrik Brautaset Aronsen <subsurface@henrik.synth.no>2013-01-24 19:58:59 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-24 13:00:03 -0800
commite3088930ab58327fac744e4672906892560dc93e (patch)
treef58167085dab3419256b44a17c3d9beee5a3804d /dive.c
parentb8efe709a8e6c23a2bf3849a454565634b2a0545 (diff)
downloadsubsurface-e3088930ab58327fac744e4672906892560dc93e.tar.gz
Use actual min and max temperatures in statistics.
The statistics page only used each dive's "watertemp" attribute, regardless of actual higher/lower temperatures in the samples. By finding the actual max/min temperatures, the statistics page utilize more "real" data, and look better even on single dives. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index f6807f3e6..d66eec9a3 100644
--- a/dive.c
+++ b/dive.c
@@ -248,6 +248,17 @@ static void fixup_pressure(struct dive *dive, struct sample *sample)
cyl->sample_end.mbar = pressure;
}
+static void update_min_max_temperatures(struct dive *dive, struct sample *sample)
+{
+ if (sample->temperature.mkelvin) {
+ if (!dive->maxtemp.mkelvin || sample->temperature.mkelvin > dive->maxtemp.mkelvin)
+ dive->maxtemp = sample->temperature;
+ if (!dive->mintemp.mkelvin || sample->temperature.mkelvin < dive->mintemp.mkelvin)
+ dive->mintemp = sample->temperature;
+ }
+}
+
+
/*
* If the cylinder tank pressures are within half a bar
* (about 8 PSI) of the sample pressures, we consider it
@@ -479,6 +490,8 @@ struct dive *fixup_dive(struct dive *dive)
if (!mintemp || temp < mintemp)
mintemp = temp;
}
+ update_min_max_temperatures(dive, sample);
+
depthtime += (time - lasttime) * (lastdepth + depth) / 2;
lastdepth = depth;
lasttime = time;