summaryrefslogtreecommitdiffstats
path: root/uemis.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-28 21:13:21 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-28 21:13:21 -0700
commit10fac7a6af7e95b45029372f32ce544c705f6887 (patch)
tree9777ea690e990051934d6ae38c0afb8963deb1ec /uemis.c
parent7259cf5bb64f7cf914c216c4c46cef5f416bb5a6 (diff)
downloadsubsurface-10fac7a6af7e95b45029372f32ce544c705f6887.tar.gz
Updating events for libdivecomputer 0.3 (and tracking uemis support)
I was a little too eager to add the deco feature to Subsurface. Jef and I went back and forth a few more times and the definition of those events changed. I guess I shouldn't have commited that code until the corresponding libdivecomputer code had been pushed. This commit now brings us in sync with the current master of libdivecomputer (but should compile with 0.2 as well - only deco events won't work then). One issue that I see is that deco / ndl aren't really a good fit for the event model. I actually disabled the drawing of the little yellow triangles for ndl events as for example on the Uemis those events are created whenever the remaining non stop time changes - and that can be every few seconds. The correct solution may be to treat this as a function of the samples, but for now this works and is tested with both OSTC and Uemis SDA. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'uemis.c')
-rw-r--r--uemis.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/uemis.c b/uemis.c
index 88099beb3..198d90358 100644
--- a/uemis.c
+++ b/uemis.c
@@ -19,6 +19,7 @@
#include "dive.h"
#include "uemis.h"
#include <libdivecomputer/parser.h>
+#include <libdivecomputer/version.h>
/*
* following code is based on code found in at base64.sourceforge.net/b64.c
@@ -101,8 +102,6 @@ bail:
return datalen;
}
-static gboolean in_deco;
-
/* Create events from the flag bits and other data in the sample;
* These bits basically represent what is displayed on screen at sample time.
* Many of these 'warnings' are way hyper-active and seriously clutter the
@@ -160,19 +159,21 @@ static void uemis_event(struct dive *dive, struct divecomputer *dc, struct sampl
/* flags[7] reflects the little on screen icons that remind of previous
* warnings / alerts - not useful for events */
- /* now add deco / ceiling events */
- if (u_sample->p_amb_tol > dive->surface_pressure.mbar &&
- u_sample->hold_time &&
- u_sample->hold_time < 99) {
- add_event(dc, sample->time.seconds, SAMPLE_EVENT_CEILING, SAMPLE_FLAGS_BEGIN,
- u_sample->hold_depth * 10, N_("ceiling"));
- add_event(dc, sample->time.seconds, SAMPLE_EVENT_DECOSTOP, 0,
- u_sample->hold_time * 60, N_("deco"));
- in_deco = TRUE;
- } else if (in_deco) {
- in_deco = FALSE;
- add_event(dc, sample->time.seconds, SAMPLE_EVENT_CEILING, SAMPLE_FLAGS_END,
- 0, N_("ceiling"));
+ /* now add deco / NDL
+ * This will create an event for every sample (SUCK) but the
+ * code in the parser will then do the right thing and just
+ * keep the relevant ones */
+ if (u_sample->p_amb_tol > dive->surface_pressure.mbar) {
+ if (u_sample->hold_time && u_sample->hold_time < 99) {
+ int hold_depth = u_sample->hold_depth / 100.0 + 0.5;
+ add_event(dc, sample->time.seconds, SAMPLE_EVENT_DECOSTOP, 0,
+ hold_depth | (u_sample->hold_time * 60) << 16 , N_("deco stop"));
+ }
+#if DC_VERSION_CHECK(0, 3, 0)
+ } else {
+ add_event(dc, sample->time.seconds, SAMPLE_EVENT_NDL, 0,
+ u_sample->hold_time * 60, N_("non stop time"));
+#endif
}
}
@@ -189,7 +190,6 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
struct divecomputer *dc = &dive->dc;
int template, gasoffset;
- in_deco = FALSE;
datalen = uemis_convert_base64(base64, &data);
dive->airtemp.mkelvin = *(uint16_t *)(data + 45) * 100 + 273150;