cyl->sample_end.mbar = 0;
}
}
- if (end < 0)
+ if (end < 0) {
+ /* Assume an ascent/descent rate of 9 m/min */
+ int depth = dive->maxdepth.mm;
+ int asc_desc_time = depth*60/9000;
+ int duration = dive->duration.seconds;
+
+ /* Protect against insane dives - make mean be half of max */
+ if (duration <= asc_desc_time) {
+ duration = 2;
+ asc_desc_time = 1;
+ }
+ dive->meandepth.mm = depth*(duration-asc_desc_time)/duration;
return dive;
+ }
update_duration(&dive->duration, end - start);
if (start != end)