For dives in CCR mode, show 'bailout' and 'on loop' events whenever a
gas switch from a diluent gas to a bailout gas and vice versa happens.
Signed-off-by: Michael Keller <github@ike.ch>
In the decostop table, we had deco stops at fractional feet
(e.g. 333.33 ft). This was somewhat awkward, because the
user defined literals do not yet(?) support non-integers
and therefore, these entries were given in mm instead.
Just round to the nearest integral feet values.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit is longer than expected, because a few of the callers
were converted to use depth_t instead of int.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Also un-inline it. There seems no reason for exporting the
implementation details in the header file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function had a horrendous interface: The caller would have to
allocate two arrays of the correct size to be filled with data.
The callee couldn't even check the size, because the data was passed
as raw pointers.
Instead, use std::vector<>, construct everything in the called
function and do size-sanity check in the calling function.
Use depth_t and duration_t instead of plain integers to represent
mean depth and time.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Allow multiplication/division of unit types with scalars,
such as
depth * 4
or
depth / 4
Multiplication the other way round (4 * depth) is not currently
supported, because that needs some template trickery.
Might do this later or wait for our switch to C++20, where we
could use concepts to make that trickery more palatable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
No point in this being a macro. Make it return a depth_t - it
was unclear that this returns a depth in mm.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Calls the global interpolate() function for integer types.
For now, the template is enabled if the arguments are not
integer types. Might want to refine that in the future.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make the type the interpolate() function works on a template type,
so that this can be used for arbitrary unit types without warnings.
Internally, it does its math using floating point arithmetics anyway,
so no risk of overflow. (Exception: when just taking the middle point,
but I would hope that no part of the code lives on the edge such that
addition of two values gives an overflow.)
Moreover, add an "math.h" include so that the header becomes
independent of others.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, we can't use our unit literals, such as "3_m" in
constexpr context, for example to define them as variables
as such:
static constexpr deco_stops_multiplier = 3_m;
Declaring the respective operator""() functions as constexpr
enables this use case.
The _ft and _atm literals are left as non-constexpr, because
they use round(), which is not constexpr on our Android
compiler. Revise this later.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a drop in the ocean. Make the usage of the unit-types a
bit more consistent throughout the code base.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Avoids funky side effects. The old version would have failed
horribly for innocent invocations such as "cube(a+b)" or
"cube(++a)".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make writeToAppLogFile() take an std::string parameter to avoid
an unnecessary UTF8->UTF16->UTF8 (std::string->QString->char *)
roundtrip.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In commit 4de109bbf1, qDebug() was
replaced with report_info(). As a side effect, the subsurface log
messages are no longer redirected to the application log file. Only the
internal Qt logging ends up in the log file.
For bug reporting by end-users, this application log file is important
because it's the easiest way to collect all the necessary information to
investigate the problem.
Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
The app already supports Mares Sirius,
but user has to allow scanning for
unknown devices in app settings.
This adds Mares Sirius to known devices.
Signed-off-by: rmultan <multan.rafal.k@gmail.com>
Switch the Divesoft log file importer to use the parser in
libdivecomputer. This adds support for the newer Divesoft Freedom+ log
file format.
Also refactor the OSTCTools log file importer to share common
functionality.
Signed-off-by: Michael Keller <github@ike.ch>
Switch the Divesoft log file importer to use the parser in
libdivecomputer. This adds support for the newer Divesoft Freedom+ log
file format.
Also refactor the OSTCTools log file importer to share common
functionality.
Signed-off-by: Michael Keller <github@ike.ch>
When computing the suggested switch depth for a gas,
we should take the next stop depth above the MOD, i.e.
round down. Otherwise we can produce MOD violation warnings.
We need, however, a bit of fudge as otherwise we do not
suggest to switch to o2 at 6m.
TestPlan uses the MOD to determine the depth to switch to
Tx21/35. This happens to be 65.378m. Therefore, switching
at 66m violates the MOD, the switch should be at 63m.
This then affects the gas usage.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
A dive without events could lead to json with extra closing brackets that
prevents browsers from rendering the dive log.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously, the subtitle generation was hardcoded, making it unsuitable
if you didn't want all of the displayed values. This has been replaced
by a format string that is configurable in the settings, using predefined
tags that are replaced with the values. The default value for this has
been set to (mostly) match the currently generated subtitle string. This
also provides a good starting point for users that want to modify the string.
Signed-off-by: Victor Arvidsson <victarv@gmail.com>
The distinguished photographer shoots raw images. There is a
comprehensive library that can extract metadata and thumbnails
from these images. Let's use it if available.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fixes build failing on Debian Buster (gcc 8.3.0) with:
/build/subsurface-beta-202409160411/./core/units.h: In function 'duration_t operator""_sec(long long unsigned int)':
/build/subsurface-beta-202409160411/./core/units.h:149:48: error: could not convert '{((int32_t)sec)}' from '<brace-enclosed initializer list>' to 'duration_t'
return { .seconds = static_cast<int32_t>(sec) };
Signed-off-by: Richard Fuchs <dfx@dfx.at>
We had a pattern where doubles were converted to long with
lrint() and then down-cast to a narrower int type.
Because this is unwieldy, introduce a function encapsulating
this.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Now that we have defined addition and subtraction on unit
classes, let's use them in a few examples.
Yes, some of these are a bit pointless, because they are
of the kind
a.mbar - b.mbar => (a-b).mbar
However, these probably should be further simplified
by storing the result in a unit type.
This commit is mostly a proof-of-concept.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When adding / subtracting unit objects it is completely
irrelevant with respect to which unit the data is stored.
Why should the user know this?
Therefore add addition / subtraction functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The goal here is to add general addition and scalar multiplication
functions to the unit types.
Thereto, we need a CRTP
(https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern)
base class.
However, this breaks compound initialization, so we have to use
named initializers:
weight_t { 2000 } -> weight_t { .grams = 2000 }
The good thing is that this is exactly how these classes were
supposed to be used: make the unit explicit!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Declaring everything at the begin of the function is a K&R
disease, that makes code very hard to follow.
Remove the last assignment to gaschange_after since that is
a noop (found by Coverity).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>