Based on original work and code by Ryan Gardner, with some additional improvements and integration into libdivecomputer by Jef Driesen.