[PATCH 1/3] Add support for heartrate and bearing information in samples

Anton Lundin glance at acc.umu.se
Mon Feb 10 00:19:39 UTC 2014


I can't check right now but I remembered something about uddf-files calling it heading instead of bearing. I think I saw it in the testfile we got from a xDeep or what's its name was. Don't remember if it ever got committed as a test file. I think I only saw it from the Norwegian guy on irc.

It there got imported as events, so there might be some future work there.

And, sorry for the mess of not being able to check things, I'm on my phone with a quite bad connection, so I thought I should just say this before I forgot it.

//Anton

On February 9, 2014 8:54:48 PM EAT, Linus Torvalds <torvalds at linux-foundation.org> wrote:
>
>From: Linus Torvalds <torvalds at linux-foundation.org>
>Date: Fri, 17 Jan 2014 14:00:28 -0800
>Subject: [PATCH 1/3] Add support for heartrate and bearing information
>in samples
>
>libdivecomputer already supports this, but we didn't save it.
>
>Tested-by: Oscar Isoz <jan.oscar.isoz at gmail.com>
>Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
>---
>
>This is unchanged from last time, apart from being rebased and having 
>added the "tested-by" from Oscar.
>
> dive.h            |  2 ++
> libdivecomputer.c |  4 ++--
> parse-xml.c       |  4 ++++
> profile.c         | 10 ++++++++++
> profile.h         |  2 ++
> save-xml.c        |  2 ++
> 6 files changed, 22 insertions(+), 2 deletions(-)
>
>diff --git a/dive.h b/dive.h
>index bcaeda9d29fb..625ea4351973 100644
>--- a/dive.h
>+++ b/dive.h
>@@ -268,6 +268,8 @@ struct sample {
> 	bool in_deco;
> 	int cns;
> 	int po2;
>+	int heartbeat;
>+	int bearing;
> };
> 
> struct divetag {
>diff --git a/libdivecomputer.c b/libdivecomputer.c
>index 3e4af4935505..b3cc1d5f7845 100644
>--- a/libdivecomputer.c
>+++ b/libdivecomputer.c
>@@ -220,10 +220,10 @@ sample_cb(dc_sample_type_t type,
>dc_sample_value_t value, void *userdata)
> 		printf("   <rbt>%u</rbt>\n", value.rbt);
> 		break;
> 	case DC_SAMPLE_HEARTBEAT:
>-		printf("   <heartbeat>%u</heartbeat>\n", value.heartbeat);
>+		sample->heartbeat = value.heartbeat;
> 		break;
> 	case DC_SAMPLE_BEARING:
>-		printf("   <bearing>%u</bearing>\n", value.bearing);
>+		sample->bearing = value.bearing;
> 		break;
> 	case DC_SAMPLE_VENDOR:
>		printf("   <vendor time='%u:%02u' type=\"%u\" size=\"%u\">",
>FRACTION(sample->time.seconds, 60),
>diff --git a/parse-xml.c b/parse-xml.c
>index 111075bfa408..819bd1545289 100644
>--- a/parse-xml.c
>+++ b/parse-xml.c
>@@ -853,6 +853,10 @@ static void try_to_fill_sample(struct sample
>*sample, const char *name, char *bu
> 		return;
> 	if (MATCH("po2.sample", double_to_permil, &sample->po2))
> 		return;
>+	if (MATCH("heartbeat", get_index, &sample->heartbeat))
>+		return;
>+	if (MATCH("bearing", get_index, &sample->bearing))
>+		return;
> 
> 	switch (import_source) {
> 	case DIVINGLOG:
>diff --git a/profile.c b/profile.c
>index f947b9d59768..db8a89af8eb3 100644
>--- a/profile.c
>+++ b/profile.c
>@@ -918,6 +918,8 @@ struct plot_data *populate_plot_entries(struct dive
>*dive, struct divecomputer *
> 			entry->temperature = lasttemp = sample->temperature.mkelvin;
> 		else
> 			entry->temperature = lasttemp;
>+		entry->heartbeat = sample->heartbeat;
>+		entry->bearing = sample->bearing;
> 
> 		lasttime = time;
> 		lastdepth = depth;
>@@ -1520,6 +1522,14 @@ static void plot_string(struct plot_data *entry,
>char *buf, int bufsize,
> 			}
> 		}
> 	}
>+	if (entry->heartbeat) {
>+		memcpy(buf2, buf, bufsize);
>+		snprintf(buf, bufsize, translate("gettextFromC","%s\nheartbeat:%d"),
>buf2, entry->heartbeat);
>+	}
>+	if (entry->bearing) {
>+		memcpy(buf2, buf, bufsize);
>+		snprintf(buf, bufsize, translate("gettextFromC","%s\nbearing:%d"),
>buf2, entry->bearing);
>+	}
> 	free(buf2);
> }
> 
>diff --git a/profile.h b/profile.h
>index 6a6936dbe995..ef81763bfb62 100644
>--- a/profile.h
>+++ b/profile.h
>@@ -42,6 +42,8 @@ struct plot_data {
> 	int stoptime_calc;
> 	int stopdepth_calc;
> 	int pressure_time;
>+	int heartbeat;
>+	int bearing;
> };
>//TODO: remove the calculatE_max_limits as soon as the new profile is
>done.
>void calculate_max_limits(struct dive *dive, struct divecomputer *dc,
>struct graphics_context *gc);
>diff --git a/save-xml.c b/save-xml.c
>index 374632624df7..7eba7165cabc 100644
>--- a/save-xml.c
>+++ b/save-xml.c
>@@ -330,6 +330,8 @@ static void save_sample(struct membuffer *b, struct
>sample *sample, struct sampl
> 		put_milli(b, " po2='", sample->po2, " bar'");
> 		old->po2 = sample->po2;
> 	}
>+	show_index(b, sample->heartbeat, "heartbeat='", "'");
>+	show_index(b, sample->bearing, "bearing='", "'");
> 	put_format(b, " />\n");
> }
> 



More information about the subsurface mailing list