Mercurial > public > ostc4
annotate Discovery/Src/t6_apnea.c @ 170:5ca88855da87 cleanup-1
Fix accidentally pushed local code
Did I say that Mercurial is a pain for long time git users :-)
For the record: created a commit with 1 file, saw a spelling error
so, did a hg commit --amend ... which sneaked in a 2nd file. I did not
notice, created a pull request, and now this stupid commit undoing things
is the only way as all is in public phase now.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Sun, 10 Mar 2019 10:46:48 +0100 |
parents | 255eedad4155 |
children | 9da7dd50e2ec |
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 extern float depthLastCall[9]; | |
50 extern uint8_t idDepthLastCall; | |
51 extern float temperatureLastCall[3]; | |
52 extern uint8_t idTemperatureLastCall; | |
53 | |
54 uint8_t t6_selection_customview = 0; | |
55 | |
56 /* Importend function prototypes ---------------------------------------------*/ | |
57 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); | |
58 | |
59 /* Private types -------------------------------------------------------------*/ | |
60 | |
61 #define CUSTOMBOX_LINE_LEFT (250) | |
62 #define CUSTOMBOX_LINE_RIGHT (549) | |
63 #define CUSTOMBOX_INSIDE_OFFSET (2) | |
64 #define CUSTOMBOX_OUTSIDE_OFFSET (2) | |
65 | |
66 #define TEXTSIZE 16 | |
67 | |
68 const uint8_t t6_customviewsStandard[] = | |
69 { | |
70 CVIEW_noneOrDebug, | |
71 CVIEW_T3_Temperature, | |
72 CVIEW_T3_END | |
73 }; | |
74 | |
75 const uint8_t *t6_customviews = t6_customviewsStandard; | |
76 const uint8_t t6_customviewSurfaceMode = CVIEW_T3_ApnoeSurfaceInfo; | |
77 | |
78 /* Private function prototypes -----------------------------------------------*/ | |
79 void t6_refresh_divemode(void); | |
80 void t6_refresh_customview(float depth); | |
81 | |
82 uint8_t t6_test_customview_warnings(void); | |
83 void t6_show_customview_warnings(void); | |
84 void t6_compass(uint16_t ActualHeading, uint16_t UserSetHeading); | |
85 | |
86 /* Exported functions --------------------------------------------------------*/ | |
87 | |
88 // for tHomeDiveMenuControl() in tHome.c and t6_refresh_customview | |
89 uint8_t t6_getCustomView(void) | |
90 { | |
91 if(stateUsed->lifeData.counterSecondsShallowDepth) | |
92 return t6_customviewSurfaceMode; | |
93 else | |
94 return t6_selection_customview; | |
95 } | |
96 | |
97 void t6_init(void) | |
98 { | |
99 t6_selection_customview = t6_customviewsStandard[0]; | |
100 | |
101 t6screen.FBStartAdress = 0; | |
102 t6screen.ImageHeight = 480; | |
103 t6screen.ImageWidth = 800; | |
104 t6screen.LayerIndex = 1; | |
105 | |
106 t6l1.Image = &t6screen; | |
107 t6l1.WindowNumberOfTextLines = 2; | |
108 t6l1.WindowLineSpacing = 19; // Abstand von Y0 | |
109 t6l1.WindowTab = 100; | |
110 t6l1.WindowX0 = 0; | |
111 t6l1.WindowX1 = BigFontSeperationLeftRight - 5; | |
112 t6l1.WindowY0 = BigFontSeperationTopBottom + 5; | |
113 t6l1.WindowY1 = 479; | |
114 | |
115 t6r1.Image = &t6screen; | |
116 t6r1.WindowNumberOfTextLines = t6l1.WindowNumberOfTextLines; | |
117 t6r1.WindowLineSpacing = t6l1.WindowLineSpacing; | |
118 t6r1.WindowTab = t6l1.WindowTab; | |
119 t6r1.WindowX0 = BigFontSeperationLeftRight + 5; | |
120 t6r1.WindowX1 = 799; | |
121 t6r1.WindowY0 = t6l1.WindowY0; | |
122 t6r1.WindowY1 = t6l1.WindowY1; | |
123 | |
124 t6c1.Image = &t6screen; | |
125 t6c1.WindowNumberOfTextLines = 2; | |
126 t6c1.WindowLineSpacing = t6l1.WindowLineSpacing; | |
127 t6c1.WindowX0 = 0; | |
128 t6c1.WindowX1 = 799; | |
129 t6c1.WindowY0 = 0; | |
130 t6c1.WindowY1 = BigFontSeperationTopBottom - 5; | |
131 | |
132 t6c2.Image = &t6screen; | |
133 t6c2.WindowNumberOfTextLines = 3; | |
134 t6c2.WindowLineSpacing = 58; | |
135 t6c2.WindowX0 = 370; | |
136 t6c2.WindowX1 = 799; | |
137 t6c2.WindowY0 = 0; | |
138 t6c2.WindowY1 = BigFontSeperationTopBottom - 5; | |
139 t6c2.WindowTab = 600; | |
140 | |
141 t6c3.Image = &t6screen; | |
142 t6c3.WindowNumberOfTextLines = 1; | |
143 t6c3.WindowLineSpacing = 0; // Abstand von Y0 | |
144 t6c3.WindowTab = 100; | |
145 t6c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
146 t6c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
147 t6c3.WindowY0 = 0; | |
148 t6c3.WindowY1 = 69; | |
149 } | |
150 | |
151 | |
152 void t6_refresh(void) | |
153 { | |
154 static uint8_t last_mode = MODE_SURFACE; | |
155 | |
156 SStateList status; | |
157 get_globalStateList(&status); | |
158 | |
159 if(stateUsed->mode != MODE_DIVE) | |
160 { | |
161 last_mode = MODE_SURFACE; | |
162 settingsGetPointer()->design = 7; | |
163 if(t6screen.FBStartAdress) | |
164 { | |
165 releaseFrame(24,t6screen.FBStartAdress); | |
166 t6screen.FBStartAdress = 0; | |
167 } | |
168 return; | |
169 } | |
170 | |
171 if(status.base != BaseHome) | |
172 return; | |
173 | |
174 t6screen.FBStartAdress = getFrame(24); | |
175 | |
176 if(last_mode != MODE_DIVE) | |
177 { | |
178 last_mode = MODE_DIVE; | |
179 t6_selection_customview = *t6_customviews; | |
180 } | |
181 | |
182 if(status.page == PageSurface) | |
183 set_globalState(StD); | |
184 | |
185 t6_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
186 GFX_SetFramesTopBottom(t6screen.FBStartAdress, 0,480); |
38 | 187 releaseAllFramesExcept(24,t6screen.FBStartAdress); |
188 } | |
189 | |
190 /* Private functions ---------------------------------------------------------*/ | |
191 | |
192 void t6_refresh_divemode(void) | |
193 { | |
194 char text[512]; | |
195 uint8_t customview_warnings = 0; | |
196 float depth_meter = 0.0; | |
197 | |
198 // everything like lines, depth, ascent graph and divetime or counterSecondsShallowDepth | |
199 depth_meter = t3_basics_lines_depth_and_divetime(&t6screen, &t6l1, &t6r1, DIVEMODE_Apnea); | |
200 | |
201 | |
202 // customview | |
203 if(stateUsed->warnings.numWarnings) | |
204 customview_warnings = t6_test_customview_warnings(); | |
205 | |
206 if(customview_warnings && warning_count_high_time) | |
207 t3_basics_show_customview_warnings(&t6c1); | |
208 else | |
209 t6_refresh_customview(depth_meter); | |
210 | |
211 if(stateUsed->warnings.lowBattery) | |
212 t3_basics_battery_low_customview_extra(&t6c1); | |
213 | |
214 | |
215 /* Menu Selection (and gas mix) */ | |
216 if(get_globalState() == StDBEAR) | |
217 { | |
218 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ); | |
219 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
220 } | |
221 else if(get_globalState() == StDRAVG) | |
222 { | |
223 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ); | |
224 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
225 } | |
226 else if(get_globalState() == StDQUIT) | |
227 { | |
228 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
229 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
230 } | |
231 else if(get_globalState() == StDSIM1) | |
232 { | |
233 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
234 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
235 } | |
236 else if(get_globalState() == StDSIM2) | |
237 { | |
238 if(settingsGetPointer()->nonMetricalSystem) | |
239 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft "); | |
240 else | |
241 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m "); | |
242 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
243 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
244 , unit_depth_integer(simulation_get_aim_depth()) | |
245 , unit_depth_char1() | |
246 , unit_depth_char2() | |
247 ); | |
248 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
249 | |
250 } | |
251 else if(get_globalState() == StDSIM3) | |
252 { | |
253 if(settingsGetPointer()->nonMetricalSystem) | |
254 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft "); | |
255 else | |
256 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m "); | |
257 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
258 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
259 , unit_depth_integer(simulation_get_aim_depth()) | |
260 , unit_depth_char1() | |
261 , unit_depth_char2() | |
262 ); | |
263 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
264 } | |
265 else if(get_globalState() == StDSIM4) | |
266 { | |
267 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' "); | |
268 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow); | |
269 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
270 , unit_depth_integer(simulation_get_aim_depth()) | |
271 , unit_depth_char1() | |
272 , unit_depth_char2() | |
273 ); | |
274 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow); | |
275 } | |
276 else | |
277 { | |
278 // keep empty | |
279 } | |
280 } | |
281 | |
282 | |
283 void t6_battery_low_customview_extra(void) | |
284 { | |
285 char TextC1[256]; | |
286 | |
287 TextC1[0] = '\002'; | |
288 TextC1[1] = '\f'; | |
289 TextC1[2] = '\025'; | |
290 TextC1[3] = '3'; | |
291 TextC1[4] = '1'; | |
292 TextC1[5] = '1'; | |
293 TextC1[6] = '1'; | |
294 TextC1[7] = '1'; | |
295 TextC1[8] = '1'; | |
296 TextC1[9] = '1'; | |
297 TextC1[10] = '1'; | |
298 TextC1[11] = '1'; | |
299 TextC1[12] = '1'; | |
300 TextC1[13] = '1'; | |
301 TextC1[14] = '0'; | |
302 TextC1[15] = 0; | |
303 | |
304 if(!warning_count_high_time) | |
305 TextC1[4] = '2'; | |
306 | |
307 GFX_write_string(&Batt24,&t6c1,TextC1,0); | |
308 } | |
309 | |
310 | |
311 | |
312 void t6_change_customview(void) | |
313 { | |
314 t3_basics_change_customview(&t6_selection_customview, t6_customviews); | |
315 } | |
316 | |
317 | |
318 void t6_refresh_customview(float depth) | |
319 { | |
320 uint8_t customViewLeftSide = CVIEW_T3_MaxDepth; | |
321 | |
322 if((t6_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) | |
323 t6_change_customview(); | |
324 | |
325 if(t6_getCustomView() == CVIEW_T3_ApnoeSurfaceInfo) | |
326 customViewLeftSide = CVIEW_T3_ApnoeSurfaceInfo; | |
327 | |
328 t3_basics_refresh_customview(depth, customViewLeftSide, &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea); | |
329 t3_basics_refresh_apnoeRight(depth, t6_getCustomView(), &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea); | |
330 } | |
331 | |
332 | |
333 uint8_t t6_test_customview_warnings(void) | |
334 { | |
335 uint8_t count = 0; | |
336 | |
337 count = 0; | |
338 return count; | |
339 } | |
340 | |
341 /* | |
342 | |
343 char text[512]; | |
344 uint16_t textpointer = 0; | |
345 | |
346 | |
347 // CVIEW_T3_Temperature | |
348 float temperatureThisCall; | |
349 float temperature; | |
350 | |
351 | |
352 // CVIEW_T3_StopWatch | |
353 SDivetime Stopwatch = {0,0,0,0}; | |
354 float fAverageDepth, fAverageDepthAbsolute; | |
355 uint16_t tempWinX0; | |
356 uint16_t tempWinY0; | |
357 | |
358 switch(t6_selection_customview) | |
359 { | |
360 case CVIEW_T3_ApnoeTimes: | |
361 break; | |
362 | |
363 case CVIEW_T3_StopWatch: | |
364 Stopwatch.Total = timer_Stopwatch_GetTime(); | |
365 Stopwatch.Minutes = Stopwatch.Total / 60; | |
366 Stopwatch.Seconds = Stopwatch.Total - ( Stopwatch.Minutes * 60 ); | |
367 fAverageDepth = timer_Stopwatch_GetAvarageDepth_Meter(); | |
368 fAverageDepthAbsolute = stateUsed->lifeData.average_depth_meter; | |
369 | |
370 snprintf(text,TEXTSIZE,"\032\f%c",TXT_AvgDepth); | |
371 GFX_write_string(&FontT42,&t6c1,text,0); | |
372 snprintf(text,TEXTSIZE,"\030\003\016%01.1f",fAverageDepthAbsolute); | |
373 GFX_write_string(&FontT105,&t6c1,text,0); | |
374 | |
375 tempWinX0 = t6c1.WindowX0; | |
376 tempWinY0 = t6c1.WindowY0; | |
377 t6c1.WindowX0 = 480; | |
378 // snprintf(text,TEXTSIZE,"\032\f%c%c - %c",TXT_2BYTE, TXT2BYTE_Clock, TXT_AvgDepth); | |
379 snprintf(text,TEXTSIZE,"\032\f%c", TXT_Stopwatch); | |
380 GFX_write_string(&FontT42,&t6c1,text,0); | |
381 snprintf(text,TEXTSIZE,"\030\016%01.1f",fAverageDepth); | |
382 GFX_write_string(&FontT105,&t6c1,text,0); | |
383 t6c1.WindowY0 = 100; | |
384 snprintf(text,TEXTSIZE,"\030%u:\016\016%02u",Stopwatch.Minutes, Stopwatch.Seconds); | |
385 GFX_write_string(&FontT105,&t6c1,text,0); | |
386 t6c1.WindowX0 = tempWinX0; | |
387 t6c1.WindowY0 = tempWinY0; | |
388 break; | |
389 | |
390 case CVIEW_T3_Temperature: | |
391 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature); | |
392 GFX_write_string(&FontT42,&t6c1,text,0); | |
393 // mean value | |
394 temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); | |
395 temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; | |
396 idTemperatureLastCall++; | |
397 if(idTemperatureLastCall >= 3) | |
398 idTemperatureLastCall = 0; | |
399 temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; | |
400 textpointer = snprintf(text,TEXTSIZE,"\030\003\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F | |
401 if(settingsGetPointer()->nonMetricalSystem == 0) | |
402 text[textpointer++] = 'C'; | |
403 else | |
404 text[textpointer++] = 'F'; | |
405 text[textpointer++] = 0; | |
406 GFX_write_string(&FontT105,&t6c1,text,0); | |
407 break; | |
408 | |
409 case CVIEW_Compass: | |
410 snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE, TXT2BYTE_Compass); | |
411 GFX_write_string(&FontT42,&t6c1,text,0); | |
412 snprintf(text,100,"\030\003%03i`",(uint16_t)stateUsed->lifeData.compass_heading); | |
413 GFX_write_string(&FontT105,&t6c1,text,0); | |
414 t6_compass((uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading); | |
415 break; | |
416 | |
417 case CVIEW_T3_MaxDepth: | |
418 default: | |
419 snprintf(text,TEXTSIZE,"\032\f%c",TXT_MaxDepth); | |
420 GFX_write_string(&FontT42,&t6c1,text,0); | |
421 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); | |
422 t3_basics_colorscheme_mod(text); | |
423 GFX_write_string(&FontT105,&t6c1,text,1); | |
424 break; | |
425 } | |
426 } | |
427 | |
428 | |
429 void t6_show_customview_warnings(void) | |
430 { | |
431 char text[256], textMain[256]; | |
432 uint8_t textpointer, textpointerMain, lineFree, more; | |
433 | |
434 snprintf(text,TEXTSIZE,"\025\f%c",TXT_Warning); | |
435 GFX_write_string(&FontT42,&t6c1,text,0); | |
436 | |
437 lineFree = 1; | |
438 more = 0; | |
439 | |
440 textpointerMain = 0; | |
441 textMain[textpointerMain++] = '\025'; | |
442 textMain[textpointerMain++] = '\003'; | |
443 | |
444 textpointer = 0; | |
445 | |
446 text[textpointer++] = '\021'; | |
447 text[textpointer++] = TXT_2BYTE; | |
448 text[textpointer++] = TXT2BYTE_WarnDecoMissed; | |
449 if(stateUsed->warnings.decoMissed) | |
450 { | |
451 text[textpointer - 3] = '\025'; | |
452 if(lineFree) | |
453 { | |
454 textMain[textpointerMain++] = TXT_2BYTE; | |
455 textMain[textpointerMain++] = text[textpointer - 1]; | |
456 textMain[textpointerMain] = 0; | |
457 lineFree--; | |
458 } | |
459 else | |
460 { | |
461 more++; | |
462 } | |
463 } | |
464 | |
465 text[textpointer++] = '\t'; | |
466 text[textpointer++] = '\021'; | |
467 text[textpointer++] = TXT_2BYTE; | |
468 text[textpointer++] = TXT2BYTE_WarnPPO2Low; | |
469 if(stateUsed->warnings.ppO2Low) | |
470 { | |
471 text[textpointer - 3] = '\025'; | |
472 if(lineFree) | |
473 { | |
474 textMain[textpointerMain++] = TXT_2BYTE; | |
475 textMain[textpointerMain++] = text[textpointer - 1]; | |
476 textMain[textpointerMain] = 0; | |
477 lineFree--; | |
478 } | |
479 else | |
480 { | |
481 more++; | |
482 } | |
483 } | |
484 | |
485 text[textpointer++] = '\n'; | |
486 text[textpointer++] = '\r'; | |
487 text[textpointer++] = '\021'; | |
488 text[textpointer++] = TXT_2BYTE; | |
489 text[textpointer++] = TXT2BYTE_WarnPPO2High; | |
490 if(stateUsed->warnings.ppO2High) | |
491 { | |
492 text[textpointer - 3] = '\025'; | |
493 if(lineFree) | |
494 { | |
495 textMain[textpointerMain++] = TXT_2BYTE; | |
496 textMain[textpointerMain++] = text[textpointer - 1]; | |
497 textMain[textpointerMain] = 0; | |
498 lineFree--; | |
499 } | |
500 else | |
501 { | |
502 more++; | |
503 } | |
504 } | |
505 | |
506 text[textpointer++] = '\t'; | |
507 text[textpointer++] = '\021'; | |
508 text[textpointer++] = TXT_2BYTE; | |
509 text[textpointer++] = TXT2BYTE_WarnFallback; | |
510 if(stateUsed->warnings.fallback) | |
511 { | |
512 text[textpointer - 3] = '\025'; | |
513 if(lineFree) | |
514 { | |
515 textMain[textpointerMain++] = TXT_2BYTE; | |
516 textMain[textpointerMain++] = text[textpointer - 1]; | |
517 textMain[textpointerMain] = 0; | |
518 lineFree--; | |
519 } | |
520 else | |
521 { | |
522 more++; | |
523 } | |
524 } | |
525 | |
526 text[textpointer++] = '\n'; | |
527 text[textpointer++] = '\r'; | |
528 text[textpointer++] = '\021'; | |
529 text[textpointer++] = TXT_2BYTE; | |
530 text[textpointer++] = TXT2BYTE_WarnSensorLinkLost; | |
531 if(stateUsed->warnings.sensorLinkLost) | |
532 { | |
533 text[textpointer - 3] = '\025'; | |
534 if(lineFree) | |
535 { | |
536 textMain[textpointerMain++] = TXT_2BYTE; | |
537 textMain[textpointerMain++] = text[textpointer - 1]; | |
538 textMain[textpointerMain] = 0; | |
539 lineFree--; | |
540 } | |
541 else | |
542 { | |
543 more++; | |
544 } | |
545 } | |
546 | |
547 text[textpointer] = 0; | |
548 GFX_write_string(&FontT48,&t6c1,textMain,1); | |
549 if(more) | |
550 { | |
551 GFX_write_string(&FontT48,&t6c2,text,1); | |
552 } | |
553 } | |
554 | |
555 | |
556 void t6_change_customview(void) | |
557 { | |
558 const uint8_t *pViews; | |
559 pViews = t6_customviews; | |
560 | |
561 while((*pViews != CVIEW_T3_END) && (*pViews != t6_selection_customview)) | |
562 {pViews++;} | |
563 | |
564 if(*pViews < CVIEW_T3_END) | |
565 pViews++; | |
566 | |
567 if(*pViews == CVIEW_T3_END) | |
568 { | |
569 t6_selection_customview = t6_customviews[0]; | |
570 } | |
571 else | |
572 t6_selection_customview = *pViews; | |
573 } | |
574 | |
575 | |
576 void t3_basics_colorscheme_mod(char *text) | |
577 { | |
578 if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard()) | |
579 { | |
580 text[0] = '\027'; | |
581 } | |
582 } | |
583 | |
584 point_t t6_compass_circle(uint8_t id, uint16_t degree) | |
585 { | |
586 float fCos, fSin; | |
587 const float piMult = ((2 * 3.14159) / 360); | |
588 // const int radius[4] = {95,105,115,60}; | |
589 const int radius[4] = {85,95,105,90}; | |
590 const point_t offset = {.x = 600, .y = 116}; | |
591 | |
592 static point_t r[4][360] = { 0 }; | |
593 | |
594 if(r[0][0].y == 0) | |
595 { | |
596 for(int i=0;i<360;i++) | |
597 { | |
598 fCos = cos(i * piMult); | |
599 fSin = sin(i * piMult); | |
600 for(int j=0;j<4;j++) | |
601 { | |
602 r[j][i].x = offset.x + (int)(fSin * radius[j]); | |
603 r[j][i].y = offset.y + (int)(fCos * radius[j]); | |
604 } | |
605 } | |
606 } | |
607 if(id > 3) id = 0; | |
608 if(degree > 359) degree = 0; | |
609 return r[id][degree]; | |
610 } | |
611 | |
612 | |
613 void t6_compass(uint16_t ActualHeading, uint16_t UserSetHeading) | |
614 { | |
615 uint16_t LineHeading; | |
616 point_t center; | |
617 static int32_t LastHeading = 0; | |
618 int32_t newHeading = 0; | |
619 int32_t diff = 0; | |
620 int32_t diff2 = 0; | |
621 | |
622 int32_t diffAbs = 0; | |
623 int32_t diffAbs2 = 0; | |
624 | |
625 newHeading = ActualHeading; | |
626 | |
627 diff = newHeading - LastHeading; | |
628 | |
629 if(newHeading < LastHeading) | |
630 diff2 = newHeading + 360 - LastHeading; | |
631 else | |
632 diff2 = newHeading - 360 - LastHeading; | |
633 | |
634 diffAbs = diff; | |
635 if(diffAbs < 0) | |
636 diffAbs *= -1; | |
637 | |
638 diffAbs2 = diff2; | |
639 if(diffAbs2 < 0) | |
640 diffAbs2 *= -1; | |
641 | |
642 | |
643 if(diffAbs <= diffAbs2) | |
644 newHeading = LastHeading + (diff / 2); | |
645 else | |
646 newHeading = LastHeading + (diff2 / 2); | |
647 | |
648 if(newHeading < 0) | |
649 newHeading += 360; | |
650 else | |
651 if(newHeading >= 360) | |
652 newHeading -= 360; | |
653 | |
654 LastHeading = newHeading; | |
655 ActualHeading = newHeading; | |
656 | |
657 if (ActualHeading < 90) | |
658 ActualHeading += 360; | |
659 | |
660 while(ActualHeading > 359) ActualHeading -= 360; | |
661 | |
662 LineHeading = 360 - ActualHeading; | |
663 GFX_draw_thick_line(9,&t6screen, t6_compass_circle(0,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font030); // North | |
664 LineHeading += 90; | |
665 if(LineHeading > 359) LineHeading -= 360; | |
666 GFX_draw_thick_line(9,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Maintick | |
667 LineHeading += 90; | |
668 if(LineHeading > 359) LineHeading -= 360; | |
669 GFX_draw_thick_line(9,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
670 LineHeading += 90; | |
671 if(LineHeading > 359) LineHeading -= 360; | |
672 GFX_draw_thick_line(9,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
673 | |
674 LineHeading = 360 - ActualHeading; | |
675 LineHeading += 45; | |
676 if(LineHeading > 359) LineHeading -= 360; | |
677 GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Subtick | |
678 LineHeading += 90; | |
679 if(LineHeading > 359) LineHeading -= 360; | |
680 GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
681 LineHeading += 90; | |
682 if(LineHeading > 359) LineHeading -= 360; | |
683 GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
684 LineHeading += 90; | |
685 if(LineHeading > 359) LineHeading -= 360; | |
686 GFX_draw_thick_line(5,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
687 | |
688 LineHeading = 360 - ActualHeading; | |
689 LineHeading += 22; | |
690 if(LineHeading > 359) LineHeading -= 360; | |
691 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Subtick | |
692 LineHeading += 45; | |
693 if(LineHeading > 359) LineHeading -= 360; | |
694 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
695 LineHeading += 45; | |
696 if(LineHeading > 359) LineHeading -= 360; | |
697 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
698 LineHeading += 45; | |
699 if(LineHeading > 359) LineHeading -= 360; | |
700 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
701 LineHeading += 45; | |
702 if(LineHeading > 359) LineHeading -= 360; | |
703 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); // Subtick | |
704 LineHeading += 45; | |
705 if(LineHeading > 359) LineHeading -= 360; | |
706 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
707 LineHeading += 45; | |
708 if(LineHeading > 359) LineHeading -= 360; | |
709 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
710 LineHeading += 45; | |
711 if(LineHeading > 359) LineHeading -= 360; | |
712 GFX_draw_thick_line(3,&t6screen, t6_compass_circle(1,LineHeading), t6_compass_circle(2,LineHeading), CLUT_Font031); | |
713 | |
714 if(UserSetHeading) | |
715 { | |
716 LineHeading = UserSetHeading + 360 - ActualHeading; | |
717 if(LineHeading > 359) LineHeading -= 360; | |
718 GFX_draw_thick_line(9,&t6screen, t6_compass_circle(3,LineHeading), t6_compass_circle(2,LineHeading), CLUT_CompassUserHeadingTick); | |
719 | |
720 // R�ckpeilung, User Back Heading | |
721 LineHeading = UserSetHeading + 360 + 180 - ActualHeading; | |
722 if(LineHeading > 359) LineHeading -= 360; | |
723 if(LineHeading > 359) LineHeading -= 360; | |
724 GFX_draw_thick_line(9,&t6screen, t6_compass_circle(3,LineHeading), t6_compass_circle(2,LineHeading), CLUT_CompassUserBackHeadingTick); | |
725 } | |
726 | |
727 center.x = 600; | |
728 center.y = 116; | |
729 GFX_draw_circle(&t6screen, center, 106, CLUT_Font030); | |
730 GFX_draw_circle(&t6screen, center, 107, CLUT_Font030); | |
731 GFX_draw_circle(&t6screen, center, 108, CLUT_Font030); | |
732 } | |
733 */ | |
734 |