Commit graph

419 commits

Author SHA1 Message Date
Robert C. Helling
d67cce2af8 Recording average depth data
This is the calculation that is needed to display a running average in the
profile.

It adds a new member plot_data.running_sum which can be turned into the
running average by dividing by plot_data.time.

Right now this isn't used by the UI.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-17 08:05:02 -08:00
Robert C. Helling
aa22e0610c Don't interpolate pressure while dragging waypoints
A profiler session in the planner shows that for deep long dives
a significant amount of CPU time is spent in populate_pressure_information()
which interpolates the cylinder pressure graphs.

This patch introduces a "fast" flag for the replot of the profile
which is active while the mouse button is still pressed and that
suppresses this calculation.

In the future, this flag could be used for other responsiveness tunings
of the plot.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-04 16:26:47 -06:00
Robert C. Helling
fb265c2929 Context menu entry to change setpoint
This patch adds a context menu entry to add a setpoint change
event. In particular, this can be used to turn a logged dive into
a CCR dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-01 14:23:45 -08:00
Robert C. Helling
a4679300cc Correctly computer O2 partial pressure
I had forgotten a / 1000.0 in the conversion of partial pressures from (double) bar to (int32) mbar.

Fixes #763

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20 07:46:47 -08:00
Anton Lundin
54237cb9a7 Fix warnings in debug_print_profiledata
Use the right format, now when those variables are integers and not
doubles.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-19 17:51:59 -08:00
Robert C. Helling
9561fa3f3e Cleaning up pressures
Added comment about meaning of o2pressure in struct plot_info.

Turned some pressures from double (in bar) to pressure_t (in mbar)

[Dirk Hohndel: picked parts of this patch and dropped others]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18 13:25:17 +00:00
willem ferguson
514a0e582a Fix issues in CCR handling
In commit 0d7c192e6e ("For CCR dives, the diluent cylinder is the
current cylinder") a few things got broken. This tries to undo those
changes and adds expanded XML output.

1) Calculate correct partial pressure of oxygen to be plotted on
   dive profile, taking into account the oxygen sensor data.
   Currently, erroneously, OC PO2 values are shown, due to an
   erroneous calling parameter to fill_pressures().
2) Read start and end cylinder pressured correctly.  some wrong
   assignments were done in file.c. This is now corrected and the correct
   cylinder pressures are shown in the equipment tab.
3) Write correct cylinder pressures to XML. Currently the data for
   the two cylinders are written to XML the wrong way round
   (diluent pressures = oxygen and vice versa).
4) Expand XML output:
   a) Write oxygen sensor data to XML
   b) Write no_of_02sensors to XML

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-18 08:57:21 +00:00
Robert C. Helling
d5d7fdc9af For CCR dives, show plot for diluent and O2 cylinder pressures
Also fixes a bug in the diluent pressure interpolation

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 18:02:42 +00:00
Robert C. Helling
0d7c192e6e For CCR dives, the diluent cylinder is the current cylinder
Change the meaning that _the_ cylinder (as we treat it in OC dives) is the
diluent cylinder (rather than the O2 cylinder). This eliminates special
cases. Now, for CCR, we have to handle the O2 cylinder in addition
(rather than the diluent in addition).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 11:45:06 +00:00
Dirk Hohndel
fa181d1ded More CCR code cleanup
Random constants are bad. Let's use the indices that we already calculated
(and true and false if we mean boolean values).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 07:23:20 +00:00
Lubomir I. Ivanov
1617d437d4 profile.c: fix a bug in calculate_gas_information_new()
In a test case loading dives/test35.xml results in a infinite(-like)
loop (Note: possibly requires the partial pressure plots enabled).

calculate_gas_information_new() has an 'if' branch to
update the cylinderindex to a dive's diluent_cylinder_index,
but it does not consider that said index can be set previously
to -1.

This results in a random neighbour memory assigned as
&dive->cylinder[-1].gasmix and passed to fill_pressures(..).

Following the calculations in the function the He gas,
can receive a bad value (e.g. for the test case in the
E+6 ranges).

Said value is then used in DivePlotDataModel()::pheMax()
(defined by MAX_PPGAS_FUNC()) resulting in one of the loops
(the 3rd one) in DiveCartesianAxis::updateTicks() to
loop indefinitely.

Fixes #759

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12 14:41:39 -08:00
Anton Lundin
1990dafda0 Remove leftover last_setpoint
Back in 24c491053c ("Don't overwrite zero setpoints") the filling of
last_setpoint logic was removed. This clears out the last bits left
over.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 11:23:28 -08:00
Robert C. Helling
cff413f14d The po2 argument of addS_segment is the setpoint, not the pO2 at that time
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 13:19:18 -08:00
Robert C. Helling
24c491053c Don't overwrite zero setpoints
As we agreed, in memory we don't zero repeated setpoints and thus zero
setpoints don't have to be overwritten by the last setpoint value.

This corrects the deco ceiling with CCR dives that bailout to OC.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 13:19:08 -08:00
Robert C. Helling
54692fb814 Use the CCR corrected gases for EAD and END calculations
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04 11:45:32 -08:00
Robert C. Helling
06ddfc0122 Prepare for PSCR calculations
Calculations for passive semi-closed rebreathers are pretty much like OC
except the pO2 is lower bey a certain (SAC dependent) factor. This patch
introduces the corresponding calculations in case dctype == PSCR which is
so far never set and there is currently no UI for these calculations. As
pO2 is SAC dependent it takes a certain attempt at getting it and drops to
defaults from the prefs otherwise.

As there is no UI at this point and I also don't have any dives, this has
not received much testing, yet, but it compiles. At least.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04 07:13:04 -08:00
willem ferguson
40bdd607c0 Calculate nitrogen and helium gas pressures for CCR after import from CSV
Currently the gas pressures stored in structures of pressure are
calculated using the gasmix composition of the currently selected
cylinder. But with CCR dives the default cylinder is the oxygen
cylinder (here, index 0). However, the gas pressures need to
be calculated using gasmix data from cylinder 1 (the diluent
cylinder). This patch allows setting the appropriate cylinder
for calculating the values in the structures of pressure. It
also allows for correctly calculating gas pressures for any
open circuit cylinders (e.g. bailout) that a CCR diver may
use. This is performed as follows:

1) In dive.h create an enum variable {oxygen, diluent, bailout}

2) Within the definition of cylinder_t, add a member: cylinder_use_type
   This stores an enum variable, one of the above.

3) In file.c where the Poseidon CSV data are read in, assign
   the appropriate enum values to each of the cylinders.

4) Within the definition of structure dive, add two members:
   int oxygen_cylinder_index
   int diluent_cylinder_index
   This will keep the indices of the two main CCR cylinders.

5) In dive.c create a function get_cylinder_use(). This scans the
   cylinders for that dive, looking for a cylinder that has a
   particular cylinder_use_type and returns that cylinder index.

6) In dive.c create a function fixup_cylinder_use() that stores the
   indices of the oxygen and diluent cylinders in the variables
   dive->oxygen_cylinder_index and dive->diluent_cylinder_index,
   making use of the function in 4) above.

7) In profile.c, modify function calculate_gas_information_new()
   to use the above functions for CCR dives to find the oxygen and
   diluent cylinders and to calculate partail gas pressures based
   on the diluent cylinder gas mix.

This results in the correct calculation of gas partial pressures
in the case of CCR dives, displaying the correct partial pressure
graphs in the dive profile widget.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-03 14:13:55 -08:00
willem ferguson
6cf3787a0e Remove code that zeroes out duplicate oxygen sensor and temperature values
Remove the code that changes all duplicate oxygen sensor, setpoint and
temperature values from a dive log to zero. One of the motivations is
that a zero setpoint value indicates an Open Circuit dive segment, not
Closed Circuit Rebreather. The code in dive.c is removed and the comments
for the corresponding restoration code that restores the last known values
into sensor or temperature with zero values is [fill_o2_values()
in profile.c] is changed to apply to the present situation.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-01 22:13:47 -07:00
Dirk Hohndel
e32ba4d6d8 Improve tank handling for Cobalt
This isn't Cobalt specific, this is specific to dive computers that
indicate the first tank that's in use with a gaschange event that
coincides with the first sample.

We need to make sure that we suppress showing that gas change event
(regardless which cylinder it goes to) and instead set the correct
cylinder index from the very start of the dive.

This works with the test data I have and doesn't seem to break thing with
any of the files that I tried... but I'm worried that this is not the
right way to do things.

Fixes #742

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-28 14:04:19 -07:00
Lubomir I. Ivanov
8b85cafa69 profile.c: remove a variable which is set but not used
fill_o2_values():
struct gas_pressures *pressures;

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27 07:38:19 -07:00
Lubomir I. Ivanov
2a9b0c7ebc profile.c: remove unused variables in calculate_ccr_po2()
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27 07:37:57 -07:00
Robert C. Helling
5f44fdd9cf Make planner work again for CCR dives
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:07:07 -07:00
willem ferguson
51a112c8bf CCR patch: Correction of inconsistency in profile.c
fill_o2_values() in profile.c: Robert identified the inconsistency of po2
assignmemts when using OC dives as opposed to CCR dives.
This is corrected here. OC dives still need to be processed in this function
because the po2 values have not been initialised anywhere else before
thos code executes.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-14 20:33:46 +02:00
Robert C. Helling
34bb461c3d Reshuffle CCR voting logic and minor clean ups
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-14 20:33:46 +02:00
willem ferguson
c8eb2dccc5 CCR patch: Reorganise the oxygen partial pressure calculations
This patch responds to the side effects that the CCR code has had with
respect to ceilings in OC dives and dive plans. Dive ceilings are now
calculated correctly again.

The following were performed:
1) remove the oxygen sensor and setpoint fields from the gas_pressures
   structure.
2) Re-insert setpoint and oxygen sensor fields in the plot_data structure.
3) Remove the algorithm that reads the o2 sensor data and calculates the
   pressures.po2 value from function fill_pressures() in dive.c and save
   it as a separate function calc_ccr_po2() in profile.c.
4) Activate calc_ccr_po2 from function fill_pressures() in profile.c.
5) Move the relative position of the call to fill_pressures() within the
   function create_polt_info_new() in profile.c.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-13 23:15:41 +02:00
willem ferguson
bc9df4652f CCR patch: Calculate the correct partial gas pressures for CCR dives
This patch adds code to the function fillpressures() in dive.c to
allow calculating o2 pressures, based on the data from the po2
sensors in the system. The following changes were made:
1) add code to perform po2 calculations for CCR with 1, 2 or 3
   oxygen sesnors.
2) Add four fields to the gas_pressures structure in dive.h. This
   allows communication of data between the function that calls
   get_pressures() and the return of partail pressure values to the
   calling function.
3) Delete the fields for setpoint and gas partial pressures from
   the structure plot_info. All partial pressures (from instruments
   as well as calculated) now reside in the pressures structure
   that forms part of plot_info.
4) Perform changes in several parts of profile.c to make use of the
   pressures structure in plot_info.

[Dirk Hohndel: yet again massive whitespace cleanup]

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 15:23:49 -04:00
willem ferguson
49c9ad199f CCR patch: Oxygen partial pressures
This patch does three things:
1) A new function fill_o2_values() is added to profile.c. This
   fills all oxygen sesnsor and setpoint values that have been
   zeroed before in order to save space in the dive log. This
   recreates the full set of sensor values obtained from the
   original CCR xml log file.
2) Function fill_o2_values() is activated in function create_
   plot_info_new() in profile.c
3) The calling parameters to function fill_pressures() in dive.c
   are changed. The last parameter is now a pointer to a structure
   of divecomputer. This will be needed in the last patch of the
   present series of three patches.

[Dirk Hohndel: minor whitespace cleanup]

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 12:40:34 -04:00
Anton Lundin
3b30009d7a Remove unused variables
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 12:34:40 -04:00
Linus Torvalds
df4e26c875 Start sanitizing gaschange event information
Decode the gasmix data into a sane format when creating the event, and
add the (currently unused) ability to specify a gas change to a
particular cylinder rather than (or in addition to) the gasmix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-12 07:45:37 -04:00
Dirk Hohndel
43765d2897 Keeping up the fight for whitespace consistency
Sadly, some of the code being fixed is my own...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-11 07:26:26 -04:00
willem ferguson
46bb02e8fc CCR patch: Import and store oxygen sensor data
This patch allows the importing of oxygen sensor and setpoint data from
Poseidon CCR dive logs.
1) Change parse-xml.c to read up to three oxygen sensor values from xml.
   and to store the information in sample structures
2) Change parse-xml.c to read o2 setpoint values fro xml and to store
   it in sample structures
3) Change dive.c to delete all sensor and setpoint values where
   subsequent samples have sensor/setpoint values that are the same.
4) Change profile.c to store the sensor/setpoint values from the samples
   into plotinfo.
5) Change the sample Poseidon xml log in the dives directory to ensure
   the correct order and hierarchy of the dive and divecomputer nodes.

[Dirk Hohndel: minor cleanup, removed debug code, whitespace]

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-11 07:12:04 -04:00
Robert C. Helling
15a99f8789 Add tissue saturation plot to tooltip
This adds a graphical representation of tissue loadings at the current moment during the dive
to the tooltip box. The layout is inspired by the Sherwater Petrel.Add tissue saturation plot to tooltip

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-19 21:48:05 -07:00
Robert C. Helling
3fc9c1e005 Tissue saturation plot a la Sherwater Pretel
This adds a toolbox icon to turn on a tissue plot inspired by the bar
graph of the Sherwater Petrel,

It shows the inert gas partial pressures for individual compartments. If
they are below the ambient pressure (grey line) they are shown in units of
the ambient pressure, if they are above, the excess is shown as a
percentage of the allowed overpressure for plain Buehlmann. So it has the
same units as a gradient factor. Thus also the a gradient factor line (for
the current depth) is shown.

The different tissues get different colors, greener for the faster ones and bluer
for the slower ones.

Positioning and on/off icon action still need some tender loving care.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-19 21:46:30 -07:00
Robert C. Helling
d6abb739d9 Helper function for partial pressure calculation
This patch introduces a new structure holding partial pressures (doubles in bar) for
all three gases and a helper function to compute them from gasmix (which holds fractions)
and ambient pressure. Currentlty this works for OC and CCR, to be extended later to PSCR.

Currently the dive_comp_type argument is unused.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-18 06:20:25 -07:00
willem ferguson
d1c521ce5e CCR patch: adapt code for diluent cylinder pressures (3)
This patch implements the cylinder pressure calculations for diluent
gas in CCR dive computers. This is the third patch for achieving this.
The following were performed:

1) Add two lines to try_to_fill_sample() in parse-xml so that
   diluent cylinder pressures are stored from XML dive log file
   into structures of sample.
2) Add one line to populate_plot_entries() in profile.c so that
   the diluent cylinder pressures are copied from structures of
   sample to structures of plot_info.
3) add three constant #defines in profile.h
4) change populate_pressure_information() in gaspressures.c in
   order to take into account pressure calculations for the
   diluent cylinder, calling subordinate functions in the
   appropriate way.
5) change create_plot_info_new() in profile.c in order to initiate
   the pressure calculations for the diluent cylinder.
6) Implement two debugging functions (one in profile.c, another
   in gaspressures.c). These debugging functions are activated
   by means of #defines.

Two function calls dealing with oxygen pressure are currently commented
out.  They will be activated in the following patch that attends to CCR
oxygen partial pressure calculation.

[Dirk Hohndel: rather massive whitespace cleanup]

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-11 08:32:10 -07:00
Willem Ferguson
7575eb44df CCR code: Split profile.c into two files, with gas caluclations separate.
This patch implements a separation of the code for gas pressure
calculations from the rest of the code in profile.c. The latter
file is now split into: profile.c and gaspressures.c. The
details of the transferred functions is given at the top of
gaspressures.c. The following chnages were made:
1) dive.h: The function types of calculate_depth_to_mbar
   and depth_to_mbar were made non-static in order to make them
   available within gaspressures.c.
2) profile.c: Prototypes for the functions in gaspressures.c
   were inserted at the top of profile. Ten functions were
   transferred from profile.c to gaspressures.c
3) gaspressures.c as well as a short header, gaspressures.h
   were created.

For the gas pressure calculations for CCR dives, gaspressures.c
forms the immediate basis for further code development.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:53:51 -07:00
Anton Lundin
848a5352c7 Add support divecomputer based TTS
Since earlier have we had support for our own calculated TTS. This adds
support for holding TTS values reported by a dive computer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 13:22:00 -07:00
Anton Lundin
537beb319b Only calculate deco stops, TTS and NDL every 30s
This introduces a limiter that we only calculate deco stop, TTS and NDL
with a minimum of 30s intervall and just reused the values from the
previous sample in other cases.

I run my OSTC3 at 2s sample intervall so this is a 15x speedup in that
case.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-29 17:16:43 -07:00
Robert C. Helling
65c5d6815c Make pO2 settings functional in planner
Spin boxes for pO2 are now hooked up to preference values. Adding new
cylinders (or changing their fo2) computes the MOD accordin to the current
value of decopo2. Note that chaning the limits for deco pO2 does _not_
automatically update the switch depth of all cylinders as those might have
been manually entered.

Furthermore, MOD has now to option of rounding to multiples of a given
depth. That is used for the automatic switch depth which are now always
multiples of 3m (so that EAN50 is switched to at 21m rather than 22m).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 21:07:10 +08:00
Henrik Brautaset Aronsen
630ec88dd4 Be more consistent in partial pressure naming
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂.
They all mean the same, but it's better to be
consistent

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:48:54 +08:00
Dirk Hohndel
a3ce3221fd Fix incorrect argument order for %.*f
Strangely, *prinf() on Linux appears to do the right thing in either
order (my guess is based on the type of the two values?), but on Windows
things go badly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 11:23:05 -07:00
Dirk Hohndel
bbe62f756a Change character for liter in SAC values as well
And fix the bug that in the info overlay SAC was always given in metric
values. And try to reduce the number of places in which we calculate the
unit conversions...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 21:00:56 -07:00
Anton Lundin
f34e6218a0 More tweaks to TTS calculations
Add a lager step value when walking the calculations forward.

[Dirk Hohndel: this was sent ages ago and in all the discussions about the
               implications I apparently never applied this]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04 13:44:08 -07:00
Linus Torvalds
9874a97ed5 Make bigger steps when calculating TTS
[Dirk Hohndel: this was sent ages ago and in all the discussions about the
               implications I apparently never applied this]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04 11:05:22 -07:00
Willem Ferguson
eaf6d56487 CCR code: Change to sample structure
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
     o2pressure_t
     bearing_t
3) The following variables were added:
     diluentpressure
     o2setpoint
     o2sensor[3]
4) Changes to a number of files were made to chanf
     sample->po2 to sample->po2.mbar
     bearing to bearring.degrees

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 17:05:25 -07:00
Dirk Hohndel
1a04013453 Encapsulate the horrid gas encoding in gas change events
We should never pass permille values around as integers. And we shouldn't
have to decode the stupid value in more than one place.

This doesn't tackle all the places where we access O2 and He "too early"
and should instead keep passing around a gaxmix. But it's a first step.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 12:07:29 -07:00
Dirk Hohndel
56395b3894 Don't assume that pressures are always positive
When planning a dive, the dive could use more gas than is in the cylinder.
So getting a negative end pressure is a useful indication to the user that
there plan might not be a good one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 13:18:13 -07:00
Anton Lundin
ff966f2c1a Move mod calculations to a separate helper
We use mod calculations on multiple places, so make a separate helper
from it with proper types.

The "clumsiness" of defining a local variable to pass into the function
and out from it comes from the discrepancies in how c and c++ handles
initializations of variables in a struct.

Thanks goes to Tiago and Linus for pointing me in the right direction.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-25 06:20:52 -07:00
Tomaz Canabrava
c86d055db7 Do not check for null before free.
C specs says that we can safelly free a NULL pointer, so there's no reason
to check if it's null before freeing it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13 09:26:50 +09:00
Anton Lundin
08df5e7e87 Use enum name instead of its int value.
SAMPLE_EVENT_GASCHANGE2 is the libdivecomputer name of the event.
Compare with that instead of its int value.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 14:58:04 -07:00