commit f2be47b2ca6dc67b1c3de7fe8c2533d8dd525236
parent 5345b59e5f18df377243eea84c0adc5638ef1182
Author: Jean Schurger <jean@schurger.org>
Date: Sun, 15 Nov 2026 21:18:43 -0500
Planning tab: no-stop calculator, decompression planner, gas tools
- No-stop: depth, gas and cylinder in; how long one can stay (no-stop time,
gas time) and a table of no-stop times out.
- Decompression: levels, cylinders (nitrox, trimix, decompression gases with
their switch depth), settings (gradient factors, speeds, last stop,
consumption, oxygen limits, water); stops, run time, gas per cylinder,
minimum gas, CNS and OTU, warnings, profile. The plan is kept between
launches.
- Gas: maximum operating depth, narcotic and air equivalents, density, best
mix for a depth, consumption.
- French strings, README, version 0.8.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYG3yp7VDUZJzSBkvTc
Diffstat:
8 files changed, 1888 insertions(+), 66 deletions(-)
diff --git a/App/Localizable.xcstrings b/App/Localizable.xcstrings
@@ -1,6 +1,46 @@
{
"sourceLanguage": "en",
"strings": {
+ "%@ at %@: as narcotic as air at %@.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "%@ à %@ : aussi narcotique que l'air à %@."
+ }
+ }
+ }
+ },
+ "%@ at %@: gas density %@ g/L.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "%@ à %@ : densité du gaz %@ g/L."
+ }
+ }
+ }
+ },
+ "%@ at %@: only %@ bar of oxygen, not breathable there.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "%@ à %@ : seulement %@ bar d'oxygène, non respirable à cette profondeur."
+ }
+ }
+ }
+ },
+ "%@ at %@: oxygen at %@ bar, above the limit.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "%@ à %@ : oxygène à %@ bar, au-dessus de la limite."
+ }
+ }
+ }
+ },
"%@ has no dives in memory.": {
"localizations": {
"fr": {
@@ -41,6 +81,16 @@
}
}
},
+ "%@ used, %@ left": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "%@ consommés, %@ restants"
+ }
+ }
+ }
+ },
"%@ · already in the logbook": {
"localizations": {
"fr": {
@@ -81,6 +131,16 @@
}
}
},
+ "%@: %@ left when leaving the bottom, under the minimum gas of %@.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "%@ : %@ restants en quittant le fond, sous le gaz minimum de %@."
+ }
+ }
+ }
+ },
"%lld": {
"localizations": {
"fr": {
@@ -371,6 +431,16 @@
}
}
},
+ "A decompression gas is taken on the way up, from its switch depth. Without a depth set by hand, that is where its oxygen reaches %@ bar.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Un gaz de décompression se prend à la remontée, à partir de sa profondeur de changement. Sans profondeur réglée à la main, c'est là où son oxygène atteint %@ bar."
+ }
+ }
+ }
+ },
"A dive already exists at this date and time.": {
"localizations": {
"fr": {
@@ -381,6 +451,26 @@
}
}
},
+ "A level uses a cylinder that is no longer in the list.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Un niveau utilise une bouteille qui n'est plus dans la liste."
+ }
+ }
+ }
+ },
+ "A planning aid, not a dive computer: models differ, and so do divers. Check a decompression plan against another tool, dive within your training, and follow your dive computer in the water.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Une aide à la planification, pas un ordinateur de plongée : les modèles diffèrent, les plongeurs aussi. Vérifiez un plan de décompression avec un autre outil, plongez dans les limites de votre formation, et suivez votre ordinateur de plongée dans l'eau."
+ }
+ }
+ }
+ },
"A week of shore diving": {
"localizations": {
"fr": {
@@ -461,6 +551,16 @@
}
}
},
+ "Add a level": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Ajouter un niveau"
+ }
+ }
+ }
+ },
"Add weights": {
"localizations": {
"fr": {
@@ -541,6 +641,16 @@
}
}
},
+ "Answer": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Réponse"
+ }
+ }
+ }
+ },
"Around the wreck, starting at the bow.\nGreen moray in the forward hold.": {
"localizations": {
"fr": {
@@ -551,6 +661,56 @@
}
}
},
+ "Ascent": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Remontée"
+ }
+ }
+ }
+ },
+ "Ascent above %@": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Remontée au-dessus de %@"
+ }
+ }
+ }
+ },
+ "Ascent and stops": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Remontée et paliers"
+ }
+ }
+ }
+ },
+ "At the bottom": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Au fond"
+ }
+ }
+ }
+ },
+ "At this depth": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "À cette profondeur"
+ }
+ }
+ }
+ },
"Average SAC": {
"localizations": {
"fr": {
@@ -621,6 +781,26 @@
}
}
},
+ "Best mix": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Meilleur mélange"
+ }
+ }
+ }
+ },
+ "Best mix for a depth": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Meilleur mélange pour une profondeur"
+ }
+ }
+ }
+ },
"Bluetooth is off": {
"localizations": {
"fr": {
@@ -641,6 +821,26 @@
}
}
},
+ "Bottom gas": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Gaz de fond"
+ }
+ }
+ }
+ },
+ "Bottom gas (1.4 bar)": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Gaz de fond (1,4 bar)"
+ }
+ }
+ }
+ },
"Buddies": {
"localizations": {
"fr": {
@@ -661,6 +861,16 @@
}
}
},
+ "Bühlmann ZHL-16C with gradient factors, open circuit, computed the way Subsurface's planner does.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Bühlmann ZHL-16C avec facteurs de gradient, circuit ouvert, calculé comme le fait le planificateur de Subsurface."
+ }
+ }
+ }
+ },
"CNS": {
"localizations": {
"fr": {
@@ -881,6 +1091,46 @@
}
}
},
+ "Conservatism": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Conservatisme"
+ }
+ }
+ }
+ },
+ "Consumption at %@": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Consommation à %@"
+ }
+ }
+ }
+ },
+ "Consumption at the surface": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Consommation en surface"
+ }
+ }
+ }
+ },
+ "Consumption factor": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Facteur de consommation"
+ }
+ }
+ }
+ },
"Cormorant Wreck": {
"localizations": {
"fr": {
@@ -1071,6 +1321,46 @@
}
}
},
+ "Decompression": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Décompression"
+ }
+ }
+ }
+ },
+ "Decompression (1.6 bar)": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Décompression (1,6 bar)"
+ }
+ }
+ }
+ },
+ "Decompression gas": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Gaz de décompression"
+ }
+ }
+ }
+ },
+ "Decompression, from %@": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Décompression, à partir de %@"
+ }
+ }
+ }
+ },
"Deepest": {
"localizations": {
"fr": {
@@ -1081,6 +1371,26 @@
}
}
},
+ "Deepest for this gas": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Profondeur max. du gaz"
+ }
+ }
+ }
+ },
+ "Deepest: %@ at %@ bar, %@ at %@ bar.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Profondeur max. : %@ à %@ bar, %@ à %@ bar."
+ }
+ }
+ }
+ },
"Delete": {
"localizations": {
"fr": {
@@ -1151,6 +1461,16 @@
}
}
},
+ "Descent": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Descente"
+ }
+ }
+ }
+ },
"Deselect all": {
"localizations": {
"fr": {
@@ -1501,6 +1821,16 @@
}
}
},
+ "Each time counts from leaving the previous depth: the way down, or up, is part of it.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Chaque temps compte depuis le départ de la profondeur précédente : la descente, ou la remontée, en fait partie."
+ }
+ }
+ }
+ },
"Edit": {
"localizations": {
"fr": {
@@ -1571,6 +1901,26 @@
}
}
},
+ "Equivalent air depth": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Profondeur équivalente à l'air"
+ }
+ }
+ }
+ },
+ "Equivalent narcotic depth": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Profondeur narcotique équivalente"
+ }
+ }
+ }
+ },
"Erase": {
"localizations": {
"fr": {
@@ -1661,6 +2011,26 @@
}
}
},
+ "Fresh": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Douce"
+ }
+ }
+ }
+ },
+ "Fresh water": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Eau douce"
+ }
+ }
+ }
+ },
"Fringing reef, shore entry": {
"localizations": {
"fr": {
@@ -1681,6 +2051,26 @@
}
}
},
+ "GF high": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "GF haut"
+ }
+ }
+ }
+ },
+ "GF low": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "GF bas"
+ }
+ }
+ }
+ },
"Gas": {
"localizations": {
"fr": {
@@ -1691,6 +2081,46 @@
}
}
},
+ "Gas density": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Densité du gaz"
+ }
+ }
+ }
+ },
+ "Gas lasts": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Autonomie en gaz"
+ }
+ }
+ }
+ },
+ "Gas needed": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Gaz nécessaire"
+ }
+ }
+ }
+ },
+ "Gas switch": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Changement de gaz"
+ }
+ }
+ }
+ },
"Gas: %@": {
"localizations": {
"fr": {
@@ -1721,6 +2151,16 @@
}
}
},
+ "Gradient factors": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Facteurs de gradient"
+ }
+ }
+ }
+ },
"Guide": {
"localizations": {
"fr": {
@@ -1751,6 +2191,16 @@
}
}
},
+ "High (GF 35/75)": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Élevé (GF 35/75)"
+ }
+ }
+ }
+ },
"Hunting octopuses and tarpon in the beams of our lights.": {
"localizations": {
"fr": {
@@ -1801,6 +2251,16 @@
}
}
},
+ "In this cylinder": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Dans cette bouteille"
+ }
+ }
+ }
+ },
"Instructor, dive centre…": {
"localizations": {
"fr": {
@@ -1841,6 +2301,16 @@
}
}
},
+ "Keep the narcotic depth at %@": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Garder la profondeur narcotique à %@"
+ }
+ }
+ }
+ },
"Keeping the logbook lets you go on without the Subsurface cloud. Nothing is deleted in the cloud either way.": {
"localizations": {
"fr": {
@@ -1861,6 +2331,16 @@
}
}
},
+ "Last stop at %@": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Dernier palier à %@"
+ }
+ }
+ }
+ },
"Last sync": {
"localizations": {
"fr": {
@@ -1991,6 +2471,26 @@
}
}
},
+ "Low (GF 45/95)": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Faible (GF 45/95)"
+ }
+ }
+ }
+ },
+ "Lower figures are more conservative. The low factor sets how deep the first stop is, the high one how much is left on surfacing.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Des valeurs plus basses sont plus prudentes. Le facteur bas fixe la profondeur du premier palier, le haut ce qui reste en arrivant en surface."
+ }
+ }
+ }
+ },
"Manually entered dive": {
"localizations": {
"fr": {
@@ -2051,6 +2551,16 @@
}
}
},
+ "Medium (GF 40/85)": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Moyen (GF 40/85)"
+ }
+ }
+ }
+ },
"Merge": {
"localizations": {
"fr": {
@@ -2101,6 +2611,36 @@
}
}
},
+ "Minimum gas": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Gaz minimum"
+ }
+ }
+ }
+ },
+ "Minimum gas: what must be left in %@ when leaving the bottom, for %@ minutes on a problem and the ascent to the first gas switch, at %@ times the consumption.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Gaz minimum : ce qui doit rester dans %@ en quittant le fond, pour %@ minutes sur un problème et la remontée jusqu'au premier changement de gaz, à %@ fois la consommation."
+ }
+ }
+ }
+ },
+ "Minimum gas: what must be left in %@ when leaving the bottom, for %lld minutes on a problem and the ascent to the first gas switch, at %@ times the consumption.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Gaz minimum : ce qui doit rester dans %@ en quittant le fond, pour %lld minutes sur un problème et la remontée jusqu'au premier changement de gaz, à %@ fois la consommation."
+ }
+ }
+ }
+ },
"Misty Wharf": {
"localizations": {
"fr": {
@@ -2321,6 +2861,16 @@
}
}
},
+ "No limit": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Sans limite"
+ }
+ }
+ }
+ },
"No logbook found for this account.": {
"localizations": {
"fr": {
@@ -2431,6 +2981,46 @@
}
}
},
+ "No stop: a direct ascent at %@ per minute.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Aucun palier : remontée directe à %@ par minute."
+ }
+ }
+ }
+ },
+ "No-stop": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Sans palier"
+ }
+ }
+ }
+ },
+ "No-stop time": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Temps sans palier"
+ }
+ }
+ }
+ },
+ "No-stop times on %@": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Temps sans palier avec %@"
+ }
+ }
+ }
+ },
"None": {
"localizations": {
"fr": {
@@ -2451,312 +3041,492 @@
}
}
},
- "Not in this version": {
+ "Not breathable above": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Non respirable au-dessus de"
+ }
+ }
+ }
+ },
+ "Not enough %@: %@ L needed, %@ L in the cylinder.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Pas assez de %@ : %@ L nécessaires, %@ L dans la bouteille."
+ }
+ }
+ }
+ },
+ "Not enough gas": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Pas assez de gaz"
+ }
+ }
+ }
+ },
+ "Not in this version": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Pas dans cette version"
+ }
+ }
+ }
+ },
+ "Not used": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Non utilisée"
+ }
+ }
+ }
+ },
+ "Not yet": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Pas encore"
+ }
+ }
+ }
+ },
+ "Notes": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Notes"
+ }
+ }
+ }
+ },
+ "Nothing new on %@ since the last download.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Rien de nouveau sur %@ depuis le dernier téléchargement."
+ }
+ }
+ }
+ },
+ "Number of dives per depth range": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Nombre de plongées par tranche de profondeur"
+ }
+ }
+ }
+ },
+ "Number of dives per duration range": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Nombre de plongées par tranche de durée"
+ }
+ }
+ }
+ },
+ "Number of dives per month of the year": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Nombre de plongées par mois de l'année"
+ }
+ }
+ }
+ },
+ "Number of dives per year": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Nombre de plongées par année"
+ }
+ }
+ }
+ },
+ "OK": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "OK"
+ }
+ }
+ }
+ },
+ "On the right: the run time when each stop ends.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "À droite : la durée totale écoulée à la fin de chaque palier."
+ }
+ }
+ }
+ },
+ "Open Settings": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Ouvrir les réglages"
+ }
+ }
+ }
+ },
+ "Open in Maps": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Ouvrir dans Plans"
+ }
+ }
+ }
+ },
+ "Or, without an account": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Ou, sans compte"
+ }
+ }
+ }
+ },
+ "Other computer": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Autre ordinateur"
+ }
+ }
+ }
+ },
+ "Oxygen": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Pas dans cette version"
+ "value": "Oxygène"
}
}
}
},
- "Not used": {
+ "Oxygen clock (CNS)": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Non utilisée"
+ "value": "Horloge oxygène (CNS)"
}
}
}
},
- "Not yet": {
+ "Oxygen clock at %@ %%.": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Pas encore"
+ "value": "Horloge oxygène à %@ %%."
}
}
}
},
- "Notes": {
+ "Oxygen limits": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Notes"
+ "value": "Limites d'oxygène"
}
}
}
},
- "Nothing new on %@ since the last download.": {
+ "Oxygen pressure": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Rien de nouveau sur %@ depuis le dernier téléchargement."
+ "value": "Pression d'oxygène"
}
}
}
},
- "Number of dives per depth range": {
+ "Oxygen units (OTU)": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Nombre de plongées par tranche de profondeur"
+ "value": "Unités d'oxygène (OTU)"
}
}
}
},
- "Number of dives per duration range": {
+ "Password": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Nombre de plongées par tranche de durée"
+ "value": "Mot de passe"
}
}
}
},
- "Number of dives per month of the year": {
+ "Password, again": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Nombre de plongées par mois de l'année"
+ "value": "Mot de passe, encore"
}
}
}
},
- "Number of dives per year": {
+ "Photo access is denied. You can turn it back on in Settings → Privacy → Photos.": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Nombre de plongées par année"
+ "value": "L'accès aux photos est refusé. Il se rétablit dans Réglages → Confidentialité → Photos."
}
}
}
},
- "OK": {
+ "Photos": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "OK"
+ "value": "Photos"
}
}
}
},
- "Open Settings": {
+ "Plan": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Ouvrir les réglages"
+ "value": "Plan"
}
}
}
},
- "Open in Maps": {
+ "Planning": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Ouvrir dans Plans"
+ "value": "Planification"
}
}
}
},
- "Or, without an account": {
+ "Poor visibility after the rain.": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Ou, sans compte"
+ "value": "Visibilité réduite après la pluie."
}
}
}
},
- "Other computer": {
+ "Position": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Autre ordinateur"
+ "value": "Position"
}
}
}
},
- "Oxygen": {
+ "Pressure": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Oxygène"
+ "value": "Pression"
}
}
}
},
- "Password": {
+ "Pressure at the surface": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Mot de passe"
+ "value": "Pression en surface"
}
}
}
},
- "Password, again": {
+ "Problem at the bottom": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Mot de passe, encore"
+ "value": "Problème au fond"
}
}
}
},
- "Photo access is denied. You can turn it back on in Settings → Privacy → Photos.": {
+ "Profile": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "L'accès aux photos est refusé. Il se rétablit dans Réglages → Confidentialité → Photos."
+ "value": "Profil"
}
}
}
},
- "Photos": {
+ "Put the computer in Bluetooth mode (on a Shearwater: Menu, then Bluetooth), keep it close to the iPhone, then tap its name. The dives are read with libdivecomputer; support has only been checked on a few models so far.": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Photos"
+ "value": "Mettez l'ordinateur en mode Bluetooth (sur un Shearwater : Menu, puis Bluetooth), gardez-le près de l'iPhone, puis touchez son nom. Les plongées sont lues avec libdivecomputer ; seuls quelques modèles ont été vérifiés pour l'instant."
}
}
}
},
- "Poor visibility after the rain.": {
+ "Rating": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Visibilité réduite après la pluie."
+ "value": "Évaluation"
}
}
}
},
- "Position": {
+ "Refresher dive, sea fans everywhere.": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Position"
+ "value": "Plongée de réadaptation, gorgones en éventail partout."
}
}
}
},
- "Pressure": {
+ "Remove the photo": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Pression"
+ "value": "Retirer la photo"
}
}
}
},
- "Profile": {
+ "Reserve": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Profil"
+ "value": "Réserve"
}
}
}
},
- "Put the computer in Bluetooth mode (on a Shearwater: Menu, then Bluetooth), keep it close to the iPhone, then tap its name. The dives are read with libdivecomputer; support has only been checked on a few models so far.": {
+ "Restore the iCloud backup (%lld dives, %@)": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Mettez l'ordinateur en mode Bluetooth (sur un Shearwater : Menu, puis Bluetooth), gardez-le près de l'iPhone, puis touchez son nom. Les plongées sont lues avec libdivecomputer ; seuls quelques modèles ont été vérifiés pour l'instant."
+ "value": "Restaurer la sauvegarde iCloud (%lld plongées, %@)"
}
}
}
},
- "Rating": {
+ "Rocky bottom and kelp": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Évaluation"
+ "value": "Fond de roche et laminaires"
}
}
}
},
- "Refresher dive, sea fans everywhere.": {
+ "Run time": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Plongée de réadaptation, gorgones en éventail partout."
+ "value": "Durée totale"
}
}
}
},
- "Remove the photo": {
+ "SAC": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Retirer la photo"
+ "value": "Conso."
}
}
}
},
- "Restore the iCloud backup (%lld dives, %@)": {
+ "Safety stop": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Restaurer la sauvegarde iCloud (%lld plongées, %@)"
+ "value": "Palier de sécurité"
}
}
}
},
- "Rocky bottom and kelp": {
+ "Safety stop when no stop is needed": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Fond de roche et laminaires"
+ "value": "Palier de sécurité quand aucun palier n'est requis"
}
}
}
},
- "SAC": {
+ "Save": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Conso."
+ "value": "Enregistrer"
}
}
}
},
- "Save": {
+ "Sea": {
"localizations": {
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Enregistrer"
+ "value": "Mer"
}
}
}
@@ -3031,6 +3801,16 @@
}
}
},
+ "Speeds": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Vitesses"
+ }
+ }
+ }
+ },
"Start": {
"localizations": {
"fr": {
@@ -3041,6 +3821,36 @@
}
}
},
+ "Start a new plan": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Recommencer un plan"
+ }
+ }
+ }
+ },
+ "Start a new plan?": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Recommencer un plan ?"
+ }
+ }
+ }
+ },
+ "Start over": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Recommencer"
+ }
+ }
+ }
+ },
"Statistics": {
"localizations": {
"fr": {
@@ -3061,6 +3871,16 @@
}
}
},
+ "Stops": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Paliers"
+ }
+ }
+ }
+ },
"Sub Rascasse can show the photos and videos taken during the dive here. They stay on your iPhone: nothing is uploaded.": {
"localizations": {
"fr": {
@@ -3171,6 +3991,26 @@
}
}
},
+ "Switch at": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Changement à"
+ }
+ }
+ }
+ },
+ "Switch depth by hand": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Profondeur de changement à la main"
+ }
+ }
+ }
+ },
"Sync now": {
"localizations": {
"fr": {
@@ -3421,6 +4261,16 @@
}
}
},
+ "The decompression does not end with these gases.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "La décompression ne se termine pas avec ces gaz."
+ }
+ }
+ }
+ },
"The deletion will be sent to the Subsurface cloud at the next sync.": {
"localizations": {
"fr": {
@@ -3461,6 +4311,16 @@
}
}
},
+ "The gas sets the limit.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "C'est le gaz qui limite."
+ }
+ }
+ }
+ },
"The iCloud backup failed: %@": {
"localizations": {
"fr": {
@@ -3501,6 +4361,26 @@
}
}
},
+ "The narcotic depth counts oxygen as narcotic as nitrogen. Density: 5.2 g/L is the recommended limit, 6.2 the one not to pass.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "La profondeur narcotique compte l'oxygène comme aussi narcotique que l'azote. Densité : 5,2 g/L est la limite recommandée, 6,2 celle à ne pas dépasser."
+ }
+ }
+ }
+ },
+ "The no-stop time sets the limit.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "C'est le temps sans palier qui limite."
+ }
+ }
+ }
+ },
"The selected dives are added to the logbook with their full profile, then uploaded to the Subsurface cloud. A dive that overlaps one already in the logbook joins it as one more dive computer; a dive the logbook already has from this computer is skipped.": {
"localizations": {
"fr": {
@@ -3591,6 +4471,36 @@
}
}
},
+ "Times count from leaving the surface, the descent included. The gas time keeps the reserve and what the ascent and a safety stop of 3 minutes at %@ take.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Les temps comptent depuis le départ de la surface, descente comprise. L'autonomie garde la réserve et ce que demandent la remontée et un palier de sécurité de 3 minutes à %@."
+ }
+ }
+ }
+ },
+ "Too deep for this gas: %@ should not be breathed below %@.": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Trop profond pour ce gaz : %@ ne doit pas être respiré au-delà de %@."
+ }
+ }
+ }
+ },
+ "Tool": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Outil"
+ }
+ }
+ }
+ },
"Total: %@": {
"localizations": {
"fr": {
@@ -3741,6 +4651,36 @@
}
}
},
+ "Up to %@ minutes": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Jusqu'à %@ minutes"
+ }
+ }
+ }
+ },
+ "Up to %lld minutes": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Jusqu'à %lld minutes"
+ }
+ }
+ }
+ },
+ "Use": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Utiliser"
+ }
+ }
+ }
+ },
"Use the account's logbook": {
"localizations": {
"fr": {
@@ -3751,6 +4691,16 @@
}
}
},
+ "Usual settings": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Réglages usuels"
+ }
+ }
+ }
+ },
"Verification": {
"localizations": {
"fr": {
@@ -4001,6 +4951,26 @@
}
}
},
+ "at %@ min": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "à %@ min"
+ }
+ }
+ }
+ },
+ "at %lld min": {
+ "localizations": {
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "à %lld min"
+ }
+ }
+ }
+ },
"belt": {
"localizations": {
"fr": {
diff --git a/App/Views/PlannerView.swift b/App/Views/PlannerView.swift
@@ -0,0 +1,368 @@
+// SPDX-License-Identifier: GPL-2.0-only
+import DivePlanner
+import SwiftUI
+
+/// Planning tools: a quick no-stop calculation, the decompression planner, and gas calculations.
+struct PlannerView: View {
+ enum Mode: String, CaseIterable { case simple, technical, gas }
+ @AppStorage("plannerMode") private var mode = LaunchOptions.value("-planner").flatMap(Mode.init(rawValue:)) ?? Mode.simple
+
+ var body: some View {
+ NavigationStack {
+ Group {
+ switch mode {
+ case .simple: SimplePlanView()
+ case .technical: TechPlanView()
+ case .gas: GasToolsView()
+ }
+ }
+ .navigationTitle("Planning")
+ .navigationBarTitleDisplayMode(.inline)
+ .safeAreaInset(edge: .top, spacing: 0) {
+ Picker("Tool", selection: $mode) {
+ Text("No-stop").tag(Mode.simple)
+ Text("Decompression").tag(Mode.technical)
+ Text("Gas").tag(Mode.gas)
+ }
+ .pickerStyle(.segmented)
+ .padding(.horizontal)
+ .padding(.vertical, 8)
+ .background(.bar)
+ }
+ }
+ .onAppear {
+ if let forced = LaunchOptions.value("-planner").flatMap(Mode.init(rawValue:)) { mode = forced }
+ }
+ }
+}
+
+/// A figure with a fixed number of decimals, written the way the user's region writes numbers.
+func fixed(_ value: Double, _ digits: Int) -> String {
+ value.formatted(.number.precision(.fractionLength(digits)))
+}
+
+/// What every planning screen ends with.
+struct PlanningDisclaimer: View {
+ var body: some View {
+ Text("A planning aid, not a dive computer: models differ, and so do divers. Check a decompression plan against another tool, dive within your training, and follow your dive computer in the water.")
+ }
+}
+
+/// A number with its unit on one row of a form.
+struct NumberRow: View {
+ let title: LocalizedStringKey
+ @Binding var value: Double
+ let unit: String
+ var digits = 0
+ var range: ClosedRange<Double>?
+ var step: Double?
+
+ var body: some View {
+ HStack {
+ Text(title)
+ Spacer(minLength: 8)
+ TextField("0", value: clamped, format: .number.precision(.fractionLength(0...digits)))
+ .keyboardType(.decimalPad)
+ .multilineTextAlignment(.trailing)
+ .frame(width: 72)
+ Text(unit).foregroundStyle(.secondary).frame(minWidth: 34, alignment: .leading)
+ if let step {
+ Stepper(title, value: clamped, step: step).labelsHidden()
+ }
+ }
+ }
+
+ private var clamped: Binding<Double> {
+ Binding {
+ value
+ } set: { new in
+ value = range.map { min(max(new, $0.lowerBound), $0.upperBound) } ?? new
+ }
+ }
+}
+
+extension Units {
+ /// A depth kept in metres, edited in the units on screen (whole feet, or tenths of a metre).
+ func depthBinding(_ meters: Binding<Double>) -> Binding<Double> {
+ Binding {
+ let shown = depthValue(meters.wrappedValue)
+ return imperial ? shown.rounded() : (shown * 10).rounded() / 10
+ } set: {
+ meters.wrappedValue = max(0, metersFromDisplay($0))
+ }
+ }
+
+ func pressureBinding(_ bar: Binding<Double>) -> Binding<Double> {
+ Binding {
+ pressureValue(bar.wrappedValue).rounded()
+ } set: {
+ bar.wrappedValue = max(0, barFromDisplay($0))
+ }
+ }
+
+ /// Step of a depth stepper, in the units on screen.
+ var depthStep: Double { imperial ? 5 : 1 }
+}
+
+/// Gradient factors by name, the way dive computers offer them.
+enum Conservatism: String, CaseIterable, Identifiable {
+ case low, medium, high
+ var id: String { rawValue }
+ var gradientFactors: (low: Double, high: Double) {
+ switch self {
+ case .low: return (0.45, 0.95)
+ case .medium: return (0.40, 0.85)
+ case .high: return (0.35, 0.75)
+ }
+ }
+ var label: String {
+ switch self {
+ case .low: return String(localized: "Low (GF 45/95)")
+ case .medium: return String(localized: "Medium (GF 40/85)")
+ case .high: return String(localized: "High (GF 35/75)")
+ }
+ }
+}
+
+struct CylinderPreset: Identifiable {
+ let name: String
+ let liters: Double
+ let bar: Double
+ var id: String { name }
+ static let all = [
+ CylinderPreset(name: "AL80", liters: 11.1, bar: 207), CylinderPreset(name: "AL63", liters: 9.0, bar: 207),
+ CylinderPreset(name: "AL40", liters: 5.7, bar: 207), CylinderPreset(name: "HP100", liters: 12.9, bar: 237),
+ CylinderPreset(name: "HP130", liters: 16.8, bar: 237), CylinderPreset(name: "10 L", liters: 10, bar: 232),
+ CylinderPreset(name: "12 L", liters: 12, bar: 232), CylinderPreset(name: "15 L", liters: 15, bar: 232),
+ CylinderPreset(name: "2 × 12 L", liters: 24, bar: 232),
+ ]
+}
+
+// MARK: No-stop diving
+
+/// The quick answer for a recreational dive: how long at this depth, on this gas, with this cylinder.
+struct SimplePlanView: View {
+ @Environment(AppModel.self) private var model
+ @AppStorage("simplePlanDepth") private var depth = 18.0
+ @AppStorage("simplePlanO2") private var o2 = 21.0
+ @AppStorage("simplePlanVolume") private var volume = 11.1
+ @AppStorage("simplePlanPressure") private var pressure = 200.0
+ @AppStorage("simplePlanReserve") private var reserve = 50.0
+ @AppStorage("simplePlanSAC") private var sac = 18.0
+ @AppStorage("simplePlanConservatism") private var conservatism = Conservatism.medium
+ @AppStorage("simplePlanFreshWater") private var freshWater = false
+ @State private var table: [(depth: Double, minutes: Int?)] = []
+
+ private var gas: BreathingGas { BreathingGas(o2: o2 / 100) }
+
+ private var settings: PlanSettings {
+ var settings = PlanSettings()
+ settings.gfLow = conservatism.gradientFactors.low
+ settings.gfHigh = conservatism.gradientFactors.high
+ settings.sacBottom = sac
+ settings.sacDeco = sac
+ settings.environment = freshWater ? .freshWater : .sea
+ return settings
+ }
+
+ var body: some View {
+ let units = model.units
+ let settings = settings
+ let noStop = DivePlanner.noStopLimit(depth: depth, gas: gas, settings: settings)
+ let gasTime = DivePlanner.gasLimit(depth: depth, volumeLiters: volume, startBar: pressure, reserveBar: reserve, settings: settings)
+ let ppO2 = gas.ppO2(atDepth: depth, in: settings.environment)
+ let mod = gas.maximumOperatingDepth(ppO2: 1.4, in: settings.environment)
+ Form {
+ Section {
+ NumberRow(title: "Depth", value: units.depthBinding($depth), unit: units.depthUnit, digits: units.imperial ? 0 : 1,
+ range: 0...units.depthValue(60), step: units.depthStep)
+ Picker("Gas", selection: $o2) {
+ Text("Air").tag(21.0)
+ Text(verbatim: "EAN32").tag(32.0)
+ Text(verbatim: "EAN36").tag(36.0)
+ if ![21, 32, 36].contains(o2) { Text(verbatim: gas.name).tag(o2) }
+ }
+ NumberRow(title: "Oxygen", value: $o2, unit: "%", range: 21...40, step: 1)
+ }
+
+ Section {
+ answer(noStop: noStop, gasTime: gasTime)
+ Grid(horizontalSpacing: 8, verticalSpacing: 8) {
+ GridRow {
+ Figure(title: "No-stop time", value: noStop.map { String(localized: "\($0) min") } ?? String(localized: "No limit"), icon: "timer")
+ Figure(title: "Gas lasts", value: String(localized: "\(gasTime) min"), icon: "gauge.with.dots.needle.33percent")
+ }
+ GridRow {
+ Figure(title: "Oxygen pressure", value: fixed(ppO2, 2) + " bar", icon: "o.circle")
+ Figure(title: "Deepest for this gas", value: units.depth(mod), icon: "arrow.down.to.line")
+ }
+ }
+ .listRowInsets(EdgeInsets(top: 8, leading: 12, bottom: 8, trailing: 12))
+ if ppO2 > 1.4 {
+ Label("Too deep for this gas: \(gas.name) should not be breathed below \(units.depth(mod)).", systemImage: "exclamationmark.triangle.fill")
+ .foregroundStyle(.red)
+ .font(.callout)
+ }
+ } header: {
+ Text("Answer")
+ } footer: {
+ Text("Times count from leaving the surface, the descent included. The gas time keeps the reserve and what the ascent and a safety stop of 3 minutes at \(units.depth(5)) take.")
+ }
+
+ Section("Cylinder") {
+ Menu {
+ ForEach(CylinderPreset.all) { preset in
+ Button(preset.name) { volume = preset.liters }
+ }
+ } label: {
+ Label("Common cylinders", systemImage: "list.bullet")
+ }
+ NumberRow(title: "Volume", value: $volume, unit: "L", digits: 1, range: 1...50)
+ NumberRow(title: "Pressure", value: units.pressureBinding($pressure), unit: units.pressureUnit, range: 0...units.pressureValue(350))
+ NumberRow(title: "Reserve", value: units.pressureBinding($reserve), unit: units.pressureUnit, range: 0...units.pressureValue(150))
+ NumberRow(title: "Consumption at the surface", value: $sac, unit: "L/min", digits: 1, range: 5...60, step: 1)
+ }
+
+ Section {
+ Picker("Conservatism", selection: $conservatism) {
+ ForEach(Conservatism.allCases) { Text($0.label).tag($0) }
+ }
+ Toggle("Fresh water", isOn: $freshWater)
+ }
+
+ Section {
+ ForEach(table, id: \.depth) { row in
+ HStack {
+ Text(units.depth(row.depth))
+ Spacer()
+ Text(row.minutes.map { String(localized: "\($0) min") } ?? String(localized: "No limit"))
+ .monospacedDigit()
+ .foregroundStyle(abs(row.depth - depth) < 1.5 ? Color.accentColor : Color.primary)
+ }
+ }
+ } header: {
+ Text("No-stop times on \(gas.name)")
+ } footer: {
+ PlanningDisclaimer()
+ }
+ }
+ .task(id: "\(o2)-\(conservatism.rawValue)-\(freshWater)") {
+ let gas = gas
+ table = await Task.detached {
+ stride(from: 12.0, through: 42.0, by: 3.0).map { ($0, DivePlanner.noStopLimit(depth: $0, gas: gas, settings: settings)) }
+ }.value
+ }
+ }
+
+ /// One sentence: how long, and what sets the limit.
+ @ViewBuilder private func answer(noStop: Int?, gasTime: Int) -> some View {
+ let limit = min(noStop ?? .max, gasTime)
+ VStack(alignment: .leading, spacing: 4) {
+ Text(limit > 0 ? String(localized: "Up to \(limit) minutes") : String(localized: "Not enough gas"))
+ .font(.title2.weight(.semibold))
+ Text((noStop ?? .max) <= gasTime
+ ? String(localized: "The no-stop time sets the limit.")
+ : String(localized: "The gas sets the limit."))
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ }
+ .padding(.vertical, 2)
+ }
+}
+
+// MARK: Gas
+
+/// Figures about a mix: how deep, how narcotic, how dense; and the best mix for a depth.
+struct GasToolsView: View {
+ @Environment(AppModel.self) private var model
+ @AppStorage("gasToolO2") private var o2 = 32.0
+ @AppStorage("gasToolHe") private var he = 0.0
+ @AppStorage("gasToolDepth") private var depth = 30.0
+ @AppStorage("gasToolBestDepth") private var bestDepth = 45.0
+ @AppStorage("gasToolBestPO2") private var bestPO2 = 1.4
+ @AppStorage("gasToolLimitEND") private var limitEND = true
+ @AppStorage("gasToolSAC") private var sac = 18.0
+ @AppStorage("gasToolMinutes") private var minutes = 30.0
+ @AppStorage("gasToolVolume") private var volume = 11.1
+
+ var body: some View {
+ let units = model.units
+ let gas = BreathingGas(o2: o2 / 100, he: he / 100)
+ let ppO2 = gas.ppO2(atDepth: depth)
+ let density = gas.density(atDepth: depth)
+ let best = BreathingGas.bestMix(forDepth: bestDepth, ppO2: bestPO2, maximumEND: limitEND ? 30 : nil)
+ let liters = sac * DiveEnvironment.sea.pressure(atDepth: depth) * minutes
+ Form {
+ Section {
+ NumberRow(title: "Oxygen", value: $o2, unit: "%", range: 5...100, step: 1)
+ NumberRow(title: "Helium", value: $he, unit: "%", range: 0...(100 - o2), step: 1)
+ NumberRow(title: "Depth", value: units.depthBinding($depth), unit: units.depthUnit, digits: units.imperial ? 0 : 1,
+ range: 0...units.depthValue(150), step: units.depthStep)
+ } header: {
+ Text(verbatim: gas.name)
+ }
+
+ Section("At this depth") {
+ row("Oxygen pressure", fixed(ppO2, 2) + " bar", alert: ppO2 > 1.6 ? .red : (ppO2 > 1.4 ? .orange : (ppO2 < 0.16 ? .red : nil)))
+ row("Equivalent narcotic depth", units.depth(gas.equivalentNarcoticDepth(atDepth: depth)),
+ alert: gas.equivalentNarcoticDepth(atDepth: depth) > 30.5 ? .orange : nil)
+ if he == 0, o2 > 21 { row("Equivalent air depth", units.depth(gas.equivalentAirDepth(atDepth: depth))) }
+ row("Gas density", fixed(density, 1) + " g/L", alert: density > 6.2 ? .red : (density > 5.2 ? .orange : nil))
+ }
+
+ Section {
+ row("Bottom gas (1.4 bar)", units.depth(gas.maximumOperatingDepth(ppO2: 1.4)))
+ row("Decompression (1.6 bar)", units.depth(gas.maximumOperatingDepth(ppO2: 1.6)))
+ if gas.minimumDepth() > 0 { row("Not breathable above", units.depth(gas.minimumDepth()), alert: .orange) }
+ } header: {
+ Text("Maximum depth")
+ } footer: {
+ Text("The narcotic depth counts oxygen as narcotic as nitrogen. Density: 5.2 g/L is the recommended limit, 6.2 the one not to pass.")
+ }
+
+ Section {
+ NumberRow(title: "Depth", value: units.depthBinding($bestDepth), unit: units.depthUnit, digits: units.imperial ? 0 : 1,
+ range: 0...units.depthValue(150), step: units.depthStep)
+ Picker("Oxygen pressure", selection: $bestPO2) {
+ ForEach([1.2, 1.3, 1.4, 1.5, 1.6], id: \.self) { Text(fixed($0, 1) + " bar").tag($0) }
+ }
+ Toggle("Keep the narcotic depth at \(units.depth(30))", isOn: $limitEND)
+ HStack {
+ Text("Best mix")
+ Spacer()
+ Text(verbatim: best.name).font(.headline)
+ Button("Use") {
+ o2 = Double(best.o2Percent)
+ he = Double(best.hePercent)
+ depth = bestDepth
+ }
+ .buttonStyle(.bordered)
+ .controlSize(.small)
+ }
+ } header: {
+ Text("Best mix for a depth")
+ }
+
+ Section {
+ NumberRow(title: "Consumption at the surface", value: $sac, unit: "L/min", digits: 1, range: 5...60, step: 1)
+ NumberRow(title: "Time", value: $minutes, unit: "min", range: 0...600, step: 5)
+ NumberRow(title: "Cylinder", value: $volume, unit: "L", digits: 1, range: 1...50)
+ row("Gas needed", fixed(liters, 0) + " L")
+ row("In this cylinder", units.pressure(liters / max(volume, 0.1)))
+ } header: {
+ Text("Consumption at \(units.depth(depth))")
+ } footer: {
+ PlanningDisclaimer()
+ }
+ }
+ }
+
+ private func row(_ title: LocalizedStringKey, _ value: String, alert: Color? = nil) -> some View {
+ HStack {
+ Text(title)
+ Spacer()
+ if alert != nil { Image(systemName: "exclamationmark.triangle.fill").foregroundStyle(alert ?? .orange) }
+ Text(value).monospacedDigit().foregroundStyle(alert ?? Color.secondary)
+ }
+ }
+}
diff --git a/App/Views/RootView.swift b/App/Views/RootView.swift
@@ -19,6 +19,9 @@ struct RootView: View {
SitesView()
.tabItem { Label("Sites", systemImage: "map") }
.tag("sites")
+ PlannerView()
+ .tabItem { Label("Planning", systemImage: "point.topleft.down.to.point.bottomright.curvepath") }
+ .tag("plan")
StatsView()
.tabItem { Label("Statistics", systemImage: "chart.bar") }
.tag("stats")
diff --git a/App/Views/TechPlanView.swift b/App/Views/TechPlanView.swift
@@ -0,0 +1,468 @@
+// SPDX-License-Identifier: GPL-2.0-only
+import Charts
+import DivePlanner
+import SwiftUI
+
+/// The decompression planner: levels and cylinders in, stops, gas and warnings out.
+struct TechPlanView: View {
+ @Environment(AppModel.self) private var model
+ @State private var plan = TechPlanView.stored()
+ @State private var result = PlanResult()
+ @State private var confirmingReset = false
+
+ private static let storageKey = "divePlan"
+
+ /// The plan the planner starts with: one level on one cylinder, one decompression gas.
+ static var starter: DivePlan {
+ DivePlan(levels: [PlanLevel(depth: 45, minutes: 25)],
+ cylinders: [PlanCylinder(gas: BreathingGas(o2Percent: 21, hePercent: 35), volumeLiters: 24, startBar: 220),
+ PlanCylinder(gas: BreathingGas(o2Percent: 50), volumeLiters: 11.1, startBar: 200, isDeco: true)])
+ }
+
+ private static func stored() -> DivePlan {
+ guard !LaunchOptions.flag("-starterPlan"), let data = UserDefaults.standard.data(forKey: storageKey),
+ let plan = try? JSONDecoder().decode(DivePlan.self, from: data), !plan.cylinders.isEmpty else { return starter }
+ return plan
+ }
+
+ var body: some View {
+ let units = model.units
+ Form {
+ Section {
+ ForEach($plan.levels) { $level in
+ VStack(spacing: 8) {
+ NumberRow(title: "Depth", value: units.depthBinding($level.depth), unit: units.depthUnit, digits: units.imperial ? 0 : 1,
+ range: 0...units.depthValue(200), step: units.depthStep)
+ NumberRow(title: "Time", value: $level.minutes, unit: "min", range: 0...600, step: 1)
+ Picker("Cylinder", selection: $level.cylinder) {
+ ForEach(Array(plan.cylinders.enumerated()), id: \.offset) { index, cylinder in
+ Text(verbatim: cylinder.gas.name).tag(index)
+ }
+ }
+ }
+ }
+ .onDelete { plan.levels.remove(atOffsets: $0) }
+ .deleteDisabled(plan.levels.count < 2)
+ Button {
+ let last = plan.levels.last
+ plan.levels.append(PlanLevel(depth: max(6, (last?.depth ?? 30) - 15), minutes: 10, cylinder: last?.cylinder ?? 0))
+ } label: {
+ Label("Add a level", systemImage: "plus.circle")
+ }
+ } header: {
+ Text("Dive")
+ } footer: {
+ Text("Each time counts from leaving the previous depth: the way down, or up, is part of it.")
+ }
+
+ Section {
+ ForEach($plan.cylinders) { $cylinder in
+ NavigationLink {
+ PlanCylinderEditor(cylinder: $cylinder, settings: plan.settings)
+ } label: {
+ cylinderLabel(cylinder, units)
+ }
+ }
+ .onDelete(perform: removeCylinders)
+ .deleteDisabled(plan.cylinders.count < 2)
+ Button {
+ plan.cylinders.append(PlanCylinder(gas: .oxygen, volumeLiters: 5.7, startBar: 200, isDeco: true))
+ } label: {
+ Label("Add a cylinder", systemImage: "plus.circle")
+ }
+ } header: {
+ Text("Cylinders")
+ }
+
+ Section {
+ NavigationLink {
+ PlanSettingsEditor(settings: $plan.settings)
+ } label: {
+ HStack {
+ Text("Settings")
+ Spacer()
+ Text(verbatim: "GF \(Int((plan.settings.gfLow * 100).rounded()))/\(Int((plan.settings.gfHigh * 100).rounded()))")
+ .foregroundStyle(.secondary)
+ }
+ }
+ }
+
+ summary(units)
+ if result.points.count > 1 {
+ Section("Profile") {
+ PlanChart(result: result, plan: plan, units: units)
+ .frame(height: 200)
+ .listRowInsets(EdgeInsets(top: 12, leading: 8, bottom: 8, trailing: 12))
+ }
+ }
+ stops(units)
+ gasSection(units)
+
+ Section {
+ Button("Start a new plan", role: .destructive) { confirmingReset = true }
+ } footer: {
+ VStack(alignment: .leading, spacing: 6) {
+ Text("Bühlmann ZHL-16C with gradient factors, open circuit, computed the way Subsurface's planner does.")
+ PlanningDisclaimer()
+ }
+ }
+ }
+ .confirmationDialog("Start a new plan?", isPresented: $confirmingReset, titleVisibility: .visible) {
+ Button("Start over", role: .destructive) { plan = Self.starter }
+ }
+ .task(id: plan) {
+ if let data = try? JSONEncoder().encode(plan) { UserDefaults.standard.set(data, forKey: Self.storageKey) }
+ let current = plan
+ let computed = await Task.detached(priority: .userInitiated) { DivePlanner.plan(current) }.value
+ if !Task.isCancelled { result = computed }
+ }
+ }
+
+ // MARK: Results
+
+ @ViewBuilder private func summary(_ units: Units) -> some View {
+ Section {
+ Grid(horizontalSpacing: 8, verticalSpacing: 8) {
+ GridRow {
+ Figure(title: "Run time", value: Units.duration(Int(result.runtime.rounded())), icon: "timer")
+ Figure(title: "Ascent and stops", value: Units.duration(Int(result.ascentTime.rounded())), icon: "arrow.up.to.line")
+ }
+ GridRow {
+ Figure(title: "Oxygen clock (CNS)", value: fixed(result.cns * 100, 0) + " %%", icon: "o.circle")
+ Figure(title: "Oxygen units (OTU)", value: fixed(result.otu, 0), icon: "lungs")
+ }
+ }
+ .listRowInsets(EdgeInsets(top: 8, leading: 12, bottom: 8, trailing: 12))
+ ForEach(Array(result.warnings.enumerated()), id: \.offset) { _, warning in
+ Label(describe(warning, units), systemImage: "exclamationmark.triangle.fill")
+ .font(.callout)
+ .foregroundStyle(isSevere(warning) ? Color.red : Color.orange)
+ }
+ } header: {
+ Text("Plan")
+ }
+ }
+
+ @ViewBuilder private func stops(_ units: Units) -> some View {
+ Section {
+ if result.stops.isEmpty {
+ Text("No stop: a direct ascent at \(units.depth(plan.settings.ascentRate)) per minute.")
+ .foregroundStyle(.secondary)
+ }
+ ForEach(Array(result.stops.enumerated()), id: \.offset) { _, stop in
+ HStack {
+ Text(units.depth(stop.depth))
+ .font(.body.monospacedDigit().weight(.medium))
+ .frame(width: 64, alignment: .leading)
+ VStack(alignment: .leading, spacing: 2) {
+ Text(String(localized: "\(Int((stop.seconds / 60).rounded())) min"))
+ .monospacedDigit()
+ if stop.kind != .deco {
+ Text(stop.kind == .safety ? String(localized: "Safety stop") : String(localized: "Gas switch"))
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ }
+ Spacer()
+ Text(verbatim: plan.cylinders.indices.contains(stop.cylinder) ? plan.cylinders[stop.cylinder].gas.name : "")
+ .foregroundStyle(.green)
+ Text(String(localized: "at \(Int((stop.endTime / 60).rounded())) min"))
+ .font(.caption.monospacedDigit())
+ .foregroundStyle(.secondary)
+ .frame(width: 78, alignment: .trailing)
+ }
+ }
+ } header: {
+ Text("Stops")
+ } footer: {
+ if !result.stops.isEmpty { Text("On the right: the run time when each stop ends.") }
+ }
+ }
+
+ @ViewBuilder private func gasSection(_ units: Units) -> some View {
+ Section {
+ ForEach(Array(plan.cylinders.enumerated()), id: \.offset) { index, cylinder in
+ let used = result.gasUsed.indices.contains(index) ? result.gasUsed[index] : 0
+ HStack {
+ Text(verbatim: cylinder.gas.name).frame(width: 84, alignment: .leading)
+ VStack(alignment: .leading, spacing: 2) {
+ Text(fixed(used, 0) + " L").monospacedDigit()
+ if let volume = cylinder.volumeLiters, volume > 0, let start = cylinder.startBar {
+ let left = start - used / volume
+ Text(String(localized: "\(units.pressure(used / volume)) used, \(units.pressure(max(0, left))) left"))
+ .font(.caption)
+ .foregroundStyle(left < 0 ? Color.red : Color.secondary)
+ }
+ }
+ Spacer()
+ }
+ }
+ if let minimum = result.minimumGasLiters, plan.cylinders.indices.contains(result.bottomCylinder) {
+ let cylinder = plan.cylinders[result.bottomCylinder]
+ HStack {
+ Text("Minimum gas")
+ Spacer()
+ Text(cylinder.volumeLiters.map { units.pressure(minimum / max($0, 0.1)) } ?? fixed(minimum, 0) + " L")
+ .monospacedDigit()
+ .foregroundStyle(.secondary)
+ }
+ }
+ } header: {
+ Text("Gas")
+ } footer: {
+ Text("Minimum gas: what must be left in \(plan.cylinders.indices.contains(result.bottomCylinder) ? plan.cylinders[result.bottomCylinder].gas.name : "") when leaving the bottom, for \(Int(plan.settings.problemMinutes)) minutes on a problem and the ascent to the first gas switch, at \(fixed(plan.settings.minimumGasFactor, 0)) times the consumption.")
+ }
+ }
+
+ private func cylinderLabel(_ cylinder: PlanCylinder, _ units: Units) -> some View {
+ HStack {
+ Text(verbatim: cylinder.gas.name).font(.body.weight(.medium))
+ Spacer()
+ VStack(alignment: .trailing, spacing: 2) {
+ if let volume = cylinder.volumeLiters, let start = cylinder.startBar {
+ Text(verbatim: "\(units.volume(volume)) · \(units.pressure(start))").font(.callout)
+ }
+ Text(cylinder.isDeco
+ ? String(localized: "Decompression, from \(units.depth(cylinder.switchDepth ?? cylinder.gas.switchDepth(ppO2: plan.settings.ppO2Deco, in: plan.settings.environment)))")
+ : String(localized: "Bottom gas"))
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ }
+ }
+
+ private func removeCylinders(at offsets: IndexSet) {
+ for index in offsets.sorted(by: >) where plan.cylinders.count > 1 {
+ plan.cylinders.remove(at: index)
+ for level in plan.levels.indices {
+ if plan.levels[level].cylinder == index {
+ plan.levels[level].cylinder = 0
+ } else if plan.levels[level].cylinder > index {
+ plan.levels[level].cylinder -= 1
+ }
+ }
+ }
+ }
+
+ private func isSevere(_ warning: PlanWarning) -> Bool {
+ switch warning {
+ case .oxygenTooHigh, .oxygenTooLow, .notEnoughGas, .endless, .unknownCylinder: return true
+ case .narcosis, .density, .underMinimumGas, .cnsHigh: return false
+ }
+ }
+
+ private func describe(_ warning: PlanWarning, _ units: Units) -> String {
+ func name(_ index: Int) -> String { plan.cylinders.indices.contains(index) ? plan.cylinders[index].gas.name : "?" }
+ switch warning {
+ case .oxygenTooHigh(let cylinder, let depth, let ppO2):
+ return String(localized: "\(name(cylinder)) at \(units.depth(depth)): oxygen at \(fixed(ppO2, 2)) bar, above the limit.")
+ case .oxygenTooLow(let cylinder, let depth, let ppO2):
+ return String(localized: "\(name(cylinder)) at \(units.depth(depth)): only \(fixed(ppO2, 2)) bar of oxygen, not breathable there.")
+ case .narcosis(let cylinder, let depth, let end):
+ return String(localized: "\(name(cylinder)) at \(units.depth(depth)): as narcotic as air at \(units.depth(end)).")
+ case .density(let cylinder, let depth, let density):
+ return String(localized: "\(name(cylinder)) at \(units.depth(depth)): gas density \(fixed(density, 1)) g/L.")
+ case .notEnoughGas(let cylinder, let needed, let available):
+ return String(localized: "Not enough \(name(cylinder)): \(fixed(needed, 0)) L needed, \(fixed(available, 0)) L in the cylinder.")
+ case .underMinimumGas(let cylinder, let left, let minimum):
+ return String(localized: "\(name(cylinder)): \(units.pressure(left)) left when leaving the bottom, under the minimum gas of \(units.pressure(minimum)).")
+ case .cnsHigh(let percent):
+ return String(localized: "Oxygen clock at \(fixed(percent, 0)) %.")
+ case .unknownCylinder:
+ return String(localized: "A level uses a cylinder that is no longer in the list.")
+ case .endless:
+ return String(localized: "The decompression does not end with these gases.")
+ }
+ }
+}
+
+/// The planned profile, with the gas switches.
+private struct PlanChart: View {
+ let result: PlanResult
+ let plan: DivePlan
+ let units: Units
+
+ var body: some View {
+ let switches = result.points.enumerated().compactMap { index, point -> PlanPoint? in
+ index > 0 && result.points[index - 1].cylinder != point.cylinder ? point : nil
+ }
+ Chart {
+ ForEach(Array(result.points.enumerated()), id: \.offset) { _, point in
+ AreaMark(x: .value("Time", point.time / 60), y: .value("Depth", -units.depthValue(point.depth)))
+ .foregroundStyle(Color.accentColor.opacity(0.18))
+ LineMark(x: .value("Time", point.time / 60), y: .value("Depth", -units.depthValue(point.depth)))
+ .foregroundStyle(Color.accentColor)
+ .lineStyle(StrokeStyle(lineWidth: 2))
+ }
+ ForEach(Array(switches.enumerated()), id: \.offset) { _, point in
+ PointMark(x: .value("Time", point.time / 60), y: .value("Depth", -units.depthValue(point.depth)))
+ .foregroundStyle(.green)
+ .annotation(position: .top, spacing: 2) {
+ Text(verbatim: plan.cylinders.indices.contains(point.cylinder) ? plan.cylinders[point.cylinder].gas.name : "")
+ .font(.caption2)
+ .foregroundStyle(.green)
+ }
+ }
+ }
+ .chartYAxis {
+ AxisMarks(position: .leading) { value in
+ AxisGridLine()
+ AxisValueLabel {
+ if let depth = value.as(Double.self) { Text(verbatim: "\(Int(-depth)) \(units.depthUnit)") }
+ }
+ }
+ }
+ .chartXAxis {
+ AxisMarks { value in
+ AxisGridLine()
+ AxisValueLabel {
+ if let minute = value.as(Double.self) { Text(verbatim: "\(Int(minute))′") }
+ }
+ }
+ }
+ }
+}
+
+/// One cylinder of the plan.
+private struct PlanCylinderEditor: View {
+ @Environment(AppModel.self) private var model
+ @Binding var cylinder: PlanCylinder
+ let settings: PlanSettings
+
+ var body: some View {
+ let units = model.units
+ let automatic = cylinder.gas.switchDepth(ppO2: settings.ppO2Deco, in: settings.environment)
+ Form {
+ Section {
+ NumberRow(title: "Oxygen", value: percent(\.o2), unit: "%", range: 5...100, step: 1)
+ NumberRow(title: "Helium", value: percent(\.he), unit: "%", range: 0...95, step: 1)
+ } header: {
+ Text(verbatim: cylinder.gas.name)
+ } footer: {
+ Text("Deepest: \(units.depth(cylinder.gas.maximumOperatingDepth(ppO2: settings.ppO2Bottom, in: settings.environment))) at \(fixed(settings.ppO2Bottom, 1)) bar, \(units.depth(cylinder.gas.maximumOperatingDepth(ppO2: settings.ppO2Deco, in: settings.environment))) at \(fixed(settings.ppO2Deco, 1)) bar.")
+ }
+ Section("Cylinder") {
+ Menu {
+ ForEach(CylinderPreset.all) { preset in
+ Button(preset.name) {
+ cylinder.volumeLiters = preset.liters
+ if cylinder.startBar == nil { cylinder.startBar = 200 }
+ }
+ }
+ } label: {
+ Label("Common cylinders", systemImage: "list.bullet")
+ }
+ NumberRow(title: "Volume", value: optional(\.volumeLiters), unit: "L", digits: 1, range: 0...60)
+ NumberRow(title: "Pressure", value: units.pressureBinding(optional(\.startBar)), unit: units.pressureUnit, range: 0...units.pressureValue(350))
+ }
+ Section {
+ Toggle("Decompression gas", isOn: $cylinder.isDeco)
+ if cylinder.isDeco {
+ Toggle("Switch depth by hand", isOn: Binding(get: { cylinder.switchDepth != nil },
+ set: { cylinder.switchDepth = $0 ? automatic : nil }))
+ if cylinder.switchDepth != nil {
+ NumberRow(title: "Switch at", value: units.depthBinding(optional(\.switchDepth)), unit: units.depthUnit,
+ range: 0...units.depthValue(150), step: units.imperial ? 10 : 3)
+ } else {
+ LabeledContent("Switch at", value: units.depth(automatic))
+ }
+ }
+ } footer: {
+ Text("A decompression gas is taken on the way up, from its switch depth. Without a depth set by hand, that is where its oxygen reaches \(fixed(settings.ppO2Deco, 1)) bar.")
+ }
+ }
+ .navigationTitle(cylinder.gas.name)
+ .navigationBarTitleDisplayMode(.inline)
+ }
+
+ private func percent(_ path: WritableKeyPath<BreathingGas, Double>) -> Binding<Double> {
+ Binding {
+ (cylinder.gas[keyPath: path] * 100).rounded()
+ } set: { new in
+ var o2 = cylinder.gas.o2, he = cylinder.gas.he
+ if path == \BreathingGas.o2 { o2 = new / 100 } else { he = new / 100 }
+ cylinder.gas = BreathingGas(o2: o2, he: he)
+ }
+ }
+
+ private func optional(_ path: WritableKeyPath<PlanCylinder, Double?>) -> Binding<Double> {
+ Binding {
+ cylinder[keyPath: path] ?? 0
+ } set: {
+ cylinder[keyPath: path] = $0 > 0 ? $0 : nil
+ }
+ }
+}
+
+private struct PlanSettingsEditor: View {
+ @Environment(AppModel.self) private var model
+ @Binding var settings: PlanSettings
+
+ var body: some View {
+ let units = model.units
+ Form {
+ Section {
+ Menu {
+ ForEach(Conservatism.allCases) { level in
+ Button(level.label) {
+ settings.gfLow = level.gradientFactors.low
+ settings.gfHigh = level.gradientFactors.high
+ }
+ }
+ } label: {
+ Label("Usual settings", systemImage: "list.bullet")
+ }
+ NumberRow(title: "GF low", value: fraction(\.gfLow), unit: "%", range: 10...100, step: 5)
+ NumberRow(title: "GF high", value: fraction(\.gfHigh), unit: "%", range: 10...100, step: 5)
+ } header: {
+ Text("Gradient factors")
+ } footer: {
+ Text("Lower figures are more conservative. The low factor sets how deep the first stop is, the high one how much is left on surfacing.")
+ }
+ Section("Speeds") {
+ NumberRow(title: "Descent", value: units.depthBinding($settings.descentRate), unit: "\(units.depthUnit)/min", range: 1...units.depthValue(40), step: units.depthStep)
+ NumberRow(title: "Ascent", value: units.depthBinding($settings.ascentRate), unit: "\(units.depthUnit)/min", range: 1...units.depthValue(18), step: units.depthStep)
+ NumberRow(title: "Ascent above \(units.depth(6))", value: units.depthBinding($settings.ascentRateLast6m), unit: "\(units.depthUnit)/min",
+ range: 1...units.depthValue(18), step: units.depthStep)
+ }
+ Section("Stops") {
+ Toggle("Last stop at \(units.depth(6))", isOn: $settings.lastStopAt6m)
+ Toggle("Safety stop when no stop is needed", isOn: $settings.safetyStop)
+ NumberRow(title: "Gas switch", value: $settings.gasSwitchSeconds, unit: "s", range: 0...300, step: 30)
+ }
+ Section("Consumption at the surface") {
+ NumberRow(title: "At the bottom", value: $settings.sacBottom, unit: "L/min", digits: 1, range: 5...60, step: 1)
+ NumberRow(title: "Ascent and stops", value: $settings.sacDeco, unit: "L/min", digits: 1, range: 5...60, step: 1)
+ }
+ Section {
+ NumberRow(title: "Problem at the bottom", value: $settings.problemMinutes, unit: "min", range: 0...10, step: 1)
+ NumberRow(title: "Consumption factor", value: $settings.minimumGasFactor, unit: "×", digits: 1, range: 1...6, step: 0.5)
+ } header: {
+ Text("Minimum gas")
+ }
+ Section("Oxygen limits") {
+ NumberRow(title: "At the bottom", value: $settings.ppO2Bottom, unit: "bar", digits: 1, range: 1...1.6, step: 0.1)
+ NumberRow(title: "Decompression", value: $settings.ppO2Deco, unit: "bar", digits: 1, range: 1...1.6, step: 0.1)
+ }
+ Section("Water") {
+ Picker("Water", selection: Binding(get: { settings.environment.waterDensity < 1.015 },
+ set: { settings.environment.waterDensity = $0 ? 1.0 : 1.03 })) {
+ Text("Sea").tag(false)
+ Text("Fresh").tag(true)
+ }
+ .pickerStyle(.segmented)
+ NumberRow(title: "Pressure at the surface", value: $settings.environment.surfacePressure, unit: "bar", digits: 3, range: 0.5...1.1)
+ }
+ }
+ .navigationTitle("Settings")
+ .navigationBarTitleDisplayMode(.inline)
+ }
+
+ private func fraction(_ path: WritableKeyPath<PlanSettings, Double>) -> Binding<Double> {
+ Binding {
+ (settings[keyPath: path] * 100).rounded()
+ } set: {
+ settings[keyPath: path] = $0 / 100
+ }
+ }
+}
diff --git a/Packages/DiveKit/Sources/DivePlanner/Planner.swift b/Packages/DiveKit/Sources/DivePlanner/Planner.swift
@@ -143,6 +143,8 @@ public struct PlanResult: Sendable, Equatable {
public var surfaceGF = 0.0
public var warnings: [PlanWarning] = []
+ public init() {}
+
/// True when the ascent has mandatory decompression stops.
public var hasDecoStops: Bool { stops.contains { $0.kind == .deco } }
public var decoStops: [PlanStop] { stops.filter { $0.kind != .safety } }
diff --git a/README.md b/README.md
@@ -53,6 +53,11 @@ The app is available in English and French.
- iCloud backup: after each change, the logbook goes to the app's iCloud Drive folder as `Logbook/logbook.zip`
(the files of the Subsurface git format), with `logbook.json` (what it holds), `settings.plist` and one archive
per day for a week in `history`. The sign-in screen offers to restore it. Photos are not copied.
+- Planning (its own tab), on top of the `DivePlanner` library:
+ - no-stop: how long at a depth on a gas with a cylinder (no-stop time, gas time, table of no-stop times);
+ - decompression: levels, cylinders with nitrox, trimix and decompression gases, gradient factors, stops, run
+ time, gas per cylinder, minimum gas, CNS and OTU, warnings, profile;
+ - gas: maximum operating depth, equivalent narcotic and air depths, density, best mix, consumption.
- Creation of a Subsurface cloud account (email, password, code received by email).
- Demo logbook (a button on the sign-in screen, or the `-demo` launch option).
@@ -70,6 +75,10 @@ Not there yet: Subsurface XML import, dive planner.
- Importers for the Shearwater and Open Rémora formats.
- `Merge` holds the rules for dives recorded by several computers and merges them as text, so that the files
of the other computers stay byte-identical.
+- `Packages/DiveKit/Sources/DivePlanner`: gas formulas and a Bühlmann ZHL-16C planner with gradient factors
+ (nitrogen and helium, open circuit, gas switches), with no dependency. The coefficients and the algorithm follow
+ Subsurface's `core/deco.cpp` and `core/planner.cpp`; the tests reproduce its benchmark plan (79 m for 30 minutes
+ on trimix 15/45 with EAN36 and oxygen: 109 minutes of run time).
- `Packages/DiveKit/Sources/CLibDiveComputer`: libdivecomputer, vendored unchanged (see its `README.md` for the
exact revision), built as a package target.
- `Packages/DiveKit/Sources/DiveComputerKit`: Swift on top of it. `Catalog` lists the models and matches one from
@@ -103,7 +112,7 @@ Not there yet: Subsurface XML import, dive planner.
Launch options: `-demo`, `-tab sites|stats|settings`, `-showDive N`, `-scroll notes|bottom`, `-edit`, `-newDive`,
`-demoChanges`, `-importFile path`, `-importAll`, `-createAccount`, `-remoraFolder path`, `-merouFolder path`,
-`-selectDives 12,13` (the selection that precedes a merge; with `-merge`, its confirmation), `-startLocal`, `-restoreBackup`, `-backupFolder path` (a plain folder stands in for iCloud Drive), `-connectCloud`, `-cards`, `-demoCards`, `-showCard`, `-editCard`, `-selectDives 12,13`, `-mergeNow`, `-diveComputer`
+`-selectDives 12,13` (the selection that precedes a merge; with `-merge`, its confirmation), `-tab plan -planner simple|technical|gas`, `-starterPlan`, `-startLocal`, `-restoreBackup`, `-backupFolder path` (a plain folder stands in for iCloud Drive), `-connectCloud`, `-cards`, `-demoCards`, `-showCard`, `-editCard`, `-selectDives 12,13`, `-mergeNow`, `-diveComputer`
(opens the download sheet; with `-fakeComputers` it lists made-up computers, the simulator having no Bluetooth).
### Validating on a real logbook
diff --git a/fastlane/Fastfile b/fastlane/Fastfile
@@ -76,9 +76,9 @@ platform :ios do
end
texts = {
"fr-CA" => ["Votre carnet de plongée sur iPhone : profils, modification hors ligne, ordinateur de plongée en Bluetooth, synchronisation facultative avec le nuage Subsurface, sauvegarde iCloud. Application indépendante de l'équipe de Subsurface.",
- "0.7 : Nouveau : (1) Sauvegarde iCloud complète : le carnet et les réglages sont copiés dans le dossier Sub Rascasse d'iCloud Drive après chaque modification (une archive par jour sur une semaine), en plus des cartes de certification ; les photos ne sont pas copiées. Réglages indique la date de la dernière sauvegarde. (2) Le compte du nuage Subsurface devient facultatif : on peut garder le carnet sur l'iPhone, restaurer la sauvegarde iCloud depuis l'écran d'accueil, connecter un compte plus tard, ou se déconnecter en gardant le carnet."],
+ "0.8 : Nouveau : onglet Planification. (1) Sans palier : pour une profondeur, un gaz et une bouteille, combien de temps on peut rester (temps sans palier, autonomie en gaz) et un tableau des temps sans palier. (2) Décompression : niveaux, bouteilles (nitrox, trimix, gaz de décompression), facteurs de gradient ; paliers, durée totale, gaz par bouteille, gaz minimum, oxygène (CNS, OTU), avertissements, profil. Calcul Bühlmann ZHL-16C comme le planificateur de Subsurface. (3) Gaz : profondeur maximale, profondeur narcotique, densité, meilleur mélange, consommation. Aide à la planification seulement : vérifier un plan avec un autre outil."],
"en-CA" => ["Your dive log on iPhone: profiles, offline editing, dive computer over Bluetooth, optional sync with Subsurface cloud storage, iCloud backup. Independent from the Subsurface team.",
- "0.7: New: (1) Full iCloud backup: the logbook and the settings are copied to the Sub Rascasse folder of iCloud Drive after each change (one archive per day over a week), on top of the certification cards; photos are not copied. Settings shows the date of the last backup. (2) The Subsurface cloud account becomes optional: the logbook can stay on the iPhone, the iCloud backup can be restored from the welcome screen, an account can be connected later, and signing out can keep the logbook."],
+ "0.8: New: Planning tab. (1) No-stop: for a depth, a gas and a cylinder, how long you can stay (no-stop time, gas time) and a table of no-stop times. (2) Decompression: levels, cylinders (nitrox, trimix, decompression gases), gradient factors; stops, run time, gas per cylinder, minimum gas, oxygen (CNS, OTU), warnings, profile. Buhlmann ZHL-16C computed like the Subsurface planner. (3) Gas: maximum depth, narcotic depth, density, best mix, consumption. A planning aid only: check a plan against another tool."],
}
_, locs = asc(:get, "/v1/apps/#{app.id}/betaAppLocalizations")
texts.each do |locale, (description, _)|
diff --git a/project.yml b/project.yml
@@ -13,7 +13,7 @@ settings:
base:
DEVELOPMENT_TEAM: CM5RQKJH56
CODE_SIGN_STYLE: Automatic
- MARKETING_VERSION: "0.7"
+ MARKETING_VERSION: "0.8"
CURRENT_PROJECT_VERSION: "1"
SWIFT_VERSION: "5.0"
targets:
@@ -29,6 +29,8 @@ targets:
product: SubsurfaceLog
- package: DiveKit
product: DiveComputerKit
+ - package: DiveKit
+ product: DivePlanner
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: org.schurger.subrascasse