diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-06 12:16:39 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-06 12:16:39 -0700 |
commit | c0a429457ab9fae5e6995777b869b111ef32be74 (patch) | |
tree | dd0d60a54bf038212fe059fa635248a38fabb549 /profile.c | |
parent | 3b67a3ecb4193972a87c5c25b29a4279121d4366 (diff) | |
download | subsurface-c0a429457ab9fae5e6995777b869b111ef32be74.tar.gz |
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>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -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) + + if (minmax) { + if (depth <= depthlimit) { + if (depthlimit - depth > enough) + break; continue; + } } else { - if (depth >= depthlimit) + 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; } |