Refactoring: Improve event_loop.

Improve the event loop architecture by making it set the divecomputer in
the constructor - using the same loop for multiple dive computers is not
intended to work.
Also change `next()` in `divemode_loop` to `at()` to make the name more
aligned with its function.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-09-03 19:48:49 +12:00 committed by bstoeger
parent 33bb39f1ca
commit ee25e8a1db
11 changed files with 28 additions and 33 deletions

View file

@ -162,7 +162,7 @@ static int tissue_at_end(struct deco_state *ds, struct dive *dive, const struct
ds->max_bottom_ceiling_pressure.mbar = ceiling_pressure.mbar;
}
divemode_t divemode = loop.next(t0.seconds + 1);
divemode_t divemode = loop.at(t0.seconds + 1);
interpolate_transition(ds, dive, t0, t1, lastdepth, sample.depth, gas, setpoint, divemode);
psample = &sample;
t0 = t1;
@ -720,7 +720,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
current_cylinder = get_cylinderid_at_time(dive, dc, sample.time);
// Find the divemode at the end of the dive
divemode_loop loop(*dc);
divemode = loop.next(bottom_time);
divemode = loop.at(bottom_time);
gas = dive->get_cylinder(current_cylinder)->gasmix;
po2 = sample.setpoint.mbar;