aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2018-05-14Simplify the bailout detection functions.Gravatar Willem Ferguson
Function peek_next_divemodechange() is redundant if get_next_divemodechange() has one additional parameter. Calls to get_next_divemodechange() were updated in divelist.c, plannernotes.c and profile.c. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Simplify bailout events in the dive logGravatar Willem Ferguson
I removed the special event type that has been used for bailout events. Bailout events are now just bookmarks with a specific name "e.g. OC, CCR, PSCR). This removes a case where a segmentation error occurred when trying to remove a bailout event from the dive profile. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Implement bailout outside of the dive plannerGravatar Willem Ferguson
This is the second step for implementing bailout. The indirect calls to fill_pressures through add_segment() (in deco.c) are addressed. Bailout is now fully implemented in the dive log but not in the dive planner. 1) The parameters to add_segment() are changed to take a divemode as the second last parameter, and not a *dive. 2) Call to add_segment() in profile.c and in divelist.c are adapted. In divelist.c some calls to add_segment were left using dc-> divemode instead of possible bailout. This appears tp be the most appropriate route. 3) The functions get_divemode_from_time() and get_next_divemodechange() in dive.c have had some small changes. 4) The calls to get_segment(0 in planner.c were changed to reflect the new parameter list, but not updated to reflect bailout. This is the next step. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Incorporate bailout events in CCR & PSCR gas calculations.Gravatar Willem Ferguson
This is a first step to interpret bailout events. 1) The event structures have a new attribute: divemode. Currently interpreted dive modes are OC, CCR, PSCR. 2) When doing fill_pressures(), the calculation is aware of divemode. When divemode is OC (==bailout), then the appropriate calculations of gas pressures are done. 3) Two new functions get_next_divemodechange() and get_divemode_at_time() are created to find divemode changes in the events linked list and to determine the dive mode at any point during the dive. 4) fill_pressures gets a small amendment to facilitate the correct calculations, depending on divemode. The cases where fill_pressures() is used *outside the planner* are changed. The result is that, for dives with bailout, the correct gas pressures are shown on the dive profile. The deco for bailout dives is not yet correct. This is the next step. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Core: don't inline rarely used functionGravatar Dirk Hohndel
This is only used by one caller and there doesn't appear to be a reason to inline it in the first place. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14Android: build fixGravatar Dirk Hohndel
On other OSs this compiles fine without adding this header, but Android is special... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14Core: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14Small whitespace cleanupGravatar Dirk Hohndel
Stumbled across this when Qt Creator re-saved the file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-13Dive pictures: refactor image downloaderGravatar Berthold Stoeger
Instead of generating one ImageDownloader object per image to be downloaded and running every image download in a separate worker thread, use one global ImageDownloader object owned by the UI thread. The images are downloaded using event based IO (as probably was the intention of the QNetworkManager class). User-visible change: after download from the internet, the thumbnail is shown without having to change dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Import camera iconGravatar Berthold Stoeger
Import a camera icon from the KDE breeze theme, which is licensed under the LGPL. Use this icon to display not-yet-loaded images in the photos tab and the profile. Source: https://github.com/KDE/breeze-icons Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Move thumbnail-size to Thumbnailer classGravatar Berthold Stoeger
The size of the to-be-created thumbnails was passed from DivePictureModel to Thumbnailer. This became more and more bothersome, because the size had to be stored with the request. Calling from Thumbnailer into DivePictureModel was not an option, since this is not linked to all tests. Therefore, move these functions to the Thumbnailer class. Since the maximum thumbnail size is now known to the thumbnailer, the dummy and failure images can be precalculated, which makes switching between dives faster. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Introduce thumbnailer classGravatar Berthold Stoeger
Create a new class, which performs all thumbnailing code. This is mostly code reshuffling. Thumbnails are extracted either from a cache or thumbnail calculation is started in a worker thread. Since getHashedImage() is called from a worker thread it makes no sense to call subfunctions in yet another worker thread. Remove these calls. In contrast to the previous code, on error the background thread produces a failure image, but it is not yet shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: replace picture struct by QStringGravatar Berthold Stoeger
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-13Dive pictures: turn SHashedImage class into getHashedImage() functionGravatar Berthold Stoeger
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-13Dive pictures: Convert thumbnailHash to individual filesGravatar Berthold Stoeger
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-13Dive pictures: save thumbnails to individual filesGravatar Berthold Stoeger
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-12Add Qt header so Q_OS_xxx macros workGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-12DC transport debugging messagesGravatar Dirk Hohndel
Show the transport types we support for each of the supported dive computers. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-11BLE: add EON Core and Mares Bluelink to detectionGravatar Dirk Hohndel
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-11iOS: only DC_TRANSPORT_BLE is supportedGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-07Planner: Unify final ascent rates in plan() and fake_dc()Gravatar Berthold Stoeger
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-07Fix CCR setpoint display bugGravatar Willem Ferguson
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-07Planner: Correctly fill out last_manual_time in fake_dc()Gravatar Berthold Stoeger
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-07Planner: don't return static data in fake_dc()Gravatar Berthold Stoeger
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-04-29When looking for gas change events only use thoseGravatar Robert C. Helling
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-28Plot OC-pO2 graph for SCR divesGravatar Willem Ferguson
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-27Android: correctly detect the different BT device typesGravatar Dirk Hohndel
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-27Create one function to determine the supported transportsGravatar Dirk Hohndel
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-27libdc transport debuggingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27QML UI: add supported dive computers to log fileGravatar Dirk Hohndel
In a more compact format than before. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27Redesign the flow for checking supported DCs on AndroidGravatar Dirk Hohndel
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-27Use libdc information about supported transportsGravatar Dirk Hohndel
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-27Do a better job of picking which transport to useGravatar Linus Torvalds
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-27Configure ostc3: Remove obsoleted settingGravatar Anton Lundin
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-25Compile fix when compiling without BLE enabledGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-24Only offer dive computers with supported transportsGravatar Dirk Hohndel
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-24use libdivecomputer 'fingerprint' to avoid downloading extra dataGravatar Linus Torvalds
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-24Actually tie in the new libdivecomputer IO model to open the dive computer ↵Gravatar Linus Torvalds
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-24Convert our custom IO model to new libdivecomputer IO modelGravatar Linus Torvalds
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-19Cleanup: Make local function waitFor() of static linkageGravatar Berthold Stoeger
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-19Coding style: remove superfluous semicolonsGravatar Berthold Stoeger
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-15Qt: don't use member function that requires Qt 5.8Gravatar Dirk Hohndel
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-14DiveObjectHelper: expose number of dives in a tripGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14GPS: untangle the timestamp comparisonGravatar Dirk Hohndel
And calculate the correct time since last fix. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14GPS: add signal to show that a new fix has been acquiredGravatar Dirk Hohndel
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-14QML UI: better debug messages for getting current locationGravatar Dirk Hohndel
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-13iOS: create our own OS support fileGravatar Dirk Hohndel
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-13BLE debug: show more packagesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-13Mobile: add Mares BLE dive computersGravatar Dirk Hohndel
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>