Mercurial > public > ostc4
annotate Discovery/Src/tMenuDeco.c @ 169:842f57bbaaad cleanup-1
Bugfix: highlight the menu underline correctly on selected state
This fixes an optical bug. In dive and simulation mode, the
underline in the top menu was not highlighted correctly for the
DECO ans SYS submenu's. The check when to highlight simply was not
correct. And, yes, this part of the code is rather obfuscated, and
deserves some attention later on.
Reported-by: Matthias Heinrichs <matthias.heinrichs@heinrichsweikamp.com>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Sun, 10 Mar 2019 10:09:58 +0100 |
parents | 8f8ea3a32e82 |
children | 1b995079c045 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuDeco.c | |
5 /// \brief Main Template file for Menu Page Deco | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 31-July-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 #include "tMenu.h" | |
31 #include "tMenuDeco.h" | |
32 #include "unit.h" | |
33 | |
34 /* Exported functions --------------------------------------------------------*/ | |
35 | |
36 uint32_t tMDeco_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext) | |
37 { | |
38 uint8_t textPointer; | |
39 uint8_t futureTTS; | |
40 double ppO2max_deco, ppO2max_std; | |
41 char divemode, CcrModusTxtId; | |
42 textPointer = 0; | |
43 *tab = 370; | |
44 *subtext = 0; | |
45 | |
46 SSettings *data = settingsGetPointer(); | |
47 | |
48 futureTTS = data->future_TTS; | |
49 ppO2max_std = data->ppO2_max_std; | |
50 ppO2max_std /= 100.0; | |
51 ppO2max_deco = data->ppO2_max_deco; | |
52 ppO2max_deco /= 100.0; | |
53 | |
54 if((line == 0) || (line == 1)) | |
55 { | |
56 switch(data->dive_mode) | |
57 { | |
58 case DIVEMODE_OC: | |
59 divemode = TXT_OpenCircuit; | |
60 break; | |
61 case DIVEMODE_CCR: | |
62 divemode = TXT_ClosedCircuit; | |
63 break; | |
64 case DIVEMODE_Gauge: | |
65 divemode = TXT_Gauge; | |
66 break; | |
67 case DIVEMODE_Apnea: | |
68 divemode = TXT_Apnoe; | |
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 | 73 } |
74 textPointer += snprintf(&text[textPointer], 60,\ | |
75 "%c" | |
76 "\t" | |
77 "%c" | |
78 , TXT_DiveMode, divemode | |
79 ); | |
80 } | |
81 strcpy(&text[textPointer],"\n\r"); | |
82 textPointer += 2; | |
83 | |
84 if(data->dive_mode == DIVEMODE_CCR) | |
85 { | |
86 if((line == 0) || (line == 2)) | |
87 { | |
88 if(data->CCR_Mode == CCRMODE_Sensors) | |
89 CcrModusTxtId = TXT_Sensor; | |
90 else | |
91 CcrModusTxtId = TXT_FixedSP; | |
92 | |
93 textPointer += snprintf(&text[textPointer], 60,\ | |
94 "%c" | |
95 "\t" | |
96 "%c" | |
97 , TXT_CCRmode | |
98 , CcrModusTxtId | |
99 ); | |
100 } | |
101 strcpy(&text[textPointer],"\n\r"); | |
102 textPointer += 2; | |
103 } | |
104 else | |
105 if(line != 0) | |
106 line++; | |
107 | |
108 if((line == 0) || (line == 3)) | |
109 { | |
110 textPointer += snprintf(&text[textPointer], 60,\ | |
111 "ppO2" | |
112 "\016\016" | |
113 "max" | |
114 "\017" | |
115 "\t" | |
116 "%0.2f" | |
117 "\016\016" | |
118 " bar " | |
119 " deco " | |
120 "\017" | |
121 "%0.2f" | |
122 "\016\016" | |
123 " bar" | |
124 "\017" | |
125 , ppO2max_std, ppO2max_deco | |
126 ); | |
127 } | |
128 strcpy(&text[textPointer],"\n\r"); | |
129 textPointer += 2; | |
130 | |
131 if((line == 0) || (line == 4)) | |
132 { | |
133 textPointer += snprintf(&text[textPointer], 60,\ | |
134 "%c" | |
135 "\t" | |
136 "%u" | |
137 "\016\016" | |
138 " %c" | |
139 "\017" | |
140 " @ " | |
141 "%u" | |
142 "\016\016" | |
143 " %c%c" | |
144 "\017" | |
145 , TXT_SafetyStop | |
146 , settingsGetPointer()->safetystopDuration | |
147 ,TXT_Minutes | |
148 , unit_depth_integer(settingsGetPointer()->safetystopDepth) | |
149 , unit_depth_char1() | |
150 , unit_depth_char2() | |
151 ); | |
152 } | |
153 strcpy(&text[textPointer],"\n\r"); | |
154 textPointer += 2; | |
155 | |
156 if((line == 0) || (line == 5)) | |
157 { | |
158 textPointer += snprintf(&text[textPointer], 60,\ | |
159 "%c" | |
160 "\t" | |
161 "%u" | |
162 "\016\016" | |
163 " %c" | |
164 "\017" | |
165 ,TXT_FutureTTS | |
166 ,futureTTS | |
167 ,TXT_Minutes | |
168 ); | |
169 } | |
170 strcpy(&text[textPointer],"\n\r"); | |
171 textPointer += 2; | |
172 | |
173 if((line == 0) || (line == 6)) | |
174 { | |
175 textPointer += snprintf(&text[textPointer], 60,\ | |
176 "%c" | |
177 "\t" | |
178 "%u" | |
179 "\016\016" | |
180 " %%" | |
181 "\017" | |
182 , TXT_Salinity | |
183 , settingsGetPointer()->salinity | |
184 ); | |
185 } | |
186 strcpy(&text[textPointer],"\n\r"); | |
187 textPointer += 2; | |
188 | |
189 | |
190 return StMDECO; | |
191 } |