annotate Discovery/Src/tMenuDeco.c @ 863:0c89c6fa949c Evo_2_23 tip

Bugfix empty line in deco plan (VPM only): Floating numbers were used to calculate the target slot for the time entry of a deco stop. The float rounding caused a time to be written into one line above the intended one. In the next step the misplaced time was overwritten by the next shallower stop. To fix the problem the index calculation has been corrected and in addition digit numbers have generally been added to floating point operations to make the floating operation more visible.
author Ideenmodellierer
date Tue, 02 Jul 2024 20:05:08 +0200
parents e81afd727993
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/tMenuDeco.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief Main Template file for Menu Page Deco
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 31-July-2014
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 "tMenu.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "tMenuDeco.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "unit.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 uint32_t tMDeco_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 uint8_t textPointer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 uint8_t futureTTS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 double ppO2max_deco, ppO2max_std;
707
e81afd727993 Menu cleanup rebreather specific settings:
Ideenmodellierer
parents: 662
diff changeset
41 char divemode;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 textPointer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 *tab = 370;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 *subtext = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 SSettings *data = settingsGetPointer();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 futureTTS = data->future_TTS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 ppO2max_std = data->ppO2_max_std;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 ppO2max_std /= 100.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 ppO2max_deco = data->ppO2_max_deco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 ppO2max_deco /= 100.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 if((line == 0) || (line == 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 switch(data->dive_mode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 case DIVEMODE_OC:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 divemode = TXT_OpenCircuit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 case DIVEMODE_CCR:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 divemode = TXT_ClosedCircuit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 case DIVEMODE_Gauge:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 divemode = TXT_Gauge;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 case DIVEMODE_Apnea:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 divemode = TXT_Apnoe;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 break;
662
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 51
diff changeset
70 case DIVEMODE_PSCR:
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 51
diff changeset
71 divemode = TXT_PSClosedCircuit;
1b995079c045 PSCR Mode
heinrichs weikamp
parents: 51
diff changeset
72 break;
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
73 default :
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
74 divemode = TXT_OpenCircuit;
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
75 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 , TXT_DiveMode, divemode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86
707
e81afd727993 Menu cleanup rebreather specific settings:
Ideenmodellierer
parents: 662
diff changeset
87 if((line == 0) || (line == 2))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 "ppO2"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 "max"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 "%0.2f"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 " bar "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 " deco "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 "%0.2f"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 " bar"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 , ppO2max_std, ppO2max_deco
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109
707
e81afd727993 Menu cleanup rebreather specific settings:
Ideenmodellierer
parents: 662
diff changeset
110 if((line == 0) || (line == 3))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 " %c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 " @ "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 , TXT_SafetyStop
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 , settingsGetPointer()->safetystopDuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 ,TXT_Minutes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 , unit_depth_integer(settingsGetPointer()->safetystopDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
707
e81afd727993 Menu cleanup rebreather specific settings:
Ideenmodellierer
parents: 662
diff changeset
135 if((line == 0) || (line == 4))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 " %c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 ,TXT_FutureTTS
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 ,futureTTS
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 ,TXT_Minutes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151
707
e81afd727993 Menu cleanup rebreather specific settings:
Ideenmodellierer
parents: 662
diff changeset
152 if((line == 0) || (line == 5))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 " %%"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 , TXT_Salinity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 , settingsGetPointer()->salinity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 return StMDECO;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 }