diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-01 13:02:30 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-04 21:05:26 -0800 |
commit | dcb6574dc4252c4ff598efb17269b7f1255afec1 (patch) | |
tree | c774cd0bb3c85c36988976ce1ab6086c9e996f7b /libdivecomputer.c | |
parent | 7383f7fe0a77c906aafcd61ccfc09dc1866c5416 (diff) | |
download | subsurface-dcb6574dc4252c4ff598efb17269b7f1255afec1.tar.gz |
Improve deco handling and add NDL support
This commit changes the code that was recently introduced to deal with
deco ceilings. Instead of handling these through events we now store the
ceiling (which in reality is the deepest deco stop with all known dive
computers) and the stop time at that ceiling in the samples.
This also adds support for NDL (non stop dive limit) which both dive
computers that appear to give us ceiling / deco information appear to
give us as well (when the diver isn't in deco).
If the mouse hovers over the profile we now add support for displaying the
NDL, the current deco obligation and (if we are able to tell from the
data) whether we are at a safety stop.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r-- | libdivecomputer.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index dba6e6fe5..2162c0fff 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -10,6 +10,7 @@ #include "display-gtk.h" #include "libdivecomputer.h" +#include "libdivecomputer/version.h" /* Christ. Libdivecomputer has the worst configuration system ever. */ #ifdef HW_FROG_H @@ -86,7 +87,7 @@ static void handle_event(struct divecomputer *dc, struct sample *sample, dc_samp }; const int nr_events = sizeof(events) / sizeof(const char *); const char *name; - + static int stoptime = 0, stopdepth = 0, ndl = 0; /* * Just ignore surface events. They are pointless. What "surface" * means depends on the dive computer (and possibly even settings @@ -96,6 +97,27 @@ 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) + if (value.event.type == SAMPLE_EVENT_DECOSTOP) { + /* packed value - time in seconds in high 16 bit + * depth in m(!) in low 16 bits */ + stoptime = value.event.value >> 16; + stopdepth = (value.event.value && 0xFFFF) * 1000; + ndl = 0; + } + if (value.event.type == SAMPLE_EVENT_NDL) { + stopdepth = 0; + stoptime = 0; + ndl = value.event.value; + } + sample->stoptime.seconds = stoptime; + sample->stopdepth.mm = stopdepth; + sample->ndl.seconds = ndl; +#endif + /* * Other evens might be more interesting, but for now we just print them out. */ |