diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-11 07:43:11 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-11 13:05:08 -0800 |
commit | 563af1daa781a53fad308870320f99a1903d5058 (patch) | |
tree | 0cf746aa4626e3a6d37bc63919c3f22f699902fc /libdivecomputer.c | |
parent | 39f80a1e0f38720addc66315aa1235731ba03418 (diff) | |
download | subsurface-563af1daa781a53fad308870320f99a1903d5058.tar.gz |
Update to the new deco / ndl code in libdivecomputer
Early in the libdivecomputer 0.3 development cycle Jef and I implemented
deco and ndl as events. That wasn't a wise design choice and we agreed to
switch this to be instead new sample types which makes much more sense
(and is much more aligned with the way we are handling them inside
Subsurface). So this commit tracks the change in libdivecomputer. Since
this happened during the development cycle there isn't a way to detect
this at compile time - so you need to make sure you have a matching
version of libdivecomputer when compiling Subsurface.
To make this easier: this commit of Subsurface requires a libdivecomputer
version that includes the libdivecomputer commit d5d44c1e0ffd "Convert
decostop / ndl to samples".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r-- | libdivecomputer.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index 99532b63f..51c6a5775 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -97,10 +97,10 @@ static void handle_event(struct divecomputer *dc, struct sample *sample, dc_samp if (value.event.type == SAMPLE_EVENT_SURFACE) return; - /* libdivecomputer 0.3 provides us with deco / ndl information for at least - * the OSTC. Sadly, it does so through events - so we convert this into our - * preferred sample format here */ -#if DC_VERSION_CHECK(0, 3, 0) + /* an early development version of libdivecomputer 0.3 provided us with deco / ndl information for + * a couple of dive computers through events; this got fixed later in the release cycle but for a + * short while I'll keep the code around that converts the events into our preferred sample format here */ +#if 0 if (value.event.type == SAMPLE_EVENT_DECOSTOP) { /* packed value - time in seconds in high 16 bit * depth in m(!) in low 16 bits */ @@ -198,6 +198,14 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) case DC_SAMPLE_CNS: sample->cns = cns = value.cns * 100 + 0.5; break; + case DC_SAMPLE_DECO: + if (value.deco.type == DC_DECO_NDL) { + ndl = value.deco.time; + } else if (value.deco.type == DC_DECO_DECOSTOP || + value.deco.type == DC_DECO_DEEPSTOP) { + stopdepth = value.deco.depth * 1000.0 + 0.5; + stoptime = value.deco.time; + } #endif default: break; |