25 Commits

Author SHA1 Message Date
Michael Keller
d37cb91734 Merge remote-tracking branch 'libdivecomputer/master' into update_libdivecomputer_202402 2024-02-02 17:40:41 +13:00
Michael Keller
58ea31e62e Cressi Leonardo: Turn ascent warnings into info events.
According to user feedback the ascent warnings on the Cressi Leonardo
are very sensitive. They come in 3 different levels.
This change turns levels 1 and 2 into info events, leaving only 3 as a
warning.
Fixes https://groups.google.com/g/subsurface-divelog/c/qBXF0wmyjKg/m/5qA0_KABCQAJ

Signed-off-by: Michael Keller <github@ike.ch>
2023-07-28 00:02:14 +12:00
Jef Driesen
63f5a4d652 Remove the dc_parser_set_data function
The dc_parser_set_data() function allows to re-use a parser object for
multiple dives. The advantages of this feature are actually very limited
in practice. The reduction in memory consumption is almost negligible,
because the amount of internal state in the parser is typically very
small. But the implementation requires some additional complexity
because each backend needs code to reset its internal state. Therefore,
the function is removed and the data and size needs to be passed
directly to the dc_parser_new() and dc_parser_new2() functions instead.

Because keeping a reference to the data has also caused issues in the
past, especially for applications implemented in a garbage collected
language, the data will now also get copied internally.
2023-05-15 22:19:37 +02:00
Jef Driesen
4e24b3a277 Pass the sample struct by reference
Because the sample struct is passed by value, the size of the structure
can't be changed without also changing the function signature and
breaking backwards compatibility. This prevents adding new fields in the
future, to support some new features.

When passing the sample struct by reference using a pointer, the size of
the pointer does always remains the same.
2023-05-15 22:19:36 +02:00
Jef Driesen
becb8bd36e Add a usage field to the tank and gas mix
For gas consumption calculations it's very convenient to know whether a
tank is used for example in a sidemount configuration, or as
oxygen/diluent tank on a rebreather.

For rebreather dives, it's convenient to know whether a gas mix is used
as a closed-circuit mix (oxygen/diluent) or as an open circuit mix
(bailout).
2023-05-15 22:19:36 +02:00
Jef Driesen
a34e909a84 Change the units for the sample time to milliseconds
Some dive computers, especially freediving computers, supports multiple
samples per second. Since our smallest unit of time is one second, we
can't represent this, and the extra samples are dropped. Therefore, the
units are changed to milliseconds to prepare supporting this extra
resolution.
2023-05-15 22:19:34 +02:00
Jef Driesen
12c77a228e Add a public api to configure the clock synchronization
For dive computers where the reference time (epoch) of the device is
unknown, libdivecomputer uses the current time of the device (devtime)
and the host system (systime) to synchronize both clocks.

Currently, both timestamps are passed directly to the constructor of the
parser. With the new public function, the application can adjust the
timestamps afterwards.
2022-08-11 17:36:26 +02:00
Jef Driesen
6ab140461a Add a public api to configure the depth calibration
Some dive computers store the depth as an absolute pressure value (in
bar). To convert to a depth value (in meters), the atmospheric pressure
and water density are required. For dive computers that do not have
those values available, libdivecomputer uses a default value. With the
new public api functions, applications can adjust those default values.

Some dive computers already provided a backend specific calibration
function. Those functions are now deprecated. They are kept around to
maintain backwards compatibility for now, but they will be removed in
the next version.
2022-08-11 17:36:15 +02:00
Jef Driesen
9ff6e5caad Remove the initial gas switch
The Cressi Drake is a freedive computer and does not support gas
switches.
2021-10-13 11:06:26 +02:00
Jef Driesen
156f54302d Add basic timezone support
Allthough most dive computers always use local time and don't support
timezones at all, there are a few exceptions. There are two different
sources of timezone information:

 - Some of the newer Uwatec/Scubapro devices use UTC internally and also
   support a timezone setting. This UTC offset is currently taken into
   account to obtain the dive date/time, but the UTC offset itself is
   lost.

 - Uwatec/Scubapro and Reefnet devices rely on the clock of the host
   system to synchronize the internal device clock and calculate the
   dive date/time. The consequence is that the resulting date/time is
   always in the timezone of the host system.

In order to preserve this timezone information, the dc_datetime_t
structure is extended with a new "timezone" field, containing the UTC
offset in seconds. Devices without timezone support will set the field
to the special value DC_TIMEZONE_NONE.

The dc_datetime_localtime() and dc_datetime_gmtime() functions will
automatically populate the new field with respectively the local
timezone offset and zero. The dc_datetime_mktime() function will take
into account the new timezone field for the conversion to UTC. The
special value DC_TIMEZONE_NONE is interpreted as zero.
2017-08-18 23:26:45 +02:00
Jef Driesen
535d612a93 Use the correct type in the leonardo vtable 2017-08-02 09:19:03 +02:00
Jef Driesen
c5f089b4a6 Remove unnecessary helper functions
The second variant of the open or create functions were introduced to
maintain backwards compatibility. But after being removed from the
public api, these functions serve no purpose anymore, and can be removed
completely.
2017-04-19 11:33:17 +02:00
Jef Driesen
d1a06e784c Remove deprecated functions from the public api
The vendor_product_parser_create() and vendor_product_device_open()
functions should be called indirectly, through the generic
dc_device_open() and dc_parser_new() functions. And the
vendor_product_extract_dives() functions are internal functions that
should never have been part of the public api in the first place.
2017-04-18 08:41:10 +02:00
Jef Driesen
ae954af768 Parse the sample interval correctly
The Cressi Drake supports a sample interval of 1, 2, 3 and 4 seconds.
2017-01-23 08:40:00 +01:00
Jef Driesen
07dcc8998b Add support for the Cressi Drake
The Cressi Drake is a mainly a freedive computer. The data format is
almost identical to the Leonardo. The main difference is that a single
dive now contains an entire freedive session. Each freedive in the
session is delimited with a 4 byte header containing the surface
interval and a special marker.
2016-12-30 22:25:14 +01:00
Jef Driesen
390b5fe553 Report the initial gas mix on the first sample
For dives with multiple gas mixes, an application doesn't have enough
info to figure out which one is the initial gas mix. Usually it's the
first gas mix, but that's not guaranteed. Reporting the intial gas mix
on the first sample avoids this problem.
2016-11-04 19:26:21 +01:00
Jef Driesen
ff29d218bb Use helper functions to allocate and free objects.
Both the allocation and initialization of the object data structure is
now moved to a single function. The corresponding deallocation function
is intended to free objects that have been allocated, but are not fully
initialized yet. The public cleanup function shouldn't be used in such
case, because it may try to release resources that haven't been
initialized yet.
2016-01-05 20:40:21 +01:00
Jef Driesen
9bc14dca10 Remove some boilerplate code from the cleanup functions.
Instead of freeing the object data structure in the backend specific
cleanup function, the memory is now freed automatically in the base
class function. This reduces the amount of boilerplate code in the
backends. Backends that don't allocate any additional resources, do no
longer require a cleanup function at all.
2016-01-05 20:40:21 +01:00
Jef Driesen
693a452250 Extend temperature with surface, min and max values. 2014-11-07 21:58:49 +01:00
Calle Gunnarsson
a4e5d4234c Cressi Leonardo now reports temperature from dive header
Signed-off-by: Calle Gunnarsson <calle.gunnarsson@gmail.com>
2014-11-07 21:58:49 +01:00
Jef Driesen
1872b71dad Add support for ascent rate warnings.
The Cressi Leonardo does store an indicator for the ascent rate (e.g.
the number of arrows) in the upper two bits. This results in 4 possible
values, ranging from 0 to 3, with the following interpretation:

    0.0 -  3.9 m/min  No signal
    4.0 -  7.9 m/min  1 Arrow
    8.0 - 11.9 m/min  2 Arrows
   12.0+       m/min  3 Arrows (with STOP icon)

Reported-By: Nick Shore <support@mac-dive.com>
2014-05-13 10:35:06 +02:00
Stephane Bensoussan
4c94460831 Use only 11 bits for the depth.
When using up to 14 bits for the depth, the resulting values are too
large in some cases. Most likely the upper bits are used to store
something else. Even with only 11 bits, the resulting depth range
(0-204.7m) should still be more than sufficient.
2013-10-21 11:41:19 +02:00
Jef Driesen
6419e189a4 Add a single isinstance function per object type.
Currently, each backend has it's own function to verify whether the
object vtable pointer is the expected one. All these functions can be
removed in favor of a single isintance function in the base class,
which takes the expected vtable pointer as a parameter.

Functions which are called through the vtable, don't need to verify the
vtable pointer, and those checks are removed.
2013-04-16 12:18:54 +02:00
Jef Driesen
007479fc92 Rename the backend structure to vtable.
The term "backend" can be confusing because it can refer to both the
virtual function table and the device/parser backends. The use of the
term "vtable" avoids this.
2013-04-16 12:18:53 +02:00
Jef Driesen
0b20855d56 Add support for the Cressi Leonardo.
This is only a preliminary version. There is certainly some room for
improvement, but the basic functionality is already in place. That
should be sufficient for daily use, and possibles issues can always be
fixed when discovered.
2013-02-04 17:20:23 +01:00