diff options
author | Anton Lundin <glance@acc.umu.se> | 2013-11-20 00:29:32 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-19 15:46:19 -0800 |
commit | eb027f2a4b83ed8eb127f0c736021556aa3952a0 (patch) | |
tree | 47fa07043bb40899c621429b0dca5ea3d61c27dd /statistics.c | |
parent | 732f7a69b08e279c88f3ce7d946e986734d0e3f7 (diff) | |
download | subsurface-eb027f2a4b83ed8eb127f0c736021556aa3952a0.tar.gz |
Do per cylinder statistics
This shows how much gas form each cylinder was used. I would like to add
SAC to that list too but it became a mess trying to calculate average
depth per cylinder.
Design based on idea in #284
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r-- | statistics.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/statistics.c b/statistics.c index a151aee27..8284dda8f 100644 --- a/statistics.c +++ b/statistics.c @@ -268,7 +268,7 @@ void get_selected_dives_text(char *buffer, int size) } } -volume_t get_gas_used(struct dive *dive) +void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS]) { int idx; volume_t gas_used = { 0 }; @@ -279,9 +279,8 @@ volume_t get_gas_used(struct dive *dive) start = cyl->start.mbar ? cyl->start : cyl->sample_start; end = cyl->end.mbar ? cyl->end : cyl->sample_end; if (start.mbar && end.mbar) - gas_used.mliter += gas_volume(cyl, start) - gas_volume(cyl, end); + gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end); } - return gas_used; } bool is_gas_used(struct dive *dive, int idx) @@ -347,15 +346,19 @@ char *get_gaslist(struct dive *dive) cyl = &dive->cylinder[idx]; o2 = get_o2(&cyl->gasmix); he = get_he(&cyl->gasmix); + if (offset > 0) { + strncpy(buf + offset, "\n", MAXBUF - offset); + offset = strlen(buf); + } if (is_air(o2, he)) - snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %s" : "%s", translate("gettextFromC","air")); + strncpy(buf + offset, translate("gettextFromC","air"), MAXBUF - offset); else if (he == 0) - snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? translate("gettextFromC",", EAN%d") : translate("gettextFromC","EAN%d"), - (o2 + 5) / 10); + snprintf(buf + offset, MAXBUF - offset, + translate("gettextFromC","EAN%d"), (o2 + 5) / 10); else - snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %d/%d" : "%d/%d", - (o2 + 5) / 10, (he + 5) / 10); + snprintf(buf + offset, MAXBUF - offset, + "%d/%d", (o2 + 5) / 10, (he + 5) / 10); offset = strlen(buf); } if (*buf == '\0') |