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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>