summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2011-11-01 20:13:14 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2011-11-01 20:13:14 -0700
commitb26ca781b87371e77b851298093b0a7136be64fa (patch)
tree287bc1a886661a5bf6f2eb49c778d40347edb36a /dive.c
parenta487f6c9314f0fe5e4173b670d9653067285da21 (diff)
downloadsubsurface-b26ca781b87371e77b851298093b0a7136be64fa.tar.gz
Use unit functions to get column headers, add unit function for pressure
Finally getting more consistent overall in how we convert between the different units and how we decide which units to display. 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 53a874b9b..cb94e7925 100644
--- a/dive.c
+++ b/dive.c
@@ -29,6 +29,30 @@ void add_event(struct dive *dive, int time, int type, int flags, int value, cons
remember_event(name);
}
+int get_pressure_units(unsigned int mb, const char **units)
+{
+ int pressure;
+ const char* unit;
+
+ switch (output_units.pressure) {
+ case PASCAL:
+ pressure = mb * 100;
+ unit = "pascal";
+ break;
+ case BAR:
+ pressure = (mb + 500) / 1000;
+ unit = "bar";
+ break;
+ case PSI:
+ pressure = mbar_to_PSI(mb);
+ unit = "psi";
+ break;
+ }
+ if (units)
+ *units = unit;
+ return pressure;
+}
+
double get_temp_units(unsigned int mk, const char **units)
{
double deg;