Change Uemis debug code to test for bit values

This way individual pieces can be turned on and off.
The commit also adds code to read from a disk image (instead of the SDA)
without all the long timeouts.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Improve deco handling and add NDL support

This commit changes the code that was recently introduced to deal with
deco ceilings. Instead of handling these through events we now store the
ceiling (which in reality is the deepest deco stop with all known dive
computers) and the stop time at that ceiling in the samples.

This also adds support for NDL (non stop dive limit) which both dive
computers that appear to give us ceiling / deco information appear to
give us as well (when the diver isn't in deco).

If the mouse hovers over the profile we now add support for displaying the
NDL, the current deco obligation and (if we are able to tell from the
data) whether we are at a safety stop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Support the new NDL / deco code in the Uemis downloader

This also replaces the old heuristic for when we are in deco with the
(hopefully correct) bits in the sample flags.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Improve automatic dive merging logic

This tunes the heuristics for when to merge two dives together into a
single dive. We used to just look at the date, and say "if they're
within one minute of each other, try to merge". This looks at the
actual dive data, and tries to see just how much sense it makes to
merge the dive.

It also checks if the dives to be merged use different dive computers,
and if so relaxes the one minute to five, since most people aren't
quite as OCD as I am, and don't tend to set their dive computers quite
that exactly to the same time and date.

I'm sure people can come up with other heuristics, but this should
make that easier too.

NOTE! If you have things like wrong timezones etc, and the
divecomputer dates are thus off by hours rather than by a couple of
minutes, this will still not merge them. For that kind of situation,
we'd need some kind of manual merge option. Note that that is *not*
the same as the current "merge two adjacent dives" together, which
joins two separate dives into one *longer* dive with a surface
interval in between.

That kind of manual merge UI makes sense, but is independent of this
partical change.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge trips without modifying the GTK tree

This patch does 4 small divelist.c changes in the following
order of importance:

1) In find_trip_by_time() now there is a check if a trip is actually found
before looking at the "when" flag.

2) Make remember_tree_state() slighly safer. If for example we have recently
deleted a trip from the linked list, it may still exist in the GTK tree model,
thus we want to check when calling find_trip_by_time() if there is an actual
match before setting the "expanded" flag for a trip.

3) When merging two trips in merge_trips_cb(), only use the tree model
to retrieve the timestamps (DIVE_DATE) and then find matching trips with
find_matching_trip(). Once we have pointers to the two trips to be merged,
move dives from one to another iterating with add_dive_to_trip().

4) In merge_trips_cb() - remember the tree state, repopulate the tree and
restore tree state, since now we are not adding/removing rows directly.
tesdsad

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>