diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-03 17:21:05 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-03 21:36:51 -0800 |
commit | 08d2ceb66bf40640b83cbfe1dc278c698ceb92b6 (patch) | |
tree | bb7e45f6987a7e689456e16c6ff60e229a85aa02 /dive.c | |
parent | 92733049a7f8c37bf1caafe93fa40fd8bae51254 (diff) | |
download | subsurface-08d2ceb66bf40640b83cbfe1dc278c698ceb92b6.tar.gz |
Extend SAMPLE_EVENT_GASCHANGE2 to have cylinder index in 'flags' field
A value of zero (which is the normal legacy one) remains "unknown", but
the divecomputer backend can now give both gasmix and cylinder number
this way.
Currently only the EON Steel backend does that, but it should be easy
enough to extend others too.
Also, fix the user-visible cylinder numbering in the cylinder change
tooltip to use a human-friendlier one-based numbering (ie first cylinder
is "cyl 1", not "cyl 0")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -57,6 +57,7 @@ int event_gasmix_redundant(struct event *ev) struct event *add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name) { + int gas_index = -1; struct event *ev, **p; unsigned int size, len = strlen(name); @@ -79,11 +80,15 @@ struct event *add_event(struct divecomputer *dc, int time, int type, int flags, case SAMPLE_EVENT_GASCHANGE2: /* High 16 bits are He percentage */ ev->gas.mix.he.permille = (value >> 16) * 10; + + /* Extension to the GASCHANGE2 format: cylinder index in 'flags' */ + if (flags > 0 && flags <= MAX_CYLINDERS) + gas_index = flags-1; /* Fallthrough */ case SAMPLE_EVENT_GASCHANGE: /* Low 16 bits are O2 percentage */ ev->gas.mix.o2.permille = (value & 0xffff) * 10; - ev->gas.index = -1; + ev->gas.index = gas_index; break; } |