C API¶
C Code Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <stdio.h>
#include <stdlib.h>
#include <deco.h>
int main() {
deco_conf_t *conf;
deco_profile_t *profile;
deco_info_t *info;
deco_stop_t stop;
int r, i;
conf = deco_conf_new();
if (!conf) {
printf("%s\n", deco_error(deco_errno));
return(-1);
}
conf->gf_low = 20;
profile = calloc(1, sizeof(deco_profile_t));
r = deco_segment_add(profile, 45, 30); // 45m for 25min
r = deco_gas_add(conf, 0, 27, 0); // add EAN29
r = deco_gas_add(conf, 22, 50, 0); // add EAN50 to be used at 22m
info = deco_calculate(profile, conf);
if (!info) {
printf("%s\n", deco_error(deco_errno));
return(-1);
}
for (i = 0; i < info->n_stops; i++) {
stop = info->stops[i];
printf("%dm %dmin\n", stop.depth, stop.time);
}
deco_free(profile, conf, info);
}
/* vim: sw=4:et:ai */
|
API Documentation¶
DefinesFunctionsDECO_ERROR_OK
DECO_ERROR_MEMORY
DECO_ERROR_NO_FEATURE
DECO_ERROR_MAX_DEPTH
DECO_ERROR_GAS_NUMBER
DECO_ERROR_SETPOINT_NUMBER
VariablesCalculate decompression information.
int deco_segment_add(deco_profile_t * profile, unsigned char depth, unsigned int time)Add dive profile segment to dive profile.
int deco_gas_add(deco_conf_t * conf, unsigned char depth, unsigned char o2, unsigned char he)Add gas mix to dive configuration.
int deco_setpoint_add(deco_conf_t * conf, unsigned char depth, float ppO2)Add setpoint to dive configuration.
deco_conf_t * deco_conf_new()Create new dive configuration with air in gas list.
void deco_set_altitude(deco_conf_t * conf, unsigned short altitude)Set altitude for decompression calculations.
The pressure of the deco configuration structure is updated.
Free libdeco memory.
char * deco_error(const int errno)Return libdeco error message.
unsigned int deco_errno
class deco_profile_segment_t
Dive profile segment.
Public Membersunsigned char depth
Planned dive bottom time.
unsigned int time
Planned dive time at depth.
class deco_profile_t
Dive plan profile information.
Public Membersunsigned char n_segments
Amount of dive profile segments.
deco_profile_segment_t * segments
Dive profile segments.
class deco_setpoint_t
CCR setpoint information.
Public Membersunsigned char depth
Depth at which setpoint is on.
float ppO2
The ppO2 of the setpoint.
class deco_gas_mix_t
Gas mix information.
Public Membersunsigned char depth
Depth at which gas is to be used.
unsigned char o2
O2 perecentage.
unsigned char he
Helium percentage.
class deco_conf_t
Dive plan configuration.
Public Membersunsigned char gf_low
Gradient factor low.
unsigned char gf_high
Gradient factor high.
unsigned short pressure
Surface pressure before dive in mbar.
unsigned char last_stop
Last deco stop, i.e. 3m or 6m.
unsigned char n_setpoints
CCR setpoint number.
deco_setpoint_t * setpoints
CCR setpoint information.
unsigned char n_gas_mixes
Amount of gas mixes.
deco_gas_mix_t * gas_list
List of gas mixes.
class deco_stop_t
Deco stop information.
Public Membersunsigned char depth
unsigned short time
class deco_info_t
Decompression information.
Public Membersunsigned short ndl
NDL in minutes (from the start of a dive).
unsigned char n_stops
Amount of deco stops.
deco_stop_t * stops
List of deco stops.