Profile: Improve Display of Bailout / Loop Events.

For dives in CCR mode, show 'bailout' and 'on loop' events whenever a
gas switch from a diluent gas to a bailout gas and vice versa happens.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-09-22 23:24:25 +12:00
parent de12d3a6ea
commit 07898f277c
16 changed files with 183 additions and 121 deletions

View file

@ -200,19 +200,20 @@ void fake_dc(struct divecomputer *dc)
}
divemode_loop::divemode_loop(const struct divecomputer &dc) :
last(dc.divemode), loop("modechange", dc)
last(dc.divemode), last_time(0), loop("modechange", dc)
{
/* on first invocation, get first event (if any) */
ev = loop.next();
}
divemode_t divemode_loop::at(int time)
std::pair<divemode_t, int> divemode_loop::at(int time)
{
while (ev && ev->time.seconds <= time) {
last = static_cast<divemode_t>(ev->value);
last_time = ev->time.seconds;
ev = loop.next();
}
return last;
return std::make_pair(last, last_time);
}
/* helper function to make it easier to work with our structures