25 Commits

Author SHA1 Message Date
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
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
d0dbd1f6fd Remove the deprecated gas change events
The new gas mix sample has been around for a while now, and we're not
going to maintain the deprecated events forever.
2016-11-04 19:24:54 +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
06e0de6712 Add a new sample with the active gas mix.
The new gasmix sample contains the index of the active gas mix.

This new sample is intended as a replacement for the existing gas change
events (SAMPLE_EVENT_GASCHANGE and SAMPLE_EVENT_GASCHANGE2). To maintain
backwards compatibility, the legacy events are marked as deprecated but
not removed yet.
2015-12-21 14:03:39 +01:00
Jef Driesen
d7c89bbc39 Add support for the temperature field. 2015-04-22 08:27:41 +02:00
Jef Driesen
47874037ea Disable gas change events except for the intial mix.
For the IQ-700, the existing code for the active gas mix always results
in an out-of-range gas mix index. The index of the active gas mix is
probably stored in another bit. As a temporary workaround, we simply
assume the active gas mix is always the first gas mix. This should
already produce correct results for dives with only single gas mix.
2015-04-22 08:27:41 +02:00
Jef Driesen
311bc85645 Add support for the Tusa IQ-700.
The Tusa IQ-700 is very similar to the other Seiko based models. The
most important change is that due the smaller amount of memory (8K vs
32K), the logbook entries are only 1 byte large instead of two bytes.
2015-04-22 08:25:03 +02:00
Jef Driesen
ba77b0ed24 Add support for gas switches. 2014-02-15 16:41:08 +01:00
Jef Driesen
d30b5c65fe Ignore invalid gas mixes.
Gas mixes that have been marked as disabled are stored as the value 0xF0.
When interpreted as an oxygen percentage, this results in an out of range
value. Therefore, these gas mixes should simply be ignored.
2014-02-15 16:41:07 +01: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
cd31ff9dff Properly store the context pointer internally.
I forgot to update the device and parser initialization functions to
store the context pointer into the objects. As a result, the internal
context pointers were always NULL.
2012-08-28 08:44:47 +02:00
Jef Driesen
53e9d72a40 Integrate the context object in the library.
The public api is changed to require a context object for all
operations. Because other library objects store the context pointer
internally, only the constructor functions need an explicit context
object as a parameter.
2012-08-27 23:08:38 +02:00
Jef Driesen
c821d40144 Introduce a namespace prefix for the high-level public api.
Adding the "dc_" namespace prefix (which is of course an abbreviation
for libdivecomputer) should avoid conflicts with other libraries. For
the time being, only the high-level device and parser layers are
changed.
2012-06-21 21:42:37 +02:00
Jef Driesen
163d383332 Use a common backend type for the device and parser layers. 2012-06-21 21:42:37 +02:00
Jef Driesen
9136a52835 Use common status codes for the device and parser layers. 2012-06-21 21:42:34 +02:00
Jef Driesen
e65025b501 Separate private and public headers.
The public header files are moved to a new subdirectory, to separate
the definition of the public interface from the actual implementation.
Using an identical directory layout as the final installation has the
advantage that the example code can be build outside the project tree
without any modifications to the #include statements.
2012-06-21 21:39:24 +02:00
Jef Driesen
4ea3964c3c Implement the new field api for the Seiko devices. 2011-01-13 23:41:47 +01:00
Jef Driesen
90e60fecee Add a new function to the public api to retrieve the dive metadata. 2011-01-13 22:14:53 +01:00
Jef Driesen
1ea4879066 Choose the samplerate based on the model number. 2011-01-13 22:12:45 +01:00
Jef Driesen
154f767a9c Convert assertions into error codes. 2011-01-08 23:40:15 +01:00
Jef Driesen
a0bb840169 Use only 12 bits for the depth.
The depth is stored with only 12 bits, which results in a maximum depth
of 99.9 meters. The remaining 4 bits are yet unknown, but one of those
bits appears to indicate a larger sample.
2010-08-29 15:08:28 +02:00
Jef Driesen
6641dda617 Add a parser for the Cressi Edy. 2010-05-03 18:02:43 +00:00