diff options
author | Jan Schubert <Jan.Schubert@GMX.li> | 2013-02-02 18:03:26 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-03 07:05:16 +1100 |
commit | 057253c4eb4b3daf3bd18dc91df29ed11d35c275 (patch) | |
tree | afe1a850727a8b3d8ca9b5e13c9c680ec1950be0 /planner.c | |
parent | 8a49278740a68f4aba9d77492910b3d0136e8897 (diff) | |
download | subsurface-057253c4eb4b3daf3bd18dc91df29ed11d35c275.tar.gz |
Fixing SP handling in planner, adding event
Fixes bug in planner which prevents from bailing out (setpoint = 0).
Also introduces events for changing setpoints in planner.
It also makes the eventtype for gaschange slightly more consistent by
changing it from SAMPLE_EVENT_GASCHANGE (O2 only) to
SAMPLE_EVENT_GASCHANGE2 (O2/He). But Subsurface treats them both the same
(the distinction comes from libdivecomputer).
Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -202,7 +202,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan) add_gas(dive, oldo2, oldhe); while (dp) { int o2 = dp->o2, he = dp->he; - int po2 = dp->po2 ? : oldpo2; + int po2 = dp->po2; int time = dp->time; int depth = dp->depth; @@ -218,11 +218,17 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan) he = oldhe; } + if (oldpo2 != po2) { + if (lasttime) + add_event(dc, lasttime, 20, 0, po2/1000, "SP change"); // SAMPLE_EVENT_PO2 + oldpo2 = po2; + } + /* Create new gas, and gas change event if necessary */ if (o2 != oldo2 || he != oldhe) { int value = (o2 / 10) | (he / 10 << 16); add_gas(dive, o2, he); - add_event(dc, lasttime, 11, 0, value, "gaschange"); + add_event(dc, lasttime, 25, 0, value, "gaschange"); // SAMPLE_EVENT_GASCHANGE2 oldo2 = o2; oldhe = he; } @@ -236,7 +242,6 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan) sample->depth.mm = depth; finish_sample(dc); lasttime = time; - oldpo2 = po2; dp = dp->next; } if (dc->samples <= 1) { |