mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Tweak the "show depth in text" heuristic a bit
Use a 10-minute window *or* when the depth has reversed sufficiently to make the max we've found interesting. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
3b67a3ecb4
commit
c0a429457a
1 changed files with 21 additions and 7 deletions
32
profile.c
32
profile.c
|
@ -52,9 +52,15 @@ static void plot_text(cairo_t *cr, double x, double y, const char *fmt, ...)
|
|||
cairo_show_text(cr, buffer);
|
||||
}
|
||||
|
||||
/* Find the next maximum point in a 5-minute window */
|
||||
static int next_minmax(struct dive *dive, int index, int max)
|
||||
/*
|
||||
* Find the next maximum point in a 10-minute window.
|
||||
*
|
||||
* We exit early if we hit "enough" of a depth reversal,
|
||||
* which is roughly 10 feet.
|
||||
*/
|
||||
static int next_minmax(struct dive *dive, int index, int minmax)
|
||||
{
|
||||
const int enough = 3000;
|
||||
int timelimit, depthlimit, result;
|
||||
struct sample *sample = dive->sample + index;
|
||||
|
||||
|
@ -76,17 +82,25 @@ static int next_minmax(struct dive *dive, int index, int max)
|
|||
depth = sample->depth.mm;
|
||||
if (time > timelimit)
|
||||
break;
|
||||
if (max) {
|
||||
if (depth <= depthlimit)
|
||||
continue;
|
||||
} else {
|
||||
if (depth >= depthlimit)
|
||||
|
||||
if (minmax) {
|
||||
if (depth <= depthlimit) {
|
||||
if (depthlimit - depth > enough)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (depth >= depthlimit) {
|
||||
if (depth - depthlimit > enough)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
depthlimit = depth;
|
||||
timelimit = time + 300;
|
||||
result = index;
|
||||
depthlimit = depth;
|
||||
/* Look up to ten minutes into the future */
|
||||
timelimit = time + 600;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue