annotate Discovery/Src/unit.c @ 862:974648b5ccfe Evo_2_23

Only use deco gas for calculation if option is enabled: The gas menu meanwhile provides the possibility to select a gas for deco (having the gas switching reminder visible) without the need to visualize the reduced deco time. If the visualization of the deco considering all gas changes is wanted then this may be enabled by selecting the gas additionaly for deco calculation.
author Ideenmodellierer
date Tue, 02 Jul 2024 19:24:03 +0200
parents 269e57ac4e56
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/unit.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief input to meter/celsius or feet/farenheit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 24-Feb-2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "unit.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "settings.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 /* Exported variables --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 uint8_t test;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 /* Private variables with external access via get_xxx() function -------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 /* Announced function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 char unit_depth_char1_T105(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 if(settingsGetPointer()->nonMetricalSystem)
567
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
51 return 'f';
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 return 'm';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 char unit_depth_char2_T105(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 if(settingsGetPointer()->nonMetricalSystem)
567
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
59 return 't';
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 return '\004'; // 004 is nop
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 char unit_depth_char1(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 return 'f';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 return 'm';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 char unit_depth_char2(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 return 't';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 return '\004'; // 004 is nop
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 float unit_depth_float(float input_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 if(settingsGetPointer()->nonMetricalSystem == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 return input_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 return 3.2808f * input_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 uint16_t unit_depth_integer(uint16_t input_meter)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 if(settingsGetPointer()->nonMetricalSystem == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 return input_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 return (input_meter * 10) / 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 float unit_temperature_float(float input_celsius)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 if(settingsGetPointer()->nonMetricalSystem == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 return input_celsius;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 return input_celsius * (9.0f/5.0f) + 32;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109
653
269e57ac4e56 Bugfix temperature display Logpage2:
Ideenmodellierer
parents: 567
diff changeset
110 int16_t unit_temperature_integer(int16_t input_celsius)
567
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
111 {
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
112 if(settingsGetPointer()->nonMetricalSystem == 0)
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
113 return input_celsius;
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
114 else
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
115 {
653
269e57ac4e56 Bugfix temperature display Logpage2:
Ideenmodellierer
parents: 567
diff changeset
116 return ((input_celsius * 9 / 5) + 32);
567
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
117 }
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
118 }
1c95f811967c -Add 12HR Time Support
izzni
parents: 38
diff changeset
119
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 uint16_t unit_speed_integer(uint16_t input_meterPerMinute)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 if(settingsGetPointer()->nonMetricalSystem == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 return input_meterPerMinute;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 return (input_meterPerMinute * 10) / 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 /* Quelle: https://de.wikipedia.org/wiki/Luftdruck */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 const float luftdruckStartMinus300[15] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 1.0530f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 1.0396f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 1.0263f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 1.01325f, // 0 m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 1.0003f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 0.9876f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 0.9750f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 0.9625f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 0.9503f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 0.9381f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 0.9262f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 0.9144f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 0.9027f,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 0.8912f, // 1000 m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 0.8358f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 const int luftdruckStartMinus300[15] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 1053,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 1040,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 1026,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 1013, // 0 m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 1000,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 988,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 975,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 962,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 950,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 938,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 926,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 914,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 903,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 891, // 1000 m
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 836
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 int unit_SeaLevelRelation_integer(int input_atmospheric_mbar)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 int i = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 int distance1, distance2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 for(i=0;i<15;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 if(input_atmospheric_mbar >= luftdruckStartMinus300[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 if(i >= 14)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 return 1500;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 else if(i == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 return -300;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 distance1 = input_atmospheric_mbar - luftdruckStartMinus300[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 distance2 = luftdruckStartMinus300[i-1] - input_atmospheric_mbar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 if(distance2 < distance1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 i -= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 return (i*100) - 300;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 }