return deg;
}
+double get_volume_units(unsigned int ml, int *frac, const char **units)
+{
+ int decimals;
+ double vol;
+ const char *unit;
+
+ switch (output_units.volume) {
+ case LITER:
+ vol = ml / 1000.0;
+ unit = "l";
+ decimals = 1;
+ break;
+ case CUFT:
+ vol = ml_to_cuft(ml);
+ unit = "cuft";
+ decimals = 2;
+ break;
+ }
+ if (frac)
+ *frac = decimals;
+ if (units)
+ *units = unit;
+ return vol;
+}
+
double get_depth_units(unsigned int mm, int *frac, const char **units)
{
int decimals;
} cylinder_t;
extern double get_depth_units(unsigned int mm, int *frac, const char **units);
+extern double get_volume_units(unsigned int mm, int *frac, const char **units);
extern double get_temp_units(unsigned int mm, const char **units);
+static inline double ml_to_cuft(int ml)
+{
+ return ml / 28317.0;
+}
+
static inline double mm_to_feet(int mm)
{
return mm * 0.00328084;
depth_t visibility;
temperature_t airtemp, watertemp;
cylinder_t cylinder[MAX_CYLINDERS];
- int otu;
+ int sac, otu;
struct event *events;
int samples, alloc_samples;
struct sample sample[];
return airuse;
}
-static void get_sac(struct dive *dive, int *val)
+static int calculate_sac(struct dive *dive)
{
double airuse, pressure, sac;
- *val = 0;
airuse = calculate_airuse(dive);
if (!airuse)
- return;
+ return 0;
if (!dive->duration.seconds)
- return;
+ return 0;
/* Mean pressure in atm: 1 atm per 10m */
pressure = 1 + (dive->meandepth.mm / 10000.0);
sac = airuse / pressure * 60 / dive->duration.seconds;
/* milliliters per minute.. */
- *val = sac * 1000;
+ return sac * 1000;
}
static void get_string(char **str, const char *s)
GtkTreeModel *model,
GtkTreeIter *iter)
{
- int sac;
char *location, *cylinder;
get_cylinder(dive, &cylinder);
get_location(dive, &location);
- get_sac(dive, &sac);
/*
* We only set the fields that changed: the strings.
DIVE_NR, dive->number,
DIVE_LOCATION, location,
DIVE_CYLINDER, cylinder,
- DIVE_SAC, sac,
+ DIVE_SAC, dive->sac,
DIVE_OTU, dive->otu,
-1);
}
struct dive *dive = dive_table.dives[i];
dive->otu = calculate_otu(dive);
+ dive->sac = calculate_sac(dive);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
DIVE_INDEX, i,