-/*
- * Return air usage (in liters).
- */
-static double calculate_airuse(struct dive *dive)
-{
- double airuse = 0;
- int i;
-
- for (i = 0; i < MAX_CYLINDERS; i++) {
- cylinder_t *cyl = dive->cylinder + i;
- int size = cyl->type.size.mliter;
- double kilo_atm;
-
- if (!size)
- continue;
-
- kilo_atm = (cyl->start.mbar - cyl->end.mbar) / 1013250.0;
-
- /* Liters of air at 1 atm == milliliters at 1k atm*/
- airuse += kilo_atm * size;
- }
- return airuse;
-}
-
-static void plot_info(struct dive *dive, struct graphics_context *gc)
-{
- text_render_options_t tro = {10, 0.2, 1.0, 0.2, RIGHT, BOTTOM};
- const double liters_per_cuft = 28.317;
- const char *unit, *desc;
- double airuse;
-
- airuse = calculate_airuse(dive);
- if (!airuse)
- return;
-
- /* I really need to start addign some unit setting thing */
- switch (output_units.volume) {
- case LITER:
- unit = "l";
- break;
- case CUFT:
- unit = "cuft";
- airuse /= liters_per_cuft;
- break;
- }
- tro.vpos = -1.0;
- plot_text(gc, &tro, 0.98, 0.98, "vol: %4.2f %s", airuse, unit);
-
- tro.vpos = -2.2;
- if (dive->duration.seconds) {
- double pressure = 1 + (dive->meandepth.mm / 10000.0);
- double sac = airuse / pressure * 60 / dive->duration.seconds;
- plot_text(gc, &tro, 0.98, 0.98, "SAC: %4.2f %s/min", sac, unit);
- }
-
- tro.vpos = -3.4;
- desc = dive->cylinder[0].type.description;
- if (desc || dive->cylinder[0].gasmix.o2.permille) {
- int o2 = dive->cylinder[0].gasmix.o2.permille / 10;
- if (!desc)
- desc = "";
- if (!o2)
- o2 = 21;
- plot_text(gc, &tro, 0.98, 0.98, "%s (%d%%)", desc, o2);
- }
-}
-