diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-11-14 12:36:40 +0100 |
---|---|---|
committer | Jan Mulder <jlmulder@xs4all.nl> | 2017-11-16 08:32:46 +0100 |
commit | 0895bccf495f478821c92dc1da00c2f62752f031 (patch) | |
tree | 91a0eff1e661e5f746bb15ccc22d36c5d230b251 /core/libdivecomputer.c | |
parent | 249b758b0dbd833a172fd6cab9c64345174dbdf0 (diff) | |
download | subsurface-0895bccf495f478821c92dc1da00c2f62752f031.tar.gz |
libdivecomputer.c init sticky values for samples for current sample
When filling samples with values during DC import fill sticky values
like CNS, NDL, stoptime,... immediately into current sample.
Otherwise we will not fill the sticky values into the last sample
created.
Add two new sticky values: heartbeat and bearing
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'core/libdivecomputer.c')
-rw-r--r-- | core/libdivecomputer.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index d8fe54e8d..c80c8f28b 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -41,7 +41,7 @@ const char *progress_bar_text = ""; void (*progress_callback)(const char *text) = NULL; double progress_bar_fraction = 0.0; -static int stoptime, stopdepth, ndl, po2, cns; +static int stoptime, stopdepth, ndl, po2, cns, heartbeat, bearing; static bool in_deco, first_temp_is_air; static int current_gas_index; @@ -332,22 +332,22 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) case DC_SAMPLE_TIME: nsensor = 0; - // The previous sample gets some sticky values - // that may have been around from before, even - // if there was no new data - if (sample) { - sample->in_deco = in_deco; - sample->ndl.seconds = ndl; - sample->stoptime.seconds = stoptime; - sample->stopdepth.mm = stopdepth; - sample->setpoint.mbar = po2; - sample->cns = cns; - } // Create a new sample. // Mark depth as negative sample = prepare_sample(dc); sample->time.seconds = value.time; sample->depth.mm = -1; + // The current sample gets some sticky values + // that may have been around from before, these + // values will be overwritten by new data if available + sample->in_deco = in_deco; + sample->ndl.seconds = ndl; + sample->stoptime.seconds = stoptime; + sample->stopdepth.mm = stopdepth; + sample->setpoint.mbar = po2; + sample->cns = cns; + sample->heartbeat = heartbeat; + sample->bearing.degrees = bearing; finish_sample(dc); break; case DC_SAMPLE_DEPTH: @@ -369,10 +369,10 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) sample->rbt.seconds = (!strncasecmp(dc->model, "suunto", 6)) ? value.rbt : value.rbt * 60; break; case DC_SAMPLE_HEARTBEAT: - sample->heartbeat = value.heartbeat; + sample->heartbeat = heartbeat = value.heartbeat; break; case DC_SAMPLE_BEARING: - sample->bearing.degrees = value.bearing; + sample->bearing.degrees = bearing = value.bearing; break; #ifdef DEBUG_DC_VENDOR case DC_SAMPLE_VENDOR: |