Can you show the heartrate in Subsurface?

Linus Torvalds torvalds at linux-foundation.org
Fri Jan 17 12:48:08 UTC 2014


On Fri, Jan 17, 2014 at 12:42 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> I'll send out a test patch if you want to try.. Give me a couple of minutes,

So here's a TOTALLY UNTESTED patch. I also don't know how well
libdivecomputer actually supports the heartrate thing, although it
does seem to at least exist in the current libdivecomputer sources.

Anyway, with this, if I did things right, subsurface will record the
heartrate and save it in the XML file. *If* it works, please send me
your resulting XML file, and maybe I can look at then displaying it.
Because this patch does *not* actually visualize the heartrate, it
just records what libdivecomputer gives us.

                  Linus
-------------- next part --------------
 dive.h            | 2 ++
 libdivecomputer.c | 4 ++--
 parse-xml.c       | 4 ++++
 save-xml.c        | 2 ++
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dive.h b/dive.h
index e4c4e354c6b7..6dc228ee54bb 100644
--- a/dive.h
+++ b/dive.h
@@ -266,6 +266,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 69fa38c5cc78..b764ae5f6178 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 3e320c9f3b23..b4a816f40948 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -854,6 +854,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/save-xml.c b/save-xml.c
index 374632624df7..d429e8d0dbe2 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