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