From bd1999134f66ff2c6261e6b9ff8fdd5adeac7e45 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 17 Apr 2018 10:32:28 -0700 Subject: [PATCH] Add subsurface-specific cylinder descriptor extension This extends the libdivecomputer notion of "dc_tankvolume_t" to not just have the tank volume type (imperial or metric), but be a "dc_tankinfo_t" that shows other information about the cylinder. The imperial-vs-metric data remains the same two values: 1 - metric 2 - imperial but instead of being an enumeration of volume types, it is extended to a bitmap of tank information, and the other bits currently are 4 - CC diluent cylinder 8 - CC O2 cylinder with possible future extensions (bailout gas, perhaps). Signed-off-by: Linus Torvalds --- include/libdivecomputer/parser.h | 17 +++++++++++------ src/suunto_eonsteel_parser.c | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 965deda..a9b0fea 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -165,11 +165,16 @@ typedef struct dc_gasmix_t { #define DC_GASMIX_UNKNOWN 0xFFFFFFFF -typedef enum dc_tankvolume_t { - DC_TANKVOLUME_NONE, - DC_TANKVOLUME_METRIC, - DC_TANKVOLUME_IMPERIAL, -} dc_tankvolume_t; +typedef unsigned int dc_tankinfo_t; +#define DC_TANKINFO_METRIC 1 +#define DC_TANKINFO_IMPERIAL 2 +#define DC_TANKINFO_CC_DILUENT 4 +#define DC_TANKINFO_CC_O2 8 + +// For backwards compatibility +#define DC_TANKVOLUME_NONE 0 +#define DC_TANKVOLUME_METRIC DC_TANKINFO_METRIC +#define DC_TANKVOLUME_IMPERIAL DC_TANKINFO_IMPERIAL /* * Tank volume @@ -196,7 +201,7 @@ typedef enum dc_tankvolume_t { typedef struct dc_tank_t { unsigned int gasmix; /* Gas mix index, or DC_GASMIX_UNKNOWN */ - dc_tankvolume_t type; /* Tank type */ + dc_tankinfo_t type; /* Tank type - metric/imperial and oc/cc */ double volume; /* Volume (liter) */ double workpressure; /* Work pressure (bar) */ double beginpressure; /* Begin pressure (bar) */ diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index 75b7091..fc0115b 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -89,7 +89,7 @@ typedef struct suunto_eonsteel_parser_t { double lowsetpoint; double highsetpoint; double customsetpoint; - dc_tankvolume_t tankinfo[MAXGASES]; + dc_tankinfo_t tankinfo[MAXGASES]; double tanksize[MAXGASES]; double tankworkingpressure[MAXGASES]; } cache; @@ -1157,7 +1157,7 @@ static void set_depth_field(suunto_eonsteel_parser_t *eon, unsigned short d) static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *desc, unsigned char type) { int idx = eon->cache.ngases; - dc_tankvolume_t tankinfo = DC_TANKVOLUME_METRIC; + dc_tankinfo_t tankinfo = DC_TANKVOLUME_METRIC; char *name; if (idx >= MAXGASES)