Commit graph

357 commits

Author SHA1 Message Date
Lubomir I. Ivanov
e7a7bd4de2 qthelper.cpp: leave lbs rounding to QString().arg() with 'f'
The following call in weight_string():
str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);

will make values in lbs larger or equal to 40 to have no fractional
part and be rounded to nearest, while values less than 40 will have one
decimal place.

fixes #412

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 16:03:38 -07:00
Lubomir I. Ivanov
fb3ce8554c datatrak.c: don't use POSIX %m format for sscanf() in dtrak_prepare_data()
The format option "%m" doesn't work for MINGW/Windows and is reported as
an unknown conversation type and this sscanf() call would not work.

The alternative is to malloc() enough space manually - e.g.
strlen(input) + 1.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 15:56:41 -07:00
Dirk Hohndel
74bf8d5260 Android build fix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 15:46:39 -07:00
Dirk Hohndel
b14a522f4f QML UI: move BT handling into core code
This shouldn't be part of the UI (qmlmanager), but part of our
overall handling of dive computers and BT devices.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 13:55:41 -07:00
Dirk Hohndel
e7cd1785c4 QML UI: add paired BT devices as vendor
This way the user can explicitly chose which dive computer they
want to download from.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 13:55:41 -07:00
Dirk Hohndel
02d3289bbf Android BT download: hardcode UUID
While it seemed logical to use the advertized service UUID that doesn't
appear to be working - instead using this hard coded UUID seems to do
the trick. I now did a successful download from my Shearwater Petrel.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-31 22:16:25 -07:00
John Van Ostrand
40f5e2e30c Cochran import: Removed long tail of 0 depth from profile
The Cochran logs the first 10 to 20 minutes (configurable) of
surface interval in case the diver re-submerges.

Signed-off-by: John Van Ostrand <john@vanostrand.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-31 21:54:05 -07:00
John Van Ostrand
3ca1191251 Cochran import: better support for older models
Older models allowed for configuration sample frequency; This patch adds
detection of sample frequency (profile_period) for cochran log file
imports.

Signed-off-by: John Van Ostrand <john@vanostrand.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-31 21:53:00 -07:00
Dirk Hohndel
4ed6ae0dc7 Android BT: use NoSecurity for connection
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-31 11:43:18 -07:00
Dirk Hohndel
286bac6d30 Android: connect to BT via uuid instead of port
We remember the offered service uuids as we detect the device and then
try the first one - likely this needs to be fixed / tuned to pick the
right one if multiple uuids are offered.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-31 10:15:40 -07:00
Dirk Hohndel
e0771e50f1 Don't override device name when using BT
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-31 10:14:24 -07:00
Dirk Hohndel
cbe03fd88d FTDI support: add minimal debugging output
Copied the libdivecomputer macros for convenience.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 21:55:49 -07:00
Dirk Hohndel
5c4f9986fe Use magic 'ftdi' as device name on Android
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 15:05:46 -07:00
Dirk Hohndel
a568562503 QML UI: try to match BT names to known dive computers
So far this just adds data to the log.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 12:25:21 -07:00
Jan Mulder
76a38b6326 More optimal search
The linear search to determine that a just downloaded dive was already
downloaded, started from the oldest dive in the logbook. It is, however
more likely that a just downloaded dive is one of the most recently
downloaded. So, just search backwards. Just a trivial performance
improvement.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-05-29 08:57:04 -07:00
Jan Mulder
88738ede30 mobile: dive_table.preexisting not set importing from mobile
Searching why the mobile app also downloads pre existing dives, it appears
that in the mobile app, the preexisting attribute is 0, where it should be the
number of dives before the download. This is easily solved by adding the correct
setting on the download thread. This solves the issue of downloading  pre existing
dives.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-05-29 08:57:04 -07:00
Dirk Hohndel
271b4caddc Fix build error
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:21:57 -07:00
Dirk Hohndel
5a4485b63b Random whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:20 -07:00
Tomaz Canabrava
7858376727 QML UI: add the DownloadThread
For this I had to also make the DCDeviceData accessible,
and for that it needed to be a pointer.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:20 -07:00
Tomaz Canabrava
85e92597b5 Set descriptor when starting thread.
Set the descriptor when starting the thread, this removes
code from the desktop code and makes everything in sync always.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:19 -07:00
Tomaz Canabrava
09904ddff5 Extract the device_data_t into helper class
Keeping the Desktop and QML versions of Subsurface
using the same codebase will keep the code saner,
this change makes the Desktop version use the
DCDeviceData helper sturct that encapsulates
the device_data_t member for easy access on the
QML. This also helped move a bit of initializations
from the UI to the Core - and that's always good.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:19 -07:00
Tomaz Canabrava
acbe5de1cb New class DCDeviceData
this class encapsulates the device_data_t from libdivecomputer
in a way that permit us to use it on QML.
this will be needed to prepare the data for the download thread.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:19 -07:00
Tomaz Canabrava
a55efcf7d8 Move the fill_computer_list() out of widgets
fill_computer_list() creates a Qt friendly
structure that contains all of the necessary
information about dive computers and it's
devices, and it's needed both in Qml and Widgets
to allow the user to download their dives.

This patch makes it possible to use the code
in QML without duplication.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 08:07:35 -07:00
Tomaz Canabrava
dec47e11cd Separate the download thread from the widget logic
This is important to not duplicate code for the Qml
view. Now the DownloadFromDiveComputer widget is mostly
free from important code (that has been upgraded to the
core folder), and I can start coding the QML interface.

There are still a few functions on the desktop widget
that will die so I can call them via the QML code later.

I also touched the location of a few globals (please, let's
stop using those) - because it was declared on the
desktop code and being used in the core.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:53:14 -07:00
Dirk Hohndel
6bfd20a014 Whitespace and warning fixes for cochran.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:37:58 -07:00
John Van Ostrand
f604089ae3 Added support for older Cochran models that have configurable sample intervals.
Corrected problem where dive profiles would include post dive
surface interval samples.

Added detection for corrupt dives.

Signed-off-by: John Van Ostrand <john@vanostrand.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:22:14 -07:00
Dirk Hohndel
c6bc88b50d Fix some warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:21:37 -07:00
Robert C. Helling
0cf8ef6e2d Adopt O2 and He densities to 20degC
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:52:04 -07:00
Robert C. Helling
05a7fe1d40 Gas denisity display improvement
This combines the display with EADD since this is the same
value with a different unit. And show it for air dives as
well.

Suggested by Jan Mulder & Anton Lundin

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:52:04 -07:00
Robert C. Helling
98a65b7157 Display gas density instead of SAC in planner
In the planner, the SAC is prescribed, so there is little
use in plotting it (as the color of the cylinder pressure
line). Rather use the color to show the density of breathing
gas.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:52:04 -07:00
Robert C. Helling
bb6ceba4ac Compute and display gas density
This appears to be critical for work of breathing so it might be
worthwhile to compute. So far only in infobox.

For background, see

https://www.youtube.com/watch?v=QBajM3xmOtc

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:52:04 -07:00
Stefan Fuchs
e6d884cf26 Creation of dive duration string and surface interval string
Update the function to create the dive duration string in a way that
it can be used also in info and stats tab and added some more flexibility.

Changed layout for <1h freedives to "0:05:35" (w/o units) or "5:35min"
(with units and :) or "5min 35sec" (with units with space).

Add a new function to create the surface interval string.

Completely remove old function get_time_string() and get_time_string_s().

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-26 15:50:52 -07:00
Robert C. Helling
7b18be2a50 Adopt planner state caching to new struct
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07:00
Robert C. Helling
57ee5a5477 Assemble global state of planner in a struct
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07:00
Robert C. Helling
b1ccd2fc43 Move planner notes to separate file
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07:00
Miika Turkia
ccf916344b Include some extradata info on Seabear import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 21:36:50 -07:00
Dirk Hohndel
d7cf3408e5 Merge branch 'seabear-refactor'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-07 07:52:55 -07:00
Salvador Cuñat
75762e5f16 Datatrak import rework: Add another memory size ckeck
As a last minute addition, and for peace of mind and soul, add just
another size check, to run before reading values from buffer.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-05-07 07:48:12 -07:00
Salvador Cuñat
47dcc964b8 Datatrak import rework: main functions
datatrak_import() is the main function called from parse_file(), but
dt_dive_parser() is where the hard work is done, for both, drop file
seeking/reading and use memory pointers instead.

datatrak_import() now returns 0 on success or 1 on failure and abort
import if parser function fails instead of keeping on trying.

dt_dive_parser() emits a warning if libdc_model is zero (manual dives).
Do not parse profiles if libdc_model is zero, for unknown models we set
a fake 0xEE value coverted to Aladin Air X/Z libdc model number. Func
now takes a pointer to a buffer and moves along the dive, when done
returns a pointer to the actual memory position or NULL if something
went wrong.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-05-07 07:48:12 -07:00
Salvador Cuñat
618cd3fab4 Datatrak import rework: modify parsing macros
Change how parsing macros work to use memory pointers instead of file
descriptors.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-05-07 07:48:12 -07:00
Salvador Cuñat
ceb54e6e9e Datatrak import rework: changes on helper funcs
Remove dtrak_profile() profile parsing func as this work is left to
libdivecomputer.
Simplifies read_file_header() to return the number of dives in the log
file as we don't use the rest of header data.
Add dtrak_prepare_data() to achieve a device_data_t structure and get
the correct libdc model number for the device.
Remove checking macro substituted with JUMP in header file.
Add dt_libdc_buffer() to get a buffer parseable with libdivecomputer.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-05-07 07:48:12 -07:00
Salvador Cuñat
22f07f5ada Datatrak import rework: initial changes
Remove dtrakheader structure. In the end, we only make use of the number
of dives in the log file.

Define a models_table_t table which strores the known Uwatec's Aladin
models and its equivalence with libdivecomputer known models.

Add a macro to check that movements in memblock buffer don't get out of
the allocated memory.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-05-07 07:48:12 -07:00
Salvador Cuñat
25cec35d24 Datatrak import rework: changes of file.c and file.h
Datatrak import is called from parse_file() in file.c. This function
reads the full file to be imported into a memblock structure. It's
easier and more secure, to parse this buffer instead of the file itself.

These are the necessary changes in function datatrak_import()
declaration and call.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-05-07 07:48:12 -07:00
Miika Turkia
c832973df5 Fix NDL and TTS for Seabear import
Apparently the refactoring changed these values to be returned directly
in seconds. Not sure why, but luckily we have test cases that discovered
the change.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 16:27:41 +03:00
Miika Turkia
d851549d9c Remove debug output
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 16:00:52 +03:00
Miika Turkia
221f67206b Make parsing of Seabear header more robust
This should work even if some header line is missing from some DC.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 15:53:35 +03:00
Miika Turkia
6e1c00078d Add dive mode support for Seabear import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 15:34:27 +03:00
Miika Turkia
cef56c6290 Import dive number from Seabear CSV file
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 14:19:58 +03:00
Miika Turkia
0dfa448d8c Refactor Seabear import
Moving the GUI independent Seabear import functionality to Subsurface
core. This will allow Robert to call it directly from download from DC.

Tested with H3 against released and daily versions of Subsurface. The
result differs somewhat, but it is actually fixing 2 bugs:
- Temperature was mis-interpreted previously
- Sample interval for a dive with 1 second interval was parsed
  incorrectly

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 13:53:52 +03:00
Miika Turkia
ab1813a445 Move intdup to qthelper
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 09:41:27 +03:00