There is no need to have two variables for the same purpose.
[Dirk Hohndel: changed to keep the two separate functions as otherwise
we no longer parse existing repos successfully]
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to streamline the view between desktop and mobile we need to save
selected profile related settings to git.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
When the first leg in the planner is not cylinder 0, a gaschange
event at t=1s is inserted. In the profile, we should treat that
as inital gas, so no pressure information is printed for cylinder 0
that is used nominally for one second.
This fixes a problem reported by Willem.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Changed the markup with <div> and <br> tags of the planner output in
a way that is is a good compromise for both displaying in UI and
printing.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This is what we have same_string() for...
This prevents a crash when saving a dive in the planner.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adding --win32log as the first command line option on Windows
will now log all stdout and stderr output to the files
subsurface_err.log and subsurface_out.log in the working directory.
This change required a new argument 'bool logfile' to be added to:
subsurface_console_init() which is defined in all platform files
(linux.c, macos.c, etc.)
Example usage:
subsurface.exe --win32log -v -v -v
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This is important if in one dive we have the real dive and
a planned version of the dive as different computers using
different sets of cylinders.
[Dirk Hohndel: an early version of this was mistakenly pushed out
by me; I reverted that and added this commit since
fixing things up as I had done for the other two
patches made things nearly unreadable]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When Suunto Vytecs are used in gauge mode they don't record gasmixes.
If a tank pressure sensor is present they nevertheless record the
pressures. This patch handles this situation by assuming the tanks
contain air (and warning the user about this).
[Dirk Hohndel: I had mistakenly pushed out an earlier version of this
commit, so this fixes things up to the final version]
Reported-by: antonnorth@gmail.com
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When merging a real dive with a planned dive (for comparison),
we should not try to be clever in merging similar cylinders,
rather keep the union of both cylinder sets as the two versions
of the dive might differ in exctly which gas and how much of it
was used.
Increase MAX_CYLINDERS to 20 to make room for this. We warn if we
exceed this number.
[Dirk Hohndel: I had mistakenly pushed out an earlier version of this
commit, so this fixes things up to the final version]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Print the SAC values from preferences into the diveplan.
These are the values used for calculation of gas consumption.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Print the ATM pressure and the altitude used for calculation into the resulting diveplan.
Moved this info together with the deco model info below the runtime table.
There is one drawback in this implementation: Altitude will be recalculated from surface pressure and therefore may differ slightly from altitude entered in the UI.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When merging a real dive with a planned dive (for comparison),
we should not try to be clever in merging similar cylinders,
rather keep the union of both cylinder sets as the two versions
of the dive might differ in exctly which gas and how much of it
was used.
Increase MAX_CYLINDERS to 20 to make room for this.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
When Suunto Vytecs are used in gauge mode they don't record gasmixes.
If a tank pressure sensor is present they nevertheless record the
pressures. This patch handles this situation by assuming the tanks
contain air (and warning the user about this).
Reported-by: antonnorth@gmail.com
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In the cylinder table, the last column ("use") always showed
OC-GAS. Editing was enabled, but the user had to guess to enter
a small integer meaning dilluent or CCR oxygen cylingder. I guess,
nobody has ever done that.
This patch makes this column clickable. A click toggles if the cylinder
is used for planning or not. This wait it is much easier to investigate
the consequences of gas loss on a plan.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
We had hardcoded the exact translation of the event numbers. They
haven't changed (although we did have what appears to be a spurious
entry for "non stop time" at the end that libdivecomputer doesn't have
an enum for).
Instead, use an explicit array index initializer array, so that it's
obvious that the two match up (and if the sample event numbers ever
change, we should cope with it gracefully).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
New libdivecomputer versions use DC_SAMPLE_GASMIX to indicate a gas
change (which contains the cylinder index we're changing to) rather than
SAMPLE_EVENT_GASCHANGE*.
Unlike the old GASCHANGE model, and despite the name, DC_SAMPLE_GASMIX
does not actually say what the mix is, it only specifies a cylinder
index. We had already extended SAMPLE_EVENT_GASCHANGE2 to have the
cylinder index in the otherwise unused "flags" field, so this is not all
that different from what we used to do.
And subsurface internally already had the logic that "if we know what
the cylinder index is, take the gas mix from the cylinder data", so
we've already been able to transparently use _either_ the actual gas mix
or the cylinder index to show the event.
But we do want to make it an event rather than some sample data, because
we want to show it as such in the profile. But because we are happy
with just the cylinder index, we'll just translate the DC_SAMPLE_GASMIX
thing to the SAMPLE_EVENT_GASCHANGE2 event, and nothing really changes
for subsurface.
libdivecomputer has made other changes, like indicating the initial
cylinder index with an early DC_SAMPLE_GASMIX report, but we've seen
that before too (in the form of early SAMPLE_EVENT_GASCHANGE events), so
that doesn't really end up changing anything for us either.
HOWEVER, one thing that is worth noticing: do *not* apply this patch and
then use an old libdivecomputer library that sends both the
DC_SAMPLE_GASMIX samples _and_ the deprecated SAMPLE_EVENT_GASCHANGE
events. It will all *work*, but since subsurface will take either,
you'll then get duplicate gas mix events.
It's not like that is in any way fatal, but it might be a bit confusing.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Modify formluas for gas use to take into account the
compressibility correction for real gases. This introduces
also the inverse formula to compute the pressure for a given
amount of gas.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Our attempt to skip any white space after the comma causes an ASSERT (strangely
only on Macs).
This closes#158
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds tooltips for the equipment tab for each cylinder, showing the
amount of gas used.
When you mouse over the size and working pressure fields, the tooltip will
show the amount of gas used (along with start and end gas volumes). And
when you mouse over the start and end pressures, it will show the start
and end gas volumes, and the Z factor used.
I started doing this because of the gas volume questions in the last day
or two (and a few from a few weeks ago). When even Robert Helling starts
wondering about the effects of compressibility on the SAC calculation, our
numbers are clearly too opaque.
With these tooltips, at least you can see what went into the used gas
calculations, instead of having to add debugging options to print out Z
factors.
[ This patch also adds a "rint()" to get the rounding right in the
gas_volume() function. Although rounding to the nearst milliliter
really doesn't matter, it's the right thing to do after doing FP
calculations ;^]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Instead of creating the individual parsers, and keeping track of their
arguments, this just uses the "new" dc_parser_new2 function ment for
buffer parsing.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
This removes our own declaration of dc_descriptor_t and all our accesses
to its internals, and switches to use the libdivecomputer functions to
access those instead.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
This is to avoid confusion with planner.display_deco_mode.
When accessing the "current deco mode" use the decoMode()
helper function.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
We have two prefernces determining the deco_mode (BUEHLMANN vs VPMB
vs RECREATIONAL): One for the planner (deco_mode) and one for
displaying dives (display_deco_mode). The former is set in the planner
settings while the latter is set in the preferences.
This patch clears up a confusion which of the two to use by introducing
a helper function that selects the correct variable.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This starts using the newly lifted out get_descriptor in configure dive
computer, instead of previously hard-coded out of date
switch-statements.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This renames and cleans up ostc_get_data_descriptor into get_descriptor,
for more generic use.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is for later reuse of that function in other source files.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I don't know how those arose in the first place, but an
empty QByteArray is never a valid hash value for an image. So
we should not store those in our translation tables and also
get rid of them when loading the tables from disk.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch fixes two bugs:
1) It first computes the effective gradient factors and then
composes the notes with the diveplan rather than the other way
around.
2) It does not try to fit a line through a single point.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For each stop, this computes an effective gradient factor
that gives the same ceiling. Then, it does linear regression
to find values for GFlow and GFhigh that give a similar deco
profile.
Note that this optimises the average gradient factor. The
runtime however depends strongly at the gradient factor at
the last depth. So we don't necessarily to get the runtime
right.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is central information when planning a dive but often
scrolled out of the window for longer plans. So print it on
the top.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Upon importing dives, the average depth can be undefined which we store as 0.
This zero should not contribute when computing the average depth for
the (yearly) statistics, only dives with average depth set now contribute.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This fixes a copy-paste error made by me that caused
tempSensorOffset to first be set the wrong way and then overridden by
pressureSensorOffset.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had (in the wrong place, imo) a new feature that
should differentiate the different deco_modes, you could
plan your dive in buelhman and see it in vpm-b, for instance
but both of them accessed the same pref.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove a few uneeded lines and add more loading code for
the preferences.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch fixes all the cases that I didn't checked for
the default prefs.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Those macros are nice because they take into consideration
the default preferences.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Date loading was incorrect, this unittest + fix deals with that.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Calculate gfline using the gradient factor that is set by the planner
preferences when in the planner, and by the general prefs when not in the
planner. This is achieved by doing the gradient factor calculation in dive.c,
where buehlmann_config is defined.
Previously, the gfline was calculated using the general preferences gfhigh and
gflow, even when in the planner.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fixes a couple of issues with the tests.
Also, a type in prefs.h is "short" while it's actually
a boolean, this made me write the wrong testcase for this.
Fixed this by setting the Qt wrapper to bool, but I didn't
changed the c implementation because I tought I could break
something.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When merging dives, this will skip the gas change event if both dives
use same gas.
Fixes#1099
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
... as those are needed for the heatmap and not only
for Buehlmann ceilings.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Separate the VPM-B conservatism preference into diveplan.vpmb_conservatism for
planning dives and prefs.vpmb_conservatism for profile ceiling display of
saved dives.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While Linux can set the locale from the language text, Windows needs the
correct locale value (which makes more sense to use, anyway - that's why
we save it).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Linus pointed out that it might be another call site (and looking at his
proposed patch I noticed a logic error in my earlier attempt)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds a simple cp2130 userspace driver. Its probably unusable in the
real world but its a great base to build upon.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The set_halfduplex function takes a unsigned int, not a int.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This rewrites the custom serial code to use the new api which I
implemented in the Subsurface-branch of libdivecomputer.
This is a bit to big patch but I haven't had the time to break it down
into more sensible patches.
This rewrite enables us to support more ftdi based divecomputer
communication and is tested with both a OSTC3, OSTC2N and a Suunto
Vyper, all over the libftdi driver.
The bluetooth code paths are tested to, and should work as before.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When editing adive in Subsurface-mobile we can only handle one buddy
due to the limitations of the combobox. To prevent loss of data when editing
a dive with more than one buddy we display "Multiple Buddies" in the buddy
field. This creates a special case where no changes are written to the buddy field
unless the user changes buddy for that dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
... and not just for Buehlmann. This makes the saturation
graphs meaningful for VPM-B.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change runtime table string from ZHL-16B to ZHL-16C to reflect he fact
that we use 5min as half-time for the fastest compartment rather than
4min.
Further more trade pow(2.0, ...) for exp().
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This removes 'fixup_dc_cylinder_index()', which was added to fix up the
pressure sensor indexes from the Atomic Cobalt dive computer.
Even for the Cobalt it really shouldn't matter, because the
libdivecomputer backend for the Cobalt actually tries to do the right
thing. See for example commit 8853a1ccd422 ("Associate the pressure
samples with the primary tank.") in libdivecomputer.
Some historical digging shows that the subsurface sample pressure index
code came in from commit e32ba4d6d8 ("Improve tank handling for
Cobalt"), dated Tue Oct 28 13:48:15 2014.
And the libdivecomputer "use the right cylinder" code was around the
same time (Fri Oct 10 20:29:17 2014 +0200).
So I suspect that subsurface needed the fixup based on an older version
of libdivecomputer. Jef's patch is a couple of weeks before, but we may
not have tracked libdivecomputer religiously.
The reason to remove this code is because it can (and does) mess up the
sensor index when it is actually reliable, like in the multi-sensor case
of the Suunto EON Steel.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds the option to select a cylinder when adding or editing a dive.
Due to limited screen size we restrict the editing to the first cylinder only.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With the recent setting cleanup, gradient factors were set to bool, so were
saved as 1/1, rather than say 50/80. This commit fixes that.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>