Next step to using gasmix instead of o2/he

This changes the divedatapoints and functions that deal with them.

It changes plan_add_segment(), create_dp(), gasToStr(), and tankInUse() to
consume gasmix instead of o2/he.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-06-01 15:25:19 -07:00
parent 2bf46381a8
commit fe773241ee
5 changed files with 58 additions and 61 deletions

13
dive.h
View file

@ -113,6 +113,11 @@ static inline bool is_air(int o2, int he)
return (he == 0) && (o2 == 0 || ((o2 >= O2_IN_AIR - 1) && (o2 <= O2_IN_AIR + 1)));
}
static inline bool gasmix_is_air(const struct gasmix *gasmix)
{
return is_air(gasmix->o2.permille, gasmix->he.permille);
}
/* Linear interpolation between 'a' and 'b', when we are 'part'way into the 'whole' distance from a to b */
static inline int interpolate(int a, int b, int part, int whole)
{
@ -626,11 +631,11 @@ extern void set_gf(short gflow, short gfhigh, bool gf_low_at_maxdepth);
extern void cache_deco_state(double, char **datap);
extern double restore_deco_state(char *data);
/* this should be converted to use our types */
struct divedatapoint {
int time;
unsigned int depth;
int o2;
int he;
struct gasmix gasmix;
int po2;
bool entered;
struct divedatapoint *next;
@ -646,9 +651,9 @@ struct diveplan {
struct divedatapoint *dp;
};
struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int o2, int he, int po2, bool entered);
struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, struct gasmix gasmix, int po2, bool entered);
void get_gas_string(int o2, int he, char *buf, int len);
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
struct divedatapoint *create_dp(int time_incr, int depth, struct gasmix gasmix, int po2);
#if DEBUG_PLAN
void dump_plan(struct diveplan *diveplan);
#endif