summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Alexandre Belloni <alexandre.belloni@piout.net>2013-11-30 09:13:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-30 07:18:01 -0800
commit197b8e0beeafdf389383bf21e3924a3ba4621c46 (patch)
tree1adfafbbb539200992d3a7f614ce62d8fd6a5160 /profile.c
parent1ea1c242922f5e8ee42cb7d20127ce4c1f95f366 (diff)
downloadsubsurface-197b8e0beeafdf389383bf21e3924a3ba4621c46.tar.gz
Ruler: display maximum descent and ascent speed
While playing with the ruler, I figured that it happened only once that my minimum speed was not 0 for a segment long enough to get any display. And it was a "dive" in an hyperbaric chamber... This patch replaces the minimum speed with the maximum descent speed and the maximum speed with the maximum ascent speed. Signed-off-by: Alexandre Belloni <alexandre.belloni@piout.net> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/profile.c b/profile.c
index defeb94fd..3493b996d 100644
--- a/profile.c
+++ b/profile.c
@@ -1334,7 +1334,7 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
struct plot_data *start, *stop, *data;
const char *depth_unit, *pressure_unit, *vertical_speed_unit;
char *buf2 = malloc(bufsize);
- int avg_speed, max_speed, min_speed;
+ int avg_speed, max_asc_speed, max_desc_speed;
int delta_depth, avg_depth, max_depth, min_depth;
int bar_used, last_pressure, pressurevalue;
int count, last_sec, delta_time;
@@ -1357,8 +1357,8 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
}
count = 0;
avg_speed = 0;
- max_speed = 0;
- min_speed = INT_MAX;
+ max_asc_speed = 0;
+ max_desc_speed = 0;
delta_depth = abs(start->depth-stop->depth);
delta_time = abs(start->sec-stop->sec);
@@ -1379,10 +1379,10 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
avg_speed += data->speed*(data->sec-last_sec);
avg_depth += data->depth*(data->sec-last_sec);
- if (abs(data->speed) < min_speed)
- min_speed = abs(data->speed);
- if (abs(data->speed) > max_speed)
- max_speed = abs(data->speed);
+ if (data->speed > max_desc_speed)
+ max_desc_speed = data->speed;
+ if (data->speed < max_asc_speed)
+ max_asc_speed = data->speed;
if (data->depth < min_depth)
min_depth = data->depth;
@@ -1421,11 +1421,11 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
snprintf(buf, bufsize, translate("gettextFromC","%s %sD:%.1f%s\n"), buf2, UTF8_AVERAGE, depthvalue, depth_unit);
memcpy(buf2, buf, bufsize);
- speedvalue = get_vertical_speed_units(abs(min_speed), NULL, &vertical_speed_unit);
+ speedvalue = get_vertical_speed_units(abs(max_desc_speed), NULL, &vertical_speed_unit);
snprintf(buf, bufsize, translate("gettextFromC","%s%sV:%.2f%s"), buf2, UTF8_DOWNWARDS_ARROW, speedvalue, vertical_speed_unit);
memcpy(buf2, buf, bufsize);
- speedvalue = get_vertical_speed_units(abs(max_speed), NULL, &vertical_speed_unit);
+ speedvalue = get_vertical_speed_units(abs(max_asc_speed), NULL, &vertical_speed_unit);
snprintf(buf, bufsize, translate("gettextFromC","%s %sV:%.2f%s"), buf2, UTF8_UPWARDS_ARROW, speedvalue, vertical_speed_unit);
memcpy(buf2, buf, bufsize);