This library provides a compact Bühlmann ZHL-16C decompression model API for DIY dive computers.
- Supports both closed circuit (fixed PPO2 setpoint) and open circuit (fixed FiO2)
- Air diluent, not considering helium penalty
- Ascent rate 9 m/min
- Stops in 3 m intervals, last stop at 3 m
- No prior dives, single dive day
- Diving from sea level
- Stop time and TTS are rounded up to full minute
- Everything is metric
- Input ambient pressure in atm (float) from pressure sensor reading
- Input dive time in minutes (float)
Configures gradient factors and the CCR oxygen setpoint.- gfLowPercent: integer percent, must be > 0 and < gfHighPercent.
gfHighPercent: integer percent, must be<= 100po2Setpoint: float, must be> 0- Returns
truewhen the configuration is accepted - If no valid input, model defaults to GF 60/85 and setpoint 1.2
Configures gradient factors and open-circuit gas.
gfLowPercent: integer percent, must be> 0and< gfHighPercentgfHighPercent: integer percent, must be<= 100fiO2: oxygen fraction as float, must be>= 0and<= 1- Returns
truewhen the configuration is accepted - If no valid input, model defaults to GF 60/85 and FiO2 0.2098 (air)
Initialises all tissue compartments to surface equilibrium.
Call after decoSetup() at startup or at the begining of the dive.
Updates tissue compartments for dive time at ambient pressure.
pressureAtm: ambient pressure in atmdtMin: dive time in minutes
Call this regularly in control loop, e.g. every second.
Computes current decompression output.
currentPressureAtm: ambient pressure in atm- Returns
DecoResult:bool inDeco:true= mandatory decompression,false= in NDLu_int16_t nextStopDepth: depth of next stop in meters, round to deeper 3 m intervalu_int16_t stopTime: time at next stop in minutes, round up to full minuteu_int16_t timeToSurface: total time to surface in minutes, including ascent time and stopsu_int16_t surfGF: gradient factor in percent expected if instantaneously surfaced
Call this when decompression needs to be calculated, e.g. every 10 seconds.
Disable or enable gradient factor.
false: normal decompression behavior, with conservatism by pre-set gradient factorstrue: ignore GF settings and force 100% GF (removes all conservatism, raw Bühlmann ZHL-16C algorithm)
Default to false. Can be called in the middle of a dive if you find deco boring and want to ride the M-value train
Sets a new CCR setpoint (> 0) and switches gas model to CCR mode.
Sets a new OC gas FiO2 (>= 0 and <= 1) and switches gas model to OC mode.
Query current gas model settings.
- Call
decoSetupCC(gfLowPercent, gfHighPercent, po2Setpoint)for CCR ordecoSetupOC(gfLowPercent, gfHighPercent, fiO2)for OC insetup() - Call
decoInit()once right after - Call
decoUpdate(pressureAtm, dtMin)inloop() - Call
decoCompute(pressureAtm)at your display/log interval - Use fields in
DecoResultto get Deco, Stop, Time, TTS, surfGF - Toggle
ripNtear(true)to see decompression result at raw M-value