From 086b0a799e0a2673fe75caa4a67a07c4ed1a5e28 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 7 May 2020 12:06:08 -0700 Subject: [PATCH] Clean up 'dc_tankvolume_t' type and make it 'dc_tankinfo_t' The dc_tankvolume_t type had information about metric vs imperial volume, but we actually want other things too, like the actual usage of the cylinder. So rename it to 'dc_tankinfo_t' and extend the semantics from an enumeration of volume units, to be a bitmap of information flags. 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 1b53fd3..d12ca26 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -148,11 +148,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 @@ -179,7 +184,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 33a6b3d..19616c4 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_TANKINFO_METRIC; char *name; if (idx >= MAXGASES)