Fixing SP handling in planner, adding event

Fixing the SP change event and introducing a bailout scenario.

I decided not to use a event showing SP=0.0 nor using a gaschange event as
is in fact there is no gas change related to bailing out itself. If there
is also a gaschange for the event it will be displayed anyway.

Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Jan Schubert 2013-02-02 18:40:29 +01:00 committed by Dirk Hohndel
parent 057253c4eb
commit 59cfa5c427
2 changed files with 10 additions and 5 deletions

View file

@ -218,9 +218,10 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan)
he = oldhe; he = oldhe;
} }
/* Check for SetPoint change */
if (oldpo2 != po2) { if (oldpo2 != po2) {
if (lasttime) if (lasttime)
add_event(dc, lasttime, 20, 0, po2/1000, "SP change"); // SAMPLE_EVENT_PO2 add_event(dc, lasttime, 20, 0, po2, "SP change"); // SAMPLE_EVENT_PO2
oldpo2 = po2; oldpo2 = po2;
} }

View file

@ -391,19 +391,23 @@ static void plot_one_event(struct graphics_context *gc, struct plot_info *pi, st
unsigned int he = event->value >> 16; unsigned int he = event->value >> 16;
unsigned int o2 = event->value & 0xffff; unsigned int o2 = event->value & 0xffff;
if (he) { if (he) {
snprintf(buffer, sizeof(buffer), "%s: (%u/%u)", snprintf(buffer, sizeof(buffer), "%s:%u/%u",
_(event->name), o2, he); _(event->name), o2, he);
} else { } else {
if (o2 == 21) if (o2 == 21)
snprintf(buffer, sizeof(buffer), "%s: %s", snprintf(buffer, sizeof(buffer), "%s:%s",
_(event->name), _("air")); _(event->name), _("air"));
else else
snprintf(buffer, sizeof(buffer), "%s: %u%% %s", snprintf(buffer, sizeof(buffer), "%s:%u%% %s",
_(event->name), o2, "O" UTF8_SUBSCRIPT_2); _(event->name), o2, "O" UTF8_SUBSCRIPT_2);
} }
} else if (event->name && !strcmp(event->name, "SP change")) {
snprintf(buffer, sizeof(buffer), "%s:%0.1f", _(event->name), (double) event->value / 1000);
} else { } else {
snprintf(buffer, sizeof(buffer), "%s: %d", _(event->name), event->value); snprintf(buffer, sizeof(buffer), "%s:%d", _(event->name), event->value);
} }
} else if (event->name && !strcmp(event->name, "SP change")) {
snprintf(buffer, sizeof(buffer), "Bailing out to OC");
} else { } else {
snprintf(buffer, sizeof(buffer), "%s%s", _(event->name), snprintf(buffer, sizeof(buffer), "%s%s", _(event->name),
event->flags == SAMPLE_FLAGS_BEGIN ? " begin" : event->flags == SAMPLE_FLAGS_BEGIN ? " begin" :