Add support for DC_SAMPLE_TTS - time to surface in seconds

Several dive computers support this, so why not have the proper
interface for it in libdivecomputer?

Triggered by the fact that the Python scripts to generate XML files from
the Garmin FIT files can import this information, but the native
libdivecomputer model couldn't.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2018-09-02 13:16:02 -07:00
parent f6ea5f514a
commit 86540206db
2 changed files with 13 additions and 2 deletions

View File

@ -46,9 +46,13 @@ typedef enum dc_sample_type_t {
DC_SAMPLE_PPO2,
DC_SAMPLE_CNS,
DC_SAMPLE_DECO,
DC_SAMPLE_GASMIX
DC_SAMPLE_GASMIX,
DC_SAMPLE_TTS, // time to surface in seconds
} dc_sample_type_t;
// Make it easy to test support compile-time with "#ifdef DC_SAMPLE_TTS"
#define DC_SAMPLE_TTS DC_SAMPLE_TTS
typedef enum dc_field_type_t {
DC_FIELD_DIVETIME,
DC_FIELD_MAXDEPTH,

View File

@ -399,7 +399,14 @@ DECLARE_FIELD(RECORD, next_stop_time, UINT32) // seconds
garmin->record_data.pending |= RECORD_DECO;
garmin->record_data.stop_time = data;
}
DECLARE_FIELD(RECORD, tts, UINT32) { } // seconds
DECLARE_FIELD(RECORD, tts, UINT32)
{
if (garmin->callback) {
dc_sample_value_t sample = {0};
sample.time = data;
garmin->callback(DC_SAMPLE_TTS, sample, garmin->userdata);
}
}
DECLARE_FIELD(RECORD, ndl, UINT32) // s
{
if (garmin->callback) {