From 9e0a3168121be98a56fb35e632bea9a00bb9f768 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 22 Jan 2013 18:15:07 -0800 Subject: 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 Signed-off-by: Dirk Hohndel --- libdivecomputer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libdivecomputer.c') diff --git a/libdivecomputer.c b/libdivecomputer.c index 2672fb72a..cb4789f49 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -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; -- cgit v1.2.3-70-g09d2