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@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-01-17 14:00:28 -08:00 committed by Dirk Hohndel
parent b88958ded5
commit 22f66501ac
6 changed files with 22 additions and 2 deletions

2
dive.h
View file

@ -268,6 +268,8 @@ struct sample {
bool in_deco;
int cns;
int po2;
int heartbeat;
int bearing;
};
struct divetag {

View file

@ -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),

View file

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

View file

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

View file

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

View file

@ -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");
}