summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Patrick Valsecchi <patrick@thus.ch>2013-10-04 07:57:48 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-04 09:16:39 -0700
commitc28fe00bfe7b0ed747050afc97812a56ccc8a291 (patch)
treedecfc381de4823d5744b8b978c29c732e0ea2c75 /dive.c
parent6ae6c768f30d2d377292f0ea3ff050dfd7cb52ca (diff)
downloadsubsurface-c28fe00bfe7b0ed747050afc97812a56ccc8a291.tar.gz
Added configuration options for vertical speed units.
Some people (free divers) are loving ft/s or m/s units for vertical speeds. Now they can choose between /min or /s in the configuration (only Qt UI). Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index 66d282d10..1d8986ab9 100644
--- a/dive.c
+++ b/dive.c
@@ -127,6 +127,30 @@ double get_depth_units(unsigned int mm, int *frac, const char **units)
return d;
}
+double get_vertical_speed_units(unsigned int mms, int *frac, const char **units)
+{
+ double d;
+ const char *unit;
+ const struct units *units_p = get_units();
+ const double time_factor = units_p->vertical_speed_time == MINUTES ? 60.0 : 1.0;
+
+ switch (units_p->length) {
+ case METERS:
+ d = mms / 1000.0 * time_factor;
+ unit = _((units_p->vertical_speed_time == MINUTES) ? "m/min" : "m/s");
+ break;
+ case FEET:
+ d = mm_to_feet(mms) * time_factor;
+ unit = _((units_p->vertical_speed_time == MINUTES) ? "ft/min" : "ft/s");
+ break;
+ }
+ if (frac)
+ *frac = d < 10;
+ if (units)
+ *units = unit;
+ return d;
+}
+
double get_weight_units(unsigned int grams, int *frac, const char **units)
{
int decimals;