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>
This commit is contained in:
Patrick Valsecchi 2013-10-04 07:57:48 +02:00 committed by Dirk Hohndel
parent 6ae6c768f3
commit c28fe00bfe
6 changed files with 80 additions and 18 deletions

24
dive.c
View file

@ -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;