mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Planner: Implement ascend rate according to GUE standard procedures
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
00e7ef2cf8
commit
c3a3c1a1e7
3 changed files with 38 additions and 5 deletions
20
dive.c
20
dive.c
|
@ -2218,3 +2218,23 @@ void set_userid(char *rUserId)
|
|||
strcpy(prefs.userid, rUserId);
|
||||
}
|
||||
#undef MAX_USERID_SIZE
|
||||
|
||||
int average_depth(struct diveplan *dive)
|
||||
{
|
||||
int integral = 0;
|
||||
int last_time = 0;
|
||||
int last_depth = 0;
|
||||
struct divedatapoint *dp = dive->dp;
|
||||
|
||||
while (dp) {
|
||||
if (dp->time) {
|
||||
/* Ignore gas indication samples */
|
||||
integral += (dp->depth + last_depth) * (dp->time - last_time) / 2;
|
||||
last_time = dp->time;
|
||||
last_depth = dp->depth;
|
||||
}
|
||||
dp = dp->next;
|
||||
}
|
||||
|
||||
return integral / last_time;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue