Mercurial > public > ostc4
annotate Discovery/Src/t6_apnea.c @ 237:ec16fd26e280 div-fixes-5
Bugfix: do not show NDL in bigscreen mode when zero
The first minute of the dive, no deco or NDL data is shown in normal mode,
but when starting in bigscreen mode, the first minute, the screen shows
NDL 0', which is obviously wrong. Fix this, and simply show nothing like
in normal mode.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Sat, 06 Apr 2019 20:35:21 +0200 |
parents | 2bb1db22b5f5 |
children | 39c147e47c1c |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/t6_apnea.c | |
5 /// \brief dive screen for Gauge mode | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 1-Feb-2017 | |
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 "t6_apnea.h" | |
31 | |
32 #include "data_exchange_main.h" | |
33 #include "decom.h" | |
34 #include "gfx_fonts.h" | |
35 #include "math.h" | |
36 #include "tHome.h" | |
37 #include "simulation.h" | |
38 #include "timer.h" | |
39 #include "unit.h" | |
40 | |
41 /* Private variables ---------------------------------------------------------*/ | |
42 GFX_DrawCfgScreen t6screen; | |
43 GFX_DrawCfgWindow t6l1; | |
44 GFX_DrawCfgWindow t6r1; | |
45 GFX_DrawCfgWindow t6c1; | |
46 GFX_DrawCfgWindow t6c2; | |
47 GFX_DrawCfgWindow t6c3; // for menu text | |
48 | |
49 uint8_t t6_selection_customview = 0; | |
50 | |
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
189
diff
changeset
|
51 /* Imported function prototypes ---------------------------------------------*/ |
38 | 52 |
53 /* Private types -------------------------------------------------------------*/ | |
54 | |
55 #define CUSTOMBOX_LINE_LEFT (250) | |
56 #define CUSTOMBOX_LINE_RIGHT (549) | |
57 #define CUSTOMBOX_INSIDE_OFFSET (2) | |
58 #define CUSTOMBOX_OUTSIDE_OFFSET (2) | |
59 | |
60 #define TEXTSIZE 16 | |
61 | |
62 const uint8_t t6_customviewsStandard[] = | |
63 { | |
64 CVIEW_noneOrDebug, | |
65 CVIEW_T3_Temperature, | |
66 CVIEW_T3_END | |
67 }; | |
68 | |
69 const uint8_t *t6_customviews = t6_customviewsStandard; | |
70 const uint8_t t6_customviewSurfaceMode = CVIEW_T3_ApnoeSurfaceInfo; | |
71 | |
72 /* Private function prototypes -----------------------------------------------*/ | |
73 void t6_refresh_divemode(void); | |
74 void t6_refresh_customview(float depth); | |
75 | |
76 uint8_t t6_test_customview_warnings(void); | |
77 | |
78 /* Exported functions --------------------------------------------------------*/ | |
79 | |
80 // for tHomeDiveMenuControl() in tHome.c and t6_refresh_customview | |
81 uint8_t t6_getCustomView(void) | |
82 { | |
83 if(stateUsed->lifeData.counterSecondsShallowDepth) | |
84 return t6_customviewSurfaceMode; | |
85 else | |
86 return t6_selection_customview; | |
87 } | |
88 | |
89 void t6_init(void) | |
90 { | |
91 t6_selection_customview = t6_customviewsStandard[0]; | |
92 | |
93 t6screen.FBStartAdress = 0; | |
94 t6screen.ImageHeight = 480; | |
95 t6screen.ImageWidth = 800; | |
96 t6screen.LayerIndex = 1; | |
97 | |
98 t6l1.Image = &t6screen; | |
99 t6l1.WindowNumberOfTextLines = 2; | |
100 t6l1.WindowLineSpacing = 19; // Abstand von Y0 | |
101 t6l1.WindowTab = 100; | |
102 t6l1.WindowX0 = 0; | |
103 t6l1.WindowX1 = BigFontSeperationLeftRight - 5; | |
104 t6l1.WindowY0 = BigFontSeperationTopBottom + 5; | |
105 t6l1.WindowY1 = 479; | |
106 | |
107 t6r1.Image = &t6screen; | |
108 t6r1.WindowNumberOfTextLines = t6l1.WindowNumberOfTextLines; | |
109 t6r1.WindowLineSpacing = t6l1.WindowLineSpacing; | |
110 t6r1.WindowTab = t6l1.WindowTab; | |
111 t6r1.WindowX0 = BigFontSeperationLeftRight + 5; | |
112 t6r1.WindowX1 = 799; | |
113 t6r1.WindowY0 = t6l1.WindowY0; | |
114 t6r1.WindowY1 = t6l1.WindowY1; | |
115 | |
116 t6c1.Image = &t6screen; | |
117 t6c1.WindowNumberOfTextLines = 2; | |
118 t6c1.WindowLineSpacing = t6l1.WindowLineSpacing; | |
119 t6c1.WindowX0 = 0; | |
120 t6c1.WindowX1 = 799; | |
121 t6c1.WindowY0 = 0; | |
122 t6c1.WindowY1 = BigFontSeperationTopBottom - 5; | |
123 | |
124 t6c2.Image = &t6screen; | |
125 t6c2.WindowNumberOfTextLines = 3; | |
126 t6c2.WindowLineSpacing = 58; | |
127 t6c2.WindowX0 = 370; | |
128 t6c2.WindowX1 = 799; | |
129 t6c2.WindowY0 = 0; | |
130 t6c2.WindowY1 = BigFontSeperationTopBottom - 5; | |
131 t6c2.WindowTab = 600; | |
132 | |
133 t6c3.Image = &t6screen; | |
134 t6c3.WindowNumberOfTextLines = 1; | |
135 t6c3.WindowLineSpacing = 0; // Abstand von Y0 | |
136 t6c3.WindowTab = 100; | |
137 t6c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
138 t6c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
139 t6c3.WindowY0 = 0; | |
140 t6c3.WindowY1 = 69; | |
141 } | |
142 | |
143 | |
144 void t6_refresh(void) | |
145 { | |
146 static uint8_t last_mode = MODE_SURFACE; | |
147 | |
148 SStateList status; | |
149 get_globalStateList(&status); | |
150 | |
151 if(stateUsed->mode != MODE_DIVE) | |
152 { | |
153 last_mode = MODE_SURFACE; | |
154 settingsGetPointer()->design = 7; | |
155 if(t6screen.FBStartAdress) | |
156 { | |
157 releaseFrame(24,t6screen.FBStartAdress); | |
158 t6screen.FBStartAdress = 0; | |
159 } | |
160 return; | |
161 } | |
162 | |
163 if(status.base != BaseHome) | |
164 return; | |
165 | |
166 t6screen.FBStartAdress = getFrame(24); | |
167 | |
168 if(last_mode != MODE_DIVE) | |
169 { | |
170 last_mode = MODE_DIVE; | |
171 t6_selection_customview = *t6_customviews; | |
172 } | |
173 | |
174 if(status.page == PageSurface) | |
175 set_globalState(StD); | |
176 | |
177 t6_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
178 GFX_SetFramesTopBottom(t6screen.FBStartAdress, 0,480); |
38 | 179 releaseAllFramesExcept(24,t6screen.FBStartAdress); |
180 } | |
181 | |
182 /* Private functions ---------------------------------------------------------*/ | |
183 | |
184 void t6_refresh_divemode(void) | |
185 { | |
186 char text[512]; | |
187 uint8_t customview_warnings = 0; | |
188 float depth_meter = 0.0; | |
189 | |
190 // everything like lines, depth, ascent graph and divetime or counterSecondsShallowDepth | |
191 depth_meter = t3_basics_lines_depth_and_divetime(&t6screen, &t6l1, &t6r1, DIVEMODE_Apnea); | |
192 | |
193 | |
194 // customview | |
195 if(stateUsed->warnings.numWarnings) | |
196 customview_warnings = t6_test_customview_warnings(); | |
197 | |
198 if(customview_warnings && warning_count_high_time) | |
199 t3_basics_show_customview_warnings(&t6c1); | |
200 else | |
201 t6_refresh_customview(depth_meter); | |
202 | |
203 if(stateUsed->warnings.lowBattery) | |
204 t3_basics_battery_low_customview_extra(&t6c1); | |
205 | |
206 | |
207 /* Menu Selection (and gas mix) */ | |
208 if(get_globalState() == StDBEAR) | |
209 { | |
210 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ); | |
211 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
212 } | |
213 else if(get_globalState() == StDRAVG) | |
214 { | |
215 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ); | |
216 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
217 } | |
218 else if(get_globalState() == StDQUIT) | |
219 { | |
220 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
221 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
222 } | |
223 else if(get_globalState() == StDSIM1) | |
224 { | |
225 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
226 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
227 } | |
228 else if(get_globalState() == StDSIM2) | |
229 { | |
230 if(settingsGetPointer()->nonMetricalSystem) | |
231 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft "); | |
232 else | |
233 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m "); | |
234 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
235 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
236 , unit_depth_integer(simulation_get_aim_depth()) | |
237 , unit_depth_char1() | |
238 , unit_depth_char2() | |
239 ); | |
240 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
241 | |
242 } | |
243 else if(get_globalState() == StDSIM3) | |
244 { | |
245 if(settingsGetPointer()->nonMetricalSystem) | |
246 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft "); | |
247 else | |
248 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m "); | |
249 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
250 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
251 , unit_depth_integer(simulation_get_aim_depth()) | |
252 , unit_depth_char1() | |
253 , unit_depth_char2() | |
254 ); | |
255 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
256 } | |
257 else if(get_globalState() == StDSIM4) | |
258 { | |
259 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' "); | |
260 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
261 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
262 , unit_depth_integer(simulation_get_aim_depth()) | |
263 , unit_depth_char1() | |
264 , unit_depth_char2() | |
265 ); | |
266 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
267 } | |
268 else | |
269 { | |
270 // keep empty | |
271 } | |
272 } | |
273 | |
274 | |
275 void t6_battery_low_customview_extra(void) | |
276 { | |
277 char TextC1[256]; | |
278 | |
279 TextC1[0] = '\002'; | |
280 TextC1[1] = '\f'; | |
281 TextC1[2] = '\025'; | |
282 TextC1[3] = '3'; | |
283 TextC1[4] = '1'; | |
284 TextC1[5] = '1'; | |
285 TextC1[6] = '1'; | |
286 TextC1[7] = '1'; | |
287 TextC1[8] = '1'; | |
288 TextC1[9] = '1'; | |
289 TextC1[10] = '1'; | |
290 TextC1[11] = '1'; | |
291 TextC1[12] = '1'; | |
292 TextC1[13] = '1'; | |
293 TextC1[14] = '0'; | |
294 TextC1[15] = 0; | |
295 | |
296 if(!warning_count_high_time) | |
297 TextC1[4] = '2'; | |
298 | |
299 GFX_write_string(&Batt24,&t6c1,TextC1,0); | |
300 } | |
301 | |
302 | |
303 | |
304 void t6_change_customview(void) | |
305 { | |
306 t3_basics_change_customview(&t6_selection_customview, t6_customviews); | |
307 } | |
308 | |
309 | |
310 void t6_refresh_customview(float depth) | |
311 { | |
312 uint8_t customViewLeftSide = CVIEW_T3_MaxDepth; | |
313 | |
314 if((t6_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) | |
315 t6_change_customview(); | |
316 | |
317 if(t6_getCustomView() == CVIEW_T3_ApnoeSurfaceInfo) | |
318 customViewLeftSide = CVIEW_T3_ApnoeSurfaceInfo; | |
319 | |
320 t3_basics_refresh_customview(depth, customViewLeftSide, &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea); | |
321 t3_basics_refresh_apnoeRight(depth, t6_getCustomView(), &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea); | |
322 } | |
323 | |
324 | |
325 uint8_t t6_test_customview_warnings(void) | |
326 { | |
327 uint8_t count = 0; | |
328 | |
329 count = 0; | |
330 return count; | |
331 } |