Commit graph

983 commits

Author SHA1 Message Date
Berthold Stoeger
f60343eebb Dive pictures: replace picture struct by QString
In imagedownloader.cpp the only thing we need from the picture struct
is the filename. Therefore, use QStrings instead of the picture struct.
This simplifies memory management.

Remove the clone_picture() function, which is not needed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
5d372cfda3 Dive pictures: turn SHashedImage class into getHashedImage() function
SHashedImage was a subclass of QImage, which fetched the image according
to the filename hashes. Turn this into a function, as this is much more
idiomatic and flexible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
e811c7306d Dive pictures: Convert thumbnailHash to individual files
On startup, convert an old-style thumbnailHash to individual
thumbnail files. Show a modal progress bar while doing so.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
6618c9ebfc Dive pictures: save thumbnails to individual files
The old code loaded all thumbnails into memory at once. This does
not scale to logs with thousands of pictures. Therefore, save
the pictures to individual files and only load the currently
needed pictures.

Currently, this will make changing switching between dives slower,
because the thumbnails are loaded from disk. In the future, it
is planned to do this in a background thread without blocking
the user interface.

A notable difference to the old code: Thumbnails are now indexed
by the image-hash (i.e. the content of the raw image) and not
by the filename of the image. Thus, different paths to the same
image should only be saved once.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Dirk Hohndel
2d253c71ff Add Qt header so Q_OS_xxx macros work
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-12 21:09:14 -07:00
Dirk Hohndel
adf3d945e1 DC transport debugging messages
Show the transport types we support for each of the supported dive computers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-12 21:09:14 -07:00
Dirk Hohndel
cef6dff762 BLE: add EON Core and Mares Bluelink to detection
Detection isn't required, but it makes things easier.  For the Mares dive
computers we only see the Bluelink, so we can't tell which dive computer is
connected to it. We guess "Quad", but the user can pick a different one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-11 22:18:19 -07:00
Dirk Hohndel
e6cb98ea4b iOS: only DC_TRANSPORT_BLE is supported
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-11 21:32:04 -07:00
Berthold Stoeger
ac1ec486ae Planner: Unify final ascent rates in plan() and fake_dc()
When generating fake profiles for manually entered dives, fake_dc() and
plan() used different final ascent rates of 5 m/min and 4.5 m/min,
respectively. This led to dives that were 6 seconds longer than entered
by the user and to confusion. See #554.

Therefore, use the same ascent rate taken from the preferences field
flag.ascratelast6m in both cases.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-07 21:17:22 +03:00
Willem Ferguson
70bb4c145b Fix CCR setpoint display bug
1) The connection for the display of CCR-setpoint o2SetpointGasItem
   was erroneous, being connected to partialpressuregasSettings. It
   is now correctly connected to technicalDetailsSettings.
2) The colour of the setpoint graph is changed from PO2_ALERT (red) to
   an orange colour in order to show setpoint in red only when it
   exceeds 1.6. This emphasises the visibility of red parts of the
   gas pressure graphs whenever gas limits are exceeed.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-07 13:56:23 +02:00
Berthold Stoeger
fc7cb09b37 Planner: Correctly fill out last_manual_time in fake_dc()
By not filling out this value, entering of manual dives was broken
for dive lengths starting with a digit 5 or higher.

Fixes #1211

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-07 13:11:53 +03:00
Berthold Stoeger
920ff15f71 Planner: don't return static data in fake_dc()
fake_dc() used to return a statically allocated dc with statically
allocated samples. This is of course a questionable practice in
the light of multi-threading / resource ownership. Once these
problems were recognized, the parameter "alloc" was added. If set
to true, the function would still return a statically allocated
dc, but heap-allocated samples, which could then be copied in
a different dc.

All in all an ownership nightmare and a recipie for disaster.
The returned static dc was only used as a pointer to the samples
anyway. There are four callers of fake_dc() and they all have access
to a dc-structure without samples. Therefore, change the semantics
of fake_dc() to fill out the passed in dc. If the caller does
not care about the samples, it can simply reset the sample number
to zero after work.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-07 13:11:53 +03:00
Robert C. Helling
d75f7474c7 When looking for gas change events only use those
This function looks for the last gas change before a
given time. We should initialize it with a gaschange
event as we might later use this event to read a
gasmix from it.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-04-29 22:50:10 +03:00
Willem Ferguson
81a812539c Plot OC-pO2 graph for SCR dives
This commit allows plotting the OC-equivalent pO2 graph for PSCR
dives. This happens in both the cases where there is no external
O2-monitoring AND when there is external pO2 monitoring. The
calculations are only done for PSCR dives and is achieved as
follows:

1) Within plot-info create a pressure-t called OC_pO2 in
   profile.h and populate this variable with the open-circuit
   pO2 values in profile.c.
2) Create a new partialPressureGasItem ocpo2GasItem in
   profilewidget2.h and, in profilewidget2.cpp, initialise it
   to read the plot-info OC_pO2 values and enable its
   display by using the setVisible method. The
   diveplotdatamodel was also touched in order to achieve
   this.
3) Create a pref button that controls the display of OC-pO2 for SCR dives
4) Change the colour of the OC-pO2 grpah to orange
5) Change the connection of the crr_OC_pO2 signal to be appropriate
6) rename the OC_pO2 attribute to scr_OC-pO2

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-04-28 20:11:22 +03:00
Dirk Hohndel
e9fd4cb7dc Android: correctly detect the different BT device types
The previous code would not add the non-LE address for dual stack
devices. Unfortunately, even with this fix we still don't get the
correct result for the dual stack Shearwater Petrel 2 that I have
for testing as Android incorrectly reports it as a BLE-only device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 16:02:17 -07:00
Dirk Hohndel
028299193a Create one function to determine the supported transports
This should make sure we create a consistent view based on all the
information available.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
5faa167e9f libdc transport debugging
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
ea7a7c6b24 QML UI: add supported dive computers to log file
In a more compact format than before.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
36749b28d9 Redesign the flow for checking supported DCs on Android
Only filter against the hard coded list if no other supported transports
are available for a dive computer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Dirk Hohndel
0cacb06d80 Use libdc information about supported transports
For example, even on platforms that support libusb, libdivecomputer
might be compiled without such support.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 11:52:48 -07:00
Linus Torvalds
901991afbe Do a better job of picking which transport to use
If the user specified bluetooth, we really should pick bluetooth, not
probe and possibly fall back to something else.

We should also honor the users choice of BLE vs classic BT.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-27 11:52:13 -07:00
Anton Lundin
fd359f5a88 Configure ostc3: Remove obsoleted setting
In firmware version 2.97 the setting 0x38, SETPOINT FALLBACK, has bin
obsoleted and we get a error when trying to write to it.

This removes this setting.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-04-27 21:33:47 +03:00
Dirk Hohndel
b930c39ead Compile fix when compiling without BLE enabled
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-25 07:56:19 -07:00
Dirk Hohndel
c5e4086820 Only offer dive computers with supported transports
On Android we still need to do more filtering as only some of the USB
divecomputers are supported. But on iOS this takes care of it without
the hard coded list.

Additionally, if built without BT or BLE support, the corresponding dive
computers are no longer shown (e.g. Perdix AI on Windows).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-24 18:02:51 -07:00
Linus Torvalds
c60d2ec3e3 use libdivecomputer 'fingerprint' to avoid downloading extra data
This opportunistically uses a cache of 'fingerprints' for already
downloaded dives.

As we download data from a dive computer, we save the fingerprint and
dive ID of the most recent dive in a per-divecopmputer fingerprint cache
file.

The next time we download from that dive computer, we will load the
cache file for that dive computer if it exists, verify that we still
have the dive that is referenced in that cachefile, and if so use the
fingerprint to let libdivecomputer potentially stop downloading dives
early.

This doesn't much matter for most dive computers, but some (like the
Scubapro G2) are not able to download one dive at a time, and need the
fingerprint to avoid doing a full dump.  That is particularly noticeable
over bluetooth, where a full dump can be very slow.

NOTE! The fingerprint cache is a separate entity from the dive log
itself.  Unlike the dive log, it doesn't synchronize over the cloud, so
if you download using different clients (say, your phone and your
laptop), the fingerprint cache entries are per device.

So you may still end up downloading dives you already have, because the
fingerprint code basically only works to avoid duplicate downloads on
the same installation.

Also, note that we only have a cache of one single entry per dive
computer and downloader, so if you download dives and then don't save
the end result, the fingerprint will now point to a dive that you don't
actually have in your dive list.  As a result, next time you download,
the fingerprint won't match any existing dive, and we'll resort to the
old non-optimized behavior.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Linus Torvalds
acc343834a Actually tie in the new libdivecomputer IO model to open the dive computer device
This creates a new libdivecomputer_device_open() helper, and makes
downloading and configuration use it to open the dive computer device
using the proper protocol.

The IRDA case was tested by Sébastien Dugué - I had initially left it
undone believing that "nobody uses IRDA".

Reported-and-tested-by: Sébastien Dugué <sebastien.dugue.subsurface@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Linus Torvalds
13f5c75ac4 Convert our custom IO model to new libdivecomputer IO model
This converts our old custom IO model to the new model that
libdivecomputer introduced.  This is partly based on Jef's rough patch
to make things build, with further work by me.

The FTDI code is temporarily disabled here, because it will need to be
integrated with the new way of opening devices.

The ble_serial code goes away entirely, since now libdivecomputer knows
about BLE transport natively, and doesn't need to have any serial
wrapper around it.

Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Berthold Stoeger
529d407933 Cleanup: Make local function waitFor() of static linkage
Moreover, remove it from the `extern "C"` block, since extern/static
is oxymoronic.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-19 15:08:12 +03:00
Berthold Stoeger
8f4604ead8 Coding style: remove superfluous semicolons
Remove a semicolon after Q_OBJECT and a few others after the closing
braces of while loops.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-19 15:08:12 +03:00
Dirk Hohndel
40755987ed Qt: don't use member function that requires Qt 5.8
This should have been caught by our build check, but it turns out that
that one isn't correctly reflected in its Travis status.

Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-15 14:46:56 -07:00
Dirk Hohndel
6a51c14365 DiveObjectHelper: expose number of dives in a trip
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 17:39:40 -07:00
Dirk Hohndel
1de4321ca1 GPS: untangle the timestamp comparison
And calculate the correct time since last fix.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:38:19 -07:00
Dirk Hohndel
ca3be8f376 GPS: add signal to show that a new fix has been acquired
This way if we don't have a current enough position we can wait for a
current fix to be acquired.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:37:44 -07:00
Dirk Hohndel
82a3d2be95 QML UI: better debug messages for getting current location
Also, show GPS refresh interval in seconds; it's confusing if this is
reported in ms.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14 13:37:44 -07:00
Dirk Hohndel
f693678235 iOS: create our own OS support file
Up until now we just reused the macos.c file for convenience, hard coding a
specific file path that may or may not work on iOS.  Instead get the preferred
path from Qt and for this we need to be able to call into Qt, so this needs to
be a C++ file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:43 -07:00
Dirk Hohndel
d931652f69 BLE debug: show more packages
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:42 -07:00
Dirk Hohndel
874cba1116 Mobile: add Mares BLE dive computers
Technically, these aren't BLE, these are just the three devices that
are supported by the Mares Bluelink Pro Bluetooth download dongle.

While we are at it, admit that this code is no longer automatically
created but instead maintained by hand.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:42 -07:00
Dirk Hohndel
d15a0bc277 Fix typos
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13 17:07:42 -07:00
Robert C. Helling
ece714556f Look for actual isobaric counter diffusion
Identify segements that fullfill the folllowing criteria for
the leading compartment:

He is off-gasing while N2 is on-gasing
Overall there is on-gasing

Add a line to the info box for those segments

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-04-11 21:15:38 +02:00
Berthold Stoeger
71d1e78db2 Cleanup: Fix memory leak in plannernotes.c
dive->notes was overwritten without free()ing the old buffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Berthold Stoeger
a4834e198d Cleanup: fix "unsave" snprintf()s in plannernotes.c
The planner notes were constructed using a sequence of
  len += snprintf(buf, buflen - len, ...);
calls. This will fail once len > buflen, because the second parameter
of snprintf is unsigned. Note that snprintf returns the number of
bytes that would have been written if it weren't truncated.

Fix this by using membuffer with put_format()/put_string() and
asprintf_loc().

Fixes #1155.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Berthold Stoeger
f7b2355ced Cleanup: unconstify results of two functions
get_dive_date_c_string() and get_current_date() return copied strings.
Make this explicit by returning non-const pointers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Berthold Stoeger
44bcc5a307 Cleanup: make local functions in core/plannernotes.c of static linkage
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-11 14:01:51 +03:00
Jeremie Guichard
5d96d4af0c Add usage documentation for membuffer helper functions
Added a comment block on top of membuffer.h describing common usage
of membuffer helper functions

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-10 08:18:32 -07:00
Berthold Stoeger
8b0055d15c Cleanup: remove unused function get_selected_dives_text()
The only caller was removed in commit c3f07b9f81.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-10 08:16:33 -07:00
Berthold Stoeger
bbacdf94e3 Cleanup: Slightly shorten code in vqasprintf_loc()
Move duplicate code, which reads '*' arguments from va_list into
parse_fmt_int() function. To pass pointers-to-va_list, the va_list
has to be copied first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-09 11:29:43 -07:00
Berthold Stoeger
5afe1a53d8 Cleanup: Move *_loc formatting functions into new format.cpp file
qthelper.cpp is already quite voluminous. Move the recently
introduced localized versions of (v)snprintf() and put_format()
into their own translation unit.

Moreover, adopt C-style semantics for asprintf_loc(). This function
will be used to remove fixed-size buffers in core/plannernotes.c.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-09 11:29:43 -07:00
Jeremie Guichard
7753352e62 Change taglist_get_tagstring to support 'unlimited' tag list size
Previous taglist_get_tagstring signature/implementation did not allow
handling of cases where inputted buffer could not contain all tags.
New implementation allocates buffer based on pre-computed size allowing to
insert all tags in the returned string.

Added get_taglist_string in qthelper to handle conversion to QString
Added TestTagList with tests for taglist_get_tagstring

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-09 07:59:51 -07:00
Miika Turkia
b28e3db7f1 Temperature 0x7F appears to mean no reading
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-07 11:33:09 -07:00
Miika Turkia
6cfbe10bc3 Handle int and float temperatures
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-07 11:33:09 -07:00