Mercurial > public > ostc4
annotate Discovery/Src/t6_apnea.c @ 776:45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
This allows the displayed compass reading to be configured to take into account the compass declination (difference between the measured magnetic North direction and the actual geographical North direction) that has different values for different locations around the globe. See https://magnetic-declination.com/ for more information. (mikeller)
author | heinrichsweikamp |
---|---|
date | Thu, 18 May 2023 09:49:17 +0200 |
parents | 65c7b009136f |
children | 18946846b95b |
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 { | |
413 | 91 SSettings* pSettings; |
92 pSettings = settingsGetPointer(); | |
38 | 93 t6_selection_customview = t6_customviewsStandard[0]; |
94 | |
95 t6screen.FBStartAdress = 0; | |
96 t6screen.ImageHeight = 480; | |
97 t6screen.ImageWidth = 800; | |
98 t6screen.LayerIndex = 1; | |
99 | |
100 t6l1.Image = &t6screen; | |
101 t6l1.WindowNumberOfTextLines = 2; | |
102 t6l1.WindowLineSpacing = 19; // Abstand von Y0 | |
103 t6l1.WindowTab = 100; | |
413 | 104 if(!pSettings->FlipDisplay) |
105 { | |
106 t6l1.WindowX0 = 0; | |
107 t6l1.WindowX1 = BigFontSeperationLeftRight - 5; | |
108 t6l1.WindowY0 = BigFontSeperationTopBottom + 5; | |
109 t6l1.WindowY1 = 479; | |
110 } | |
111 else | |
112 { | |
113 t6l1.WindowX0 = 800 - BigFontSeperationLeftRight + 5; | |
114 t6l1.WindowX1 = 799; | |
115 t6l1.WindowY0 = 0; | |
116 t6l1.WindowY1 = 479 - BigFontSeperationTopBottom + 5 ; | |
117 } | |
38 | 118 |
119 t6r1.Image = &t6screen; | |
120 t6r1.WindowNumberOfTextLines = t6l1.WindowNumberOfTextLines; | |
121 t6r1.WindowLineSpacing = t6l1.WindowLineSpacing; | |
122 t6r1.WindowTab = t6l1.WindowTab; | |
413 | 123 if(!pSettings->FlipDisplay) |
124 { | |
125 t6r1.WindowX0 = BigFontSeperationLeftRight + 5; | |
126 t6r1.WindowX1 = 799; | |
127 } | |
128 else | |
129 { | |
130 t6r1.WindowX0 = 0; | |
131 t6r1.WindowX1 = BigFontSeperationLeftRight - 5; | |
132 } | |
38 | 133 t6r1.WindowY0 = t6l1.WindowY0; |
134 t6r1.WindowY1 = t6l1.WindowY1; | |
135 | |
136 t6c1.Image = &t6screen; | |
137 t6c1.WindowNumberOfTextLines = 2; | |
138 t6c1.WindowLineSpacing = t6l1.WindowLineSpacing; | |
139 t6c1.WindowX0 = 0; | |
140 t6c1.WindowX1 = 799; | |
413 | 141 if(!pSettings->FlipDisplay) |
142 { | |
143 t6c1.WindowY0 = 0; | |
144 t6c1.WindowY1 = BigFontSeperationTopBottom - 5; | |
145 } | |
146 else | |
147 { | |
148 t6c1.WindowY0 = 480 - BigFontSeperationTopBottom + 5; | |
149 t6c1.WindowY1 = 479; | |
150 t6c1.WindowX0 = 0; | |
151 t6c1.WindowX1 = BigFontSeperationLeftRight - 5; | |
152 } | |
38 | 153 |
154 t6c2.Image = &t6screen; | |
155 t6c2.WindowNumberOfTextLines = 3; | |
156 t6c2.WindowLineSpacing = 58; | |
157 t6c2.WindowX0 = 370; | |
158 t6c2.WindowX1 = 799; | |
413 | 159 |
160 if(!pSettings->FlipDisplay) | |
161 { | |
162 t6c2.WindowY0 = 0; | |
163 t6c2.WindowY1 = BigFontSeperationTopBottom - 5; | |
164 } | |
165 else | |
166 { | |
167 t6c2.WindowY0 = 480 - BigFontSeperationTopBottom + 5; | |
168 t6c2.WindowY1 = 479; | |
169 } | |
170 | |
38 | 171 t6c2.WindowTab = 600; |
172 | |
173 t6c3.Image = &t6screen; | |
174 t6c3.WindowNumberOfTextLines = 1; | |
175 t6c3.WindowLineSpacing = 0; // Abstand von Y0 | |
176 t6c3.WindowTab = 100; | |
177 t6c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
178 t6c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
413 | 179 if(!pSettings->FlipDisplay) |
180 { | |
181 t6c3.WindowY0 = 0; | |
182 t6c3.WindowY1 = 69; | |
183 } | |
184 else | |
185 { | |
186 t6c3.WindowY0 = 480 - 69; | |
187 t6c3.WindowY1 = 479; | |
188 } | |
38 | 189 } |
190 | |
191 | |
192 void t6_refresh(void) | |
193 { | |
194 static uint8_t last_mode = MODE_SURFACE; | |
195 | |
196 SStateList status; | |
197 get_globalStateList(&status); | |
198 | |
199 if(stateUsed->mode != MODE_DIVE) | |
200 { | |
201 last_mode = MODE_SURFACE; | |
202 settingsGetPointer()->design = 7; | |
203 if(t6screen.FBStartAdress) | |
204 { | |
205 releaseFrame(24,t6screen.FBStartAdress); | |
206 t6screen.FBStartAdress = 0; | |
207 } | |
208 return; | |
209 } | |
210 | |
211 if(status.base != BaseHome) | |
212 return; | |
213 | |
214 t6screen.FBStartAdress = getFrame(24); | |
215 | |
216 if(last_mode != MODE_DIVE) | |
217 { | |
218 last_mode = MODE_DIVE; | |
219 t6_selection_customview = *t6_customviews; | |
220 } | |
221 | |
222 if(status.page == PageSurface) | |
223 set_globalState(StD); | |
224 | |
225 t6_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
226 GFX_SetFramesTopBottom(t6screen.FBStartAdress, 0,480); |
38 | 227 releaseAllFramesExcept(24,t6screen.FBStartAdress); |
228 } | |
229 | |
230 /* Private functions ---------------------------------------------------------*/ | |
231 | |
232 void t6_refresh_divemode(void) | |
233 { | |
234 char text[512]; | |
235 uint8_t customview_warnings = 0; | |
236 float depth_meter = 0.0; | |
237 | |
238 // everything like lines, depth, ascent graph and divetime or counterSecondsShallowDepth | |
239 depth_meter = t3_basics_lines_depth_and_divetime(&t6screen, &t6l1, &t6r1, DIVEMODE_Apnea); | |
240 | |
241 | |
242 // customview | |
243 if(stateUsed->warnings.numWarnings) | |
244 customview_warnings = t6_test_customview_warnings(); | |
245 | |
246 if(customview_warnings && warning_count_high_time) | |
247 t3_basics_show_customview_warnings(&t6c1); | |
248 else | |
249 t6_refresh_customview(depth_meter); | |
250 | |
251 if(stateUsed->warnings.lowBattery) | |
252 t3_basics_battery_low_customview_extra(&t6c1); | |
253 | |
254 | |
255 /* Menu Selection (and gas mix) */ | |
256 if(get_globalState() == StDBEAR) | |
257 { | |
258 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ); | |
259 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
260 } | |
261 else if(get_globalState() == StDRAVG) | |
262 { | |
263 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ); | |
264 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
265 } | |
266 else if(get_globalState() == StDQUIT) | |
267 { | |
268 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
269 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
270 } | |
271 else if(get_globalState() == StDSIM1) | |
272 { | |
273 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
274 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
275 } | |
276 else if(get_globalState() == StDSIM2) | |
277 { | |
278 if(settingsGetPointer()->nonMetricalSystem) | |
279 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft "); | |
280 else | |
281 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m "); | |
282 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
283 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
284 , unit_depth_integer(simulation_get_aim_depth()) | |
285 , unit_depth_char1() | |
286 , unit_depth_char2() | |
287 ); | |
288 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
289 | |
290 } | |
291 else if(get_globalState() == StDSIM3) | |
292 { | |
293 if(settingsGetPointer()->nonMetricalSystem) | |
294 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft "); | |
295 else | |
296 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m "); | |
297 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
298 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
299 , unit_depth_integer(simulation_get_aim_depth()) | |
300 , unit_depth_char1() | |
301 , unit_depth_char2() | |
302 ); | |
303 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
304 } | |
305 else if(get_globalState() == StDSIM4) | |
306 { | |
307 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' "); | |
308 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
309 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
310 , unit_depth_integer(simulation_get_aim_depth()) | |
311 , unit_depth_char1() | |
312 , unit_depth_char2() | |
313 ); | |
314 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
315 } | |
316 else | |
317 { | |
318 // keep empty | |
319 } | |
320 } | |
321 | |
322 | |
323 void t6_battery_low_customview_extra(void) | |
324 { | |
325 char TextC1[256]; | |
326 | |
327 TextC1[0] = '\002'; | |
328 TextC1[1] = '\f'; | |
329 TextC1[2] = '\025'; | |
330 TextC1[3] = '3'; | |
331 TextC1[4] = '1'; | |
332 TextC1[5] = '1'; | |
333 TextC1[6] = '1'; | |
334 TextC1[7] = '1'; | |
335 TextC1[8] = '1'; | |
336 TextC1[9] = '1'; | |
337 TextC1[10] = '1'; | |
338 TextC1[11] = '1'; | |
339 TextC1[12] = '1'; | |
340 TextC1[13] = '1'; | |
341 TextC1[14] = '0'; | |
342 TextC1[15] = 0; | |
343 | |
344 if(!warning_count_high_time) | |
345 TextC1[4] = '2'; | |
346 | |
347 GFX_write_string(&Batt24,&t6c1,TextC1,0); | |
348 } | |
349 | |
350 | |
351 | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
225
diff
changeset
|
352 void t6_change_customview(uint8_t action) |
38 | 353 { |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
225
diff
changeset
|
354 t3_basics_change_customview(&t6_selection_customview, t6_customviews, action); |
38 | 355 } |
356 | |
357 | |
358 void t6_refresh_customview(float depth) | |
359 { | |
360 uint8_t customViewLeftSide = CVIEW_T3_MaxDepth; | |
361 | |
362 if(t6_getCustomView() == CVIEW_T3_ApnoeSurfaceInfo) | |
363 customViewLeftSide = CVIEW_T3_ApnoeSurfaceInfo; | |
364 | |
365 t3_basics_refresh_customview(depth, customViewLeftSide, &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea); | |
366 t3_basics_refresh_apnoeRight(depth, t6_getCustomView(), &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea); | |
367 } | |
368 | |
369 | |
370 uint8_t t6_test_customview_warnings(void) | |
371 { | |
372 uint8_t count = 0; | |
373 | |
374 count = 0; | |
375 return count; | |
376 } |