libdivecomputer: add air temperature fixups for Suunto

libdivecomputer doesn't actually seem to support air temperature
reporting at all, but at least for Suunto dive computers the air
temperature is recorded as the temperature for the first sample.

So since we already have vendor-specific libdivecomputer hacks, let's
just add that one as a rule.  It may be that other divecomputers do this
too, so this adds it as a generic concept - it's just that right now the
flag for "air temperature in first sample" is only set for Suunto dive
computers.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2013-01-22 18:15:07 -08:00 committed by Dirk Hohndel
parent acd6dff4a8
commit 9e0a316812

View file

@ -24,7 +24,7 @@
static const char *progress_bar_text = "";
static double progress_bar_fraction = 0.0;
static int stoptime, stopdepth, ndl, po2, cns;
static gboolean in_deco;
static gboolean in_deco, first_temp_is_air;
static GError *error(const char *fmt, ...)
{
@ -495,6 +495,12 @@ static int dive_cb(const unsigned char *data, unsigned int size,
if (!devdata->force_download && find_dive(&dive->dc))
return 0;
/* Various libdivecomputer interface fixups */
if (first_temp_is_air && dive->dc.samples) {
dive->airtemp = dive->dc.sample[0].temperature;
dive->dc.sample[0].temperature.mkelvin = 0;
}
dive->downloaded = TRUE;
record_dive(dive);
mark_divelist_changed(TRUE);
@ -572,6 +578,8 @@ static unsigned int fixup_suunto_versions(device_data_t *devdata, const dc_event
struct device_info *info;
unsigned int serial = devinfo->serial;
first_temp_is_air = 1;
serial = undo_libdivecomputer_suunto_nr_changes(serial);
info = create_device_info(devdata->model, devdata->deviceid);
@ -681,6 +689,7 @@ static const char *do_libdivecomputer_import(device_data_t *data)
const char *err;
import_dive_number = 0;
first_temp_is_air = 0;
data->device = NULL;
data->context = NULL;