annotate Discovery/Src/tMenuDeco.c @ 304:43b44f8d4fb0 cleanup-4

bugfix, simulator: fix the 1 sec difference between stopwatch and divetime This is a rather subtle bugfix. counterSecondsShallowDepth is used to decide to increase dive_time_seconds_without_surface_time. But just after using it, logic is present to reset counterSecondsShallowDepth. So, basically, we are looking to an old state. Simply increase dive_time_seconds_without_surface_time *after* we have reset counterSecondsShallowDepth, so that we are looking to a current state instead of an old one. Notice that this is simulator only. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 20 May 2019 13:06:02 +0200
parents 8f8ea3a32e82
children 1b995079c045
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;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 char divemode, CcrModusTxtId;
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;
51
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
70 default :
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
71 divemode = TXT_OpenCircuit;
8f8ea3a32e82 Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents: 38
diff changeset
72 break;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 , TXT_DiveMode, divemode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 if(data->dive_mode == DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 if((line == 0) || (line == 2))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 if(data->CCR_Mode == CCRMODE_Sensors)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 CcrModusTxtId = TXT_Sensor;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 CcrModusTxtId = TXT_FixedSP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 , TXT_CCRmode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 , CcrModusTxtId
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 if(line != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 line++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 if((line == 0) || (line == 3))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 "ppO2"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 "max"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 "%0.2f"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 " bar "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 " deco "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 "%0.2f"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 " bar"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 , ppO2max_std, ppO2max_deco
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 if((line == 0) || (line == 4))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 " %c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 " @ "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 , TXT_SafetyStop
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 , settingsGetPointer()->safetystopDuration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 ,TXT_Minutes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 , unit_depth_integer(settingsGetPointer()->safetystopDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 if((line == 0) || (line == 5))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 " %c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 ,TXT_FutureTTS
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 ,futureTTS
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 ,TXT_Minutes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 if((line == 0) || (line == 6))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 "%u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 " %%"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 , TXT_Salinity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 , settingsGetPointer()->salinity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 return StMDECO;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 }