I hope this is good as a first patch!

Changes to sample data structure:
This patch implements changes to the structure of the sample structure
by using more strict typing. In units.h, creating two new typedefs:
        o2pressure_t
        bearing_t
In units.h, changing the types of the unit variables to int32_t or int16_t.
This was for duration_t, depth_t, pressure_t, temperature_t.

Changing the types of the sample structure in dive.h so that all variables are strongly typed and that all variables are defined in term of units. This included:
In dive.h, add the following variables to store rebreather data later on:
        o2setpoint
        o2sensor[3]
Change cylinderpressure to cylinderpressure[2] to povide for diluent

Changes to the files below involved changing sample->po2 to sample->po2.mbar
and changing sample->cylinderpressure to sample->cylinderpressure[0]

Signed-off-by: Willem Ferguson <[email protected]>

>From 96fbda61af243d3ecb2046bb5f2ac3a86c9912d3 Mon Sep 17 00:00:00 2001
From: Willem Ferguson <[email protected]>
Date: Mon, 2 Jun 2014 18:27:51 +0200
Subject: [PATCH 3/3] [PATCH] Rebreather branch. Start of branch.

Changes to sample data structure:
This patch implements changes to the structure of the sample structure
by using more strict typing. In units.h, creating two new typedefs:
        o2pressure_t
        bearing_t
In units.h, changing the types of the unit variables to int32_t or int16_t.
This was for duration_t, depth_t, pressure_t, temperature_t.

Changing the types of the sample structure in dive.h so that all variables are
strongly typed and that all variables are defined in term of units. This included:
In dive.h, add the following variables to store rebreather data:
        o2setpoint
        o2sensor[3]
        Change cylinderpressure to cylinderpressure[2] to povide for diluent
Changes to the files below involved changing sample->po2 to sample->po2.mbar
and changing sample->cylinderpressure to sample->cylinderpressure[0]

Signed-off-by: Willem Ferguson <[email protected]>
---
 dive.c            |   18 +++++++++---------
 dive.h            |   33 ++++++++++++++++++---------------
 divelist.c        |   10 +++++-----
 file.c            |    2 +-
 libdivecomputer.c |   10 +++++-----
 load-git.c        |    8 ++++----
 parse-xml.c       |    8 ++++----
 planner.c         |   14 +++++++-------
 profile.c         |    8 ++++----
 save-git.c        |   10 +++++-----
 save-xml.c        |   10 +++++-----
 uemis.c           |    2 +-
 units.h           |   20 +++++++++++++++-----
 13 files changed, 83 insertions(+), 70 deletions(-)

diff --git a/dive.c b/dive.c
index 9cfdfc1..b5e398a 100644
--- a/dive.c
+++ b/dive.c
@@ -471,7 +471,7 @@ static void fixup_pressure(struct dive *dive, struct sample *sample)
 	int pressure, index;
 	cylinder_t *cyl;
 
-	pressure = sample->cylinderpressure.mbar;
+	pressure = sample->cylinderpressure[0].mbar;
 	if (!pressure)
 		return;
 	index = sample->sensor;
@@ -856,13 +856,13 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
 		int time = sample->time.seconds;
 		int depth = sample->depth.mm;
 		int temp = sample->temperature.mkelvin;
-		int pressure = sample->cylinderpressure.mbar;
+		int pressure = sample->cylinderpressure[0].mbar;
 		int index = sample->sensor;
 
 		if (index == lastindex) {
 			/* Remove duplicate redundant pressure information */
 			if (pressure == lastpressure)
-				sample->cylinderpressure.mbar = 0;
+				sample->cylinderpressure[0].mbar = 0;
 			/* check for simply linear data in the samples
 			   +INT_MAX means uninitialized, -INT_MAX means not linear */
 			if (pressure_delta[index] != -INT_MAX && lastpressure) {
@@ -929,7 +929,7 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
 			cylinder_t *cyl = dive->cylinder + j;
 			for (i = 0; i < dc->samples; i++)
 				if (dc->sample[i].sensor == j)
-					dc->sample[i].cylinderpressure.mbar = 0;
+					dc->sample[i].cylinderpressure[0].mbar = 0;
 			if (!cyl->start.mbar)
 				cyl->start.mbar = cyl->sample_start.mbar;
 			if (!cyl->end.mbar)
@@ -1099,13 +1099,13 @@ static void merge_samples(struct divecomputer *res, struct divecomputer *a, stru
 			sample.depth = as->depth;
 		if (as->temperature.mkelvin)
 			sample.temperature = as->temperature;
-		if (as->cylinderpressure.mbar)
-			sample.cylinderpressure = as->cylinderpressure;
+		if (as->cylinderpressure[0].mbar)
+			sample.cylinderpressure[0] = as->cylinderpressure[0];
 		if (as->sensor)
 			sample.sensor = as->sensor;
 		if (as->cns)
 			sample.cns = as->cns;
-		if (as->po2)
+		if (as->po2.mbar)
 			sample.po2 = as->po2;
 		if (as->ndl.seconds)
 			sample.ndl = as->ndl;
@@ -1300,7 +1300,7 @@ static void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, int
 		struct sample *s = dc->sample + i;
 		int sensor;
 
-		if (!s->cylinderpressure.mbar)
+		if (!s->cylinderpressure[0].mbar)
 			continue;
 		sensor = mapping[s->sensor];
 		if (sensor >= 0)
@@ -1804,7 +1804,7 @@ static int same_sample(struct sample *a, struct sample *b)
 		return 0;
 	if (a->temperature.mkelvin != b->temperature.mkelvin)
 		return 0;
-	if (a->cylinderpressure.mbar != b->cylinderpressure.mbar)
+	if (a->cylinderpressure[0].mbar != b->cylinderpressure[0].mbar)
 		return 0;
 	return a->sensor == b->sensor;
 }
diff --git a/dive.h b/dive.h
index 26732df..314010e 100644
--- a/dive.h
+++ b/dive.h
@@ -140,21 +140,24 @@ static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit) {
 void get_gas_string(const struct gasmix *gasmix, char *text, int len);
 const char *gasname(const struct gasmix *gasmix);
 
-struct sample {
-	duration_t time;
-	depth_t depth;
-	temperature_t temperature;
-	pressure_t cylinderpressure;
-	int sensor; /* Cylinder pressure sensor index */
-	duration_t ndl;
-	duration_t stoptime;
-	depth_t stopdepth;
-	bool in_deco;
-	int cns;
-	int po2;
-	int heartbeat;
-	int bearing;
-};
+struct sample                         // BASE TYPE BYTES  UNITS    RANGE      DESCRIPTION
+{                                     // --------- -----  -----    -----      -----------
+        duration_t time;               // int32_t    4  seconds  (0-68 yrs)   elapsed dive time up to this sample
+        duration_t stoptime;           // uint32_t   2  seconds  (0-18 h)     time duration of next deco stop
+        duration_t ndl;                // uint32_t   2  seconds  (0-18 h)     time duration before no-deco limit
+        depth_t depth;                 // int32_t    4    mm     (0-2000 km)  dive depth of this sample
+        depth_t stopdepth;             // int32_t    4    mm     (0-2000 km)  depth of next deco stop
+        temperature_t temperature;     // int32_t    4  mdegrK   (0-2 MdegrK) ambient temperature
+        pressure_t cylinderpressure[2];// int32_t    8    mbar   (0-2 Mbar)   cylinder pressure 
+        uint8_t sensor;                // uint8_t    1  sensorID (0-255)      ID of cylinder pressure sensor
+        o2pressure_t po2;              // uint32_t   4    mbar   (0-65 bar)   O2 partial pressure
+        o2pressure_t o2setpoint;       // uint32_t   4    mbar   (0-65 bar)   O2 setpoint (rebreather)
+        o2pressure_t o2sensor[3];      // uint32_t   6    mbar   (0-65 bar)   Up to 3 PO2 sensor values (rebreather)
+        bearing_t bearing;             // int16_t    2  degrees  (-32k to 32k deg) compass bearing
+        uint8_t   cns;                 // uint8_t    1     %     (0-255 %)    cns% accumulated 
+        uint8_t   heartbeat;           // uint8_t    1  beats/m  (0-255)      heart rate measurement
+        bool      in_deco;             // bool       1    y/n      y/n        this sample is part of deco
+};                      // Total size of structure: 48 bytes, excluding padding at end
 
 struct divetag {
 	/*
diff --git a/divelist.c b/divelist.c
index 4899824..c018bbd 100644
--- a/divelist.c
+++ b/divelist.c
@@ -178,8 +178,8 @@ static int calculate_otu(struct dive *dive)
 		struct sample *sample = dc->sample + i;
 		struct sample *psample = sample - 1;
 		t = sample->time.seconds - psample->time.seconds;
-		if (sample->po2) {
-			po2 = sample->po2;
+		if (sample->po2.mbar) {
+			po2 = sample->po2.mbar;
 		} else {
 			int o2 = active_o2(dive, dc, sample->time);
 			po2 = o2 * depth_to_atm(sample->depth.mm, dive);
@@ -242,8 +242,8 @@ static int calculate_cns(struct dive *dive)
 		struct sample *sample = dc->sample + i;
 		struct sample *psample = sample - 1;
 		t = sample->time.seconds - psample->time.seconds;
-		if (sample->po2) {
-			po2 = sample->po2;
+		if (sample->po2.mbar) {
+			po2 = sample->po2.mbar;
 		} else {
 			int o2 = active_o2(dive, dc, sample->time);
 			po2 = o2 / depth_to_atm(sample->depth.mm, dive);
@@ -326,7 +326,7 @@ static void add_dive_to_deco(struct dive *dive)
 		for (j = t0; j < t1; j++) {
 			int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0);
 			(void)add_segment(depth_to_mbar(depth, dive) / 1000.0,
-					  &dive->cylinder[sample->sensor].gasmix, 1, sample->po2, dive);
+					  &dive->cylinder[sample->sensor].gasmix, 1, sample->po2.mbar, dive);
 		}
 	}
 }
diff --git a/file.c b/file.c
index 2c0b9f9..fc47aca 100644
--- a/file.c
+++ b/file.c
@@ -236,7 +236,7 @@ static void add_sample_data(struct sample *sample, enum csv_format type, double
 		sample->temperature.mkelvin = F_to_mkelvin(val);
 		break;
 	case CSV_PRESSURE:
-		sample->cylinderpressure.mbar = psi_to_mbar(val * 4);
+		sample->cylinderpressure[0].mbar = psi_to_mbar(val * 4);
 		break;
 	}
 }
diff --git a/libdivecomputer.c b/libdivecomputer.c
index d6f2d60..275a647 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -198,7 +198,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
 			sample->ndl.seconds = ndl;
 			sample->stoptime.seconds = stoptime;
 			sample->stopdepth.mm = stopdepth;
-			sample->po2 = po2;
+			sample->po2.mbar = po2;
 			sample->cns = cns;
 		}
 		sample = prepare_sample(dc);
@@ -210,7 +210,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
 		break;
 	case DC_SAMPLE_PRESSURE:
 		sample->sensor = value.pressure.tank;
-		sample->cylinderpressure.mbar = rint(value.pressure.value * 1000);
+		sample->cylinderpressure[0].mbar = rint(value.pressure.value * 1000);
 		break;
 	case DC_SAMPLE_TEMPERATURE:
 		sample->temperature.mkelvin = C_to_mkelvin(value.temperature);
@@ -225,7 +225,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
 		sample->heartbeat = value.heartbeat;
 		break;
 	case DC_SAMPLE_BEARING:
-		sample->bearing = value.bearing;
+		sample->bearing.degrees = value.bearing;
 		break;
 	case DC_SAMPLE_VENDOR:
 		printf("   <vendor time='%u:%02u' type=\"%u\" size=\"%u\">", FRACTION(sample->time.seconds, 60),
@@ -237,10 +237,10 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
 #if DC_VERSION_CHECK(0, 3, 0)
 	case DC_SAMPLE_SETPOINT:
 		/* for us a setpoint means constant pO2 from here */
-		sample->po2 = po2 = rint(value.setpoint * 1000);
+		sample->po2.mbar = po2 = rint(value.setpoint * 1000);
 		break;
 	case DC_SAMPLE_PPO2:
-		sample->po2 = po2 = rint(value.ppo2 * 1000);
+		sample->po2.mbar = po2 = rint(value.ppo2 * 1000);
 		break;
 	case DC_SAMPLE_CNS:
 		sample->cns = cns = rint(value.cns * 100);
diff --git a/load-git.c b/load-git.c
index acfdd25..84298b1 100644
--- a/load-git.c
+++ b/load-git.c
@@ -376,7 +376,7 @@ static void parse_sample_keyvalue(void *_sample, const char *key, const char *va
 	if (!strcmp(key, "po2")) {
 		pressure_t p = get_pressure(value);
 		// Ugh, typeless.
-		sample->po2 = p.mbar;
+		sample->po2.mbar = p.mbar;
 		return;
 	}
 	if (!strcmp(key, "heartbeat")) {
@@ -384,7 +384,7 @@ static void parse_sample_keyvalue(void *_sample, const char *key, const char *va
 		return;
 	}
 	if (!strcmp(key, "bearing")) {
-		sample->bearing = atoi(value);
+		sample->bearing.degrees = atoi(value);
 		return;
 	}
 	report_error("Unexpected sample key/value pair (%s/%s)", key, value);
@@ -409,7 +409,7 @@ static char *parse_sample_unit(struct sample *sample, double val, char *unit)
 		sample->depth.mm = rint(1000*val);
 		break;
 	case 'b':
-		sample->cylinderpressure.mbar = rint(1000*val);
+		sample->cylinderpressure[0].mbar = rint(1000*val);
 		break;
 	default:
 		sample->temperature.mkelvin = C_to_mkelvin(val);
@@ -435,7 +435,7 @@ static struct sample *new_sample(struct divecomputer *dc)
 	struct sample *sample = prepare_sample(dc);
 	if (sample != dc->sample) {
 		memcpy(sample, sample-1, sizeof(struct sample));
-		sample->cylinderpressure.mbar = 0;
+		sample->cylinderpressure[0].mbar = 0;
 	}
 	return sample;
 }
diff --git a/parse-xml.c b/parse-xml.c
index f6806d2..22741a4 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1325,7 +1325,7 @@ static void sample_start(void)
 	cur_sample->stoptime.seconds = laststoptime;
 	cur_sample->stopdepth.mm = laststopdepth;
 	cur_sample->cns = lastcns;
-	cur_sample->po2 = lastpo2;
+	cur_sample->po2.mbar = lastpo2;
 	cur_sample->sensor = lastsensor;
 }
 
@@ -1340,7 +1340,7 @@ static void sample_end(void)
 	laststoptime = cur_sample->stoptime.seconds;
 	laststopdepth = cur_sample->stopdepth.mm;
 	lastcns = cur_sample->cns;
-	lastpo2 = cur_sample->po2;
+	lastpo2 = cur_sample->po2.mbar;
 	cur_sample = NULL;
 }
 
@@ -1836,7 +1836,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
 		if (data[18] && data[18][0])
 			cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
 		if (data[19] && data[19][0])
-			cur_sample->cylinderpressure.mbar = pressureBlob[i];
+			cur_sample->cylinderpressure[0].mbar = pressureBlob[i];
 		sample_end();
 	}
 
@@ -1927,7 +1927,7 @@ extern int shearwater_profile_sample(void *handle, int columns, char **data, cha
 	if (data[2])
 		cur_sample->temperature.mkelvin = metric ? C_to_mkelvin(atof(data[2])) : F_to_mkelvin(atof(data[2]));
 	if (data[3])
-		cur_sample->po2 = atof(data[3]) * 1000;
+		cur_sample->po2.mbar = atof(data[3]) * 1000;
 	if (data[4])
 		cur_sample->ndl.seconds = atoi(data[4]) * 60;
 	if (data[5])
diff --git a/planner.c b/planner.c
index cc8e9d9..c61a435 100644
--- a/planner.c
+++ b/planner.c
@@ -138,7 +138,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap)
 		}
 		if (i > 0)
 			lastdepth = psample->depth.mm;
-		tissue_tolerance = interpolate_transition(dive, t0, t1, lastdepth, sample->depth.mm, &dive->cylinder[gasidx].gasmix, sample->po2);
+		tissue_tolerance = interpolate_transition(dive, t0, t1, lastdepth, sample->depth.mm, &dive->cylinder[gasidx].gasmix, sample->po2.mbar);
 		psample = sample;
 		t0 = t1;
 	}
@@ -242,7 +242,7 @@ static struct dive *create_dive_from_plan(struct diveplan *diveplan, struct dive
 	cyl = &master_dive->cylinder[0];
 	oldgasmix = cyl->gasmix;
 	sample = prepare_sample(dc);
-	sample->po2 = dp->po2;
+	sample->po2.mbar = dp->po2;
 	finish_sample(dc);
 	while (dp) {
 		struct gasmix gasmix = dp->gasmix;
@@ -279,7 +279,7 @@ static struct dive *create_dive_from_plan(struct diveplan *diveplan, struct dive
 			/* need to insert a first sample for the new gas */
 			add_gas_switch_event(dive, dc, lasttime + 1, idx);
 			sample = prepare_sample(dc);
-			sample[-1].po2 = po2;
+			sample[-1].po2.mbar = po2;
 			sample->time.seconds = lasttime + 1;
 			sample->depth.mm = lastdepth;
 			finish_sample(dc);
@@ -290,13 +290,13 @@ static struct dive *create_dive_from_plan(struct diveplan *diveplan, struct dive
 		sample = prepare_sample(dc);
 		/* set po2 at beginning of this segment */
 		/* and keep it valid for last sample - where it likely doesn't matter */
-		sample[-1].po2 = po2;
-		sample->po2 = po2;
+		sample[-1].po2.mbar = po2;
+		sample->po2.mbar = po2;
 		sample->time.seconds = lasttime = time;
 		sample->depth.mm = lastdepth = depth;
 		update_cylinder_pressure(dive, sample[-1].depth.mm, depth, time - sample[-1].time.seconds,
 				dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl);
-		sample->cylinderpressure.mbar = cyl->end.mbar;
+		sample->cylinderpressure[0].mbar = cyl->end.mbar;
 		finish_sample(dc);
 		dp = dp->next;
 	}
@@ -630,7 +630,7 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, s
 	/* we start with gas 0, then check if that was changed */
 	gas = dive->cylinder[0].gasmix;
 	get_gas_from_events(&dive->dc, sample->time.seconds, &gas);
-	po2 = dive->dc.sample[dive->dc.samples - 1].po2;
+	po2 = dive->dc.sample[dive->dc.samples - 1].po2.mbar;
 	if ((current_cylinder = get_gasidx(dive, &gas)) == -1) {
 		report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas));
 		current_cylinder = 0;
diff --git a/profile.c b/profile.c
index d3934e3..cad02fe 100644
--- a/profile.c
+++ b/profile.c
@@ -700,7 +700,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer
 
 		while (--i >= 0) {
 			int depth = s->depth.mm;
-			int pressure = s->cylinderpressure.mbar;
+			int pressure = s->cylinderpressure[0].mbar;
 			int temperature = s->temperature.mkelvin;
 			int heartbeat = s->heartbeat;
 
@@ -834,16 +834,16 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *
 		pi->has_ndl |= sample->ndl.seconds;
 		entry->in_deco = sample->in_deco;
 		entry->cns = sample->cns;
-		entry->po2 = sample->po2 / 1000.0;
+		entry->po2 = sample->po2.mbar / 1000.0;
 		/* FIXME! sensor index -> cylinder index translation! */
 		entry->cylinderindex = sample->sensor;
-		SENSOR_PRESSURE(entry) = sample->cylinderpressure.mbar;
+		SENSOR_PRESSURE(entry) = sample->cylinderpressure[0].mbar;
 		if (sample->temperature.mkelvin)
 			entry->temperature = lasttemp = sample->temperature.mkelvin;
 		else
 			entry->temperature = lasttemp;
 		entry->heartbeat = sample->heartbeat;
-		entry->bearing = sample->bearing;
+		entry->bearing = sample->bearing.degrees;
 
 		/* skip events that happened at this time */
 		while (ev && ev->time.seconds == time)
diff --git a/save-git.c b/save-git.c
index 6abba60..290c4d2 100644
--- a/save-git.c
+++ b/save-git.c
@@ -227,13 +227,13 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
 	put_format(b, "%3u:%02u", FRACTION(sample->time.seconds, 60));
 	put_milli(b, " ", sample->depth.mm, "m");
 	put_temperature(b, sample->temperature, " ", "°C");
-	put_pressure(b, sample->cylinderpressure, " ", "bar");
+	put_pressure(b, sample->cylinderpressure[0], " ", "bar");
 
 	/*
 	 * We only show sensor information for samples with pressure, and only if it
 	 * changed from the previous sensor we showed.
 	 */
-	if (sample->cylinderpressure.mbar && sample->sensor != old->sensor) {
+	if (sample->cylinderpressure[0].mbar && sample->sensor != old->sensor) {
 		put_format(b, " sensor=%d", sample->sensor);
 		old->sensor = sample->sensor;
 	}
@@ -262,12 +262,12 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
 		old->cns = sample->cns;
 	}
 
-	if (sample->po2 != old->po2) {
-		put_milli(b, " po2=", sample->po2, "bar");
+	if (sample->po2.mbar != old->po2.mbar) {
+		put_milli(b, " po2=", sample->po2.mbar, "bar");
 		old->po2 = sample->po2;
 	}
 	show_index(b, sample->heartbeat, "heartbeat=", "");
-	show_index(b, sample->bearing, "bearing=", "°");
+	show_index(b, sample->bearing.degrees, "bearing=", "°");
 	put_format(b, "\n");
 }
 
diff --git a/save-xml.c b/save-xml.c
index e52cfdf..6d386fa 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -244,13 +244,13 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
 	put_format(b, "  <sample time='%u:%02u min'", FRACTION(sample->time.seconds, 60));
 	put_milli(b, " depth='", sample->depth.mm, " m'");
 	put_temperature(b, sample->temperature, " temp='", " C'");
-	put_pressure(b, sample->cylinderpressure, " pressure='", " bar'");
+	put_pressure(b, sample->cylinderpressure[0], " pressure='", " bar'");
 
 	/*
 	 * We only show sensor information for samples with pressure, and only if it
 	 * changed from the previous sensor we showed.
 	 */
-	if (sample->cylinderpressure.mbar && sample->sensor != old->sensor) {
+	if (sample->cylinderpressure[0].mbar && sample->sensor != old->sensor) {
 		put_format(b, " sensor='%d'", sample->sensor);
 		old->sensor = sample->sensor;
 	}
@@ -279,12 +279,12 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
 		old->cns = sample->cns;
 	}
 
-	if (sample->po2 != old->po2) {
-		put_milli(b, " po2='", sample->po2, " bar'");
+	if (sample->po2.mbar != old->po2.mbar) {
+		put_milli(b, " po2='", sample->po2.mbar, " bar'");
 		old->po2 = sample->po2;
 	}
 	show_index(b, sample->heartbeat, "heartbeat='", "'");
-	show_index(b, sample->bearing, "bearing='", "'");
+	show_index(b, sample->bearing.degrees, "bearing='", "'");
 	put_format(b, " />\n");
 }
 
diff --git a/uemis.c b/uemis.c
index 59f7057..4798690 100644
--- a/uemis.c
+++ b/uemis.c
@@ -356,7 +356,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap)
 		sample->depth.mm = rel_mbar_to_depth(u_sample->water_pressure, dive);
 		sample->temperature.mkelvin = C_to_mkelvin(u_sample->dive_temperature / 10.0);
 		sample->sensor = active;
-		sample->cylinderpressure.mbar =
+		sample->cylinderpressure[0].mbar =
 		    (u_sample->tank_pressure_high * 256 + u_sample->tank_pressure_low) * 10;
 		sample->cns = u_sample->cns;
 		uemis_event(dive, dc, sample, u_sample);
diff --git a/units.h b/units.h
index 0a9e44b..2ec9fec 100644
--- a/units.h
+++ b/units.h
@@ -59,26 +59,36 @@ typedef int64_t timestamp_t;
 
 typedef struct
 {
-	int seconds;
+	int32_t seconds;        // durations up to 68 yrs
 } duration_t;
 
 typedef struct
 {
-	int mm;
+	int32_t mm;             // depth up to 2000 km
 } depth_t;
 
 typedef struct
 {
-	int mbar;
+	int32_t mbar;           // pressure up to 2000 bar
 } pressure_t;
 
 typedef struct
 {
-	int mkelvin;
+        uint32_t mbar;
+} o2pressure_t;                 // pressure up to 65 bar  
+    
+typedef struct
+{
+	int32_t mkelvin;        // temp up to 1750 degrees C
 } temperature_t;
 
 typedef struct
 {
+        int16_t degrees;        // avoid ambiguity with radians
+} bearing_t;                    // compass bearing
+
+typedef struct
+{
 	int mliter;
 } volume_t;
 
@@ -242,4 +252,4 @@ struct units {
 }
 #endif
 
-#endif
\ No newline at end of file
+#endif
-- 
1.7.10.4

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to