Start populating the maintab Dive Info widget

Establish some useful helpers and use them when updating the values.

One of the helpers (from statistics.c) puzzlingly doesn't link - so that's
ifdefed out.

Also had to re-arrange the settings reading code (it came too late) and to
extract the expanding code of the top dive from the settings reading code
(as it had no business being there to begin with).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-05-06 20:36:37 -07:00
parent 1a8239a240
commit b75a89aa86
7 changed files with 100 additions and 9 deletions

View file

@ -267,3 +267,18 @@ void get_selected_dives_text(char *buffer, int size)
}
}
volume_t get_gas_used(struct dive *dive)
{
int idx;
volume_t gas_used = { 0 };
for (idx = 0; idx < MAX_CYLINDERS; idx++) {
cylinder_t *cyl = &dive->cylinder[idx];
pressure_t start, end;
start = cyl->start.mbar ? cyl->start : cyl->sample_start;
end = cyl->end.mbar ?cyl->sample_end : cyl->sample_end;
if (start.mbar && end.mbar)
gas_used.mliter += gas_volume(cyl, start) - gas_volume(cyl, end);
}
return gas_used;
}