Mercurial > public > ostc4
annotate Discovery/Src/t7.c @ 101:83feba2ad1c3 kittz
globals
author | Dmitry Romanov <kitt@bk.ru> |
---|---|
date | Tue, 27 Nov 2018 13:18:59 +0300 |
parents | 8f8ea3a32e82 |
children | 4276d56eb37c cc8e24374b83 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/t7.c | |
5 /// \brief Main Template file for dive mode 7x | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 23-April-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 "t7.h" | |
31 | |
32 //#include "bonexConnect.h" | |
33 #include "data_exchange_main.h" | |
34 #include "decom.h" | |
35 #include "gfx_fonts.h" | |
36 #include "logbook_miniLive.h" | |
37 #include "math.h" | |
38 #include "tHome.h" | |
39 #include "simulation.h" | |
40 #include "timer.h" | |
41 #include "unit.h" | |
42 | |
43 /* Private function prototypes -----------------------------------------------*/ | |
44 | |
45 void t7_refresh_surface(void); | |
46 void t7_refresh_surface_debugmode(void); | |
47 void t7_refresh_divemode(void); | |
48 void t7_refresh_sleep_design_fun(void); | |
49 void t7_refresh_divemode_userselected_left_lower_corner(void); | |
50 void t7_refresh_customview(void); | |
51 | |
52 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide); | |
53 | |
54 void t7_tissues(const SDiveState * pState); | |
55 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading); | |
56 void t7_scooter(void); | |
57 void t7_SummaryOfLeftCorner(void); | |
58 void t7_debug(void); | |
59 | |
60 void t7_miniLiveLogProfile(void); | |
61 //void t7_clock(void); | |
62 void t7_logo_OSTC(void); | |
63 void t7_colorscheme_mod(char *text); | |
64 | |
65 uint8_t t7_test_customview_warnings(void); | |
66 void t7_show_customview_warnings(void); | |
67 | |
68 uint8_t t7_test_customview_warnings_surface_mode(void); | |
69 void t7_show_customview_warnings_surface_mode(void); | |
70 | |
71 uint8_t t7_customtextPrepare(char * text); | |
72 | |
73 /* Importend function prototypes ---------------------------------------------*/ | |
74 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); | |
75 | |
76 /* Exported variables --------------------------------------------------------*/ | |
77 | |
78 /* Private variables ---------------------------------------------------------*/ | |
79 float depthLastCall[9] = { 0,0,0,0,0,0,0,0,0}; | |
80 uint8_t idDepthLastCall = 0; | |
81 float temperatureLastCall[3] = { 0,0,0}; | |
82 uint8_t idTemperatureLastCall = 0; | |
83 | |
84 GFX_DrawCfgScreen t7screen; | |
85 GFX_DrawCfgScreen t7screenCompass; | |
86 | |
87 /* left 3 fields | |
88 * right 3 fields | |
89 * centered one field on top of customview, one below | |
90 * customview header + customview + warning | |
91 */ | |
92 GFX_DrawCfgWindow t7l1, t7l2, t7l3; | |
93 GFX_DrawCfgWindow t7r1, t7r2, t7r3; | |
94 GFX_DrawCfgWindow t7c1, t7batt, t7c2, t7charge, t7voltage; | |
95 GFX_DrawCfgWindow t7cH, t7cC, t7cW, t7cY0free; | |
96 GFX_DrawCfgWindow t7pCompass; | |
97 GFX_DrawCfgWindow t7surfaceL, t7surfaceR; | |
98 | |
99 uint8_t selection_custom_field = 1; | |
100 uint8_t selection_customview = 1; | |
101 | |
102 uint8_t updateNecessary = 0; | |
103 | |
104 typedef struct{ | |
105 uint32_t pointer; | |
106 uint32_t x0; | |
107 uint32_t y0; | |
108 uint32_t width; | |
109 uint32_t height; | |
110 } SBackground; | |
111 | |
112 SBackground background = | |
113 { | |
114 .pointer = NULL, | |
115 }; | |
116 | |
117 | |
118 /* Private types -------------------------------------------------------------*/ | |
119 const uint8_t customviewsDiveStandard[] = | |
120 { | |
121 CVIEW_sensors, | |
122 CVIEW_Compass, | |
123 CVIEW_Decolist, | |
124 CVIEW_Tissues, | |
125 CVIEW_Profile, | |
126 CVIEW_Gaslist, | |
127 CVIEW_sensors_mV, | |
128 CVIEW_EADTime, | |
129 CVIEW_SummaryOfLeftCorner, | |
130 CVIEW_noneOrDebug, | |
131 CVIEW_END, | |
132 CVIEW_END | |
133 }; | |
134 | |
135 const uint8_t customviewsSurfaceStandard[] = | |
136 { | |
137 // CVIEW_CompassDebug, | |
138 CVIEW_Hello, | |
139 CVIEW_sensors, | |
140 CVIEW_Compass, | |
141 CVIEW_Tissues, | |
142 CVIEW_sensors_mV, | |
143 CVIEW_END, | |
144 CVIEW_END | |
145 }; | |
146 | |
147 const uint8_t customviewsDiveScooter[] = | |
148 { | |
149 CVIEW_Scooter, | |
150 CVIEW_sensors, | |
151 CVIEW_Compass, | |
152 CVIEW_Decolist, | |
153 CVIEW_Tissues, | |
154 CVIEW_Profile, | |
155 CVIEW_Gaslist, | |
156 CVIEW_sensors_mV, | |
157 CVIEW_EADTime, | |
158 CVIEW_SummaryOfLeftCorner, | |
159 CVIEW_noneOrDebug, | |
160 CVIEW_END, | |
161 CVIEW_END | |
162 }; | |
163 | |
164 const uint8_t customviewsSurfaceScooter[] = | |
165 { | |
166 // CVIEW_CompassDebug, | |
167 CVIEW_Scooter, | |
168 CVIEW_Hello, | |
169 CVIEW_sensors, | |
170 CVIEW_Compass, | |
171 CVIEW_Tissues, | |
172 CVIEW_sensors_mV, | |
173 CVIEW_END, | |
174 CVIEW_END | |
175 }; | |
176 | |
177 const uint8_t *customviewsDive = customviewsDiveStandard; | |
178 const uint8_t *customviewsSurface = customviewsSurfaceStandard; | |
179 | |
180 #define TEXTSIZE 16 | |
181 /* offset includes line: 2 = line +1 | |
182 * box (line) is 300 px | |
183 * inside is 296 px | |
184 * left of box are 249 px ( 0..248) | |
185 * right of box are 249 px (551 .. 799) | |
186 */ | |
187 | |
188 #define CUSTOMBOX_LINE_LEFT (250) | |
189 #define CUSTOMBOX_LINE_RIGHT (549) | |
190 #define CUSTOMBOX_INSIDE_OFFSET (2) | |
191 #define CUSTOMBOX_OUTSIDE_OFFSET (2) | |
192 #define CUSTOMBOX_SPACE_INSIDE (CUSTOMBOX_LINE_RIGHT + 1 - (CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_INSIDE_OFFSET)) | |
193 | |
194 | |
195 /* Exported functions --------------------------------------------------------*/ | |
196 | |
197 void t7_init(void) | |
198 { | |
199 if(getLicence() == LICENCEBONEX) | |
200 { | |
201 customviewsDive = customviewsDiveScooter; | |
202 customviewsSurface = customviewsSurfaceScooter; | |
203 } | |
204 | |
205 selection_custom_field = 1; | |
206 selection_customview = customviewsSurface[0]; | |
207 | |
208 t7screen.FBStartAdress = 0; | |
209 t7screen.ImageHeight = 480; | |
210 t7screen.ImageWidth = 800; | |
211 t7screen.LayerIndex = 1; | |
212 | |
213 t7screenCompass.FBStartAdress = 0; | |
214 t7screenCompass.ImageHeight = 240; | |
215 t7screenCompass.ImageWidth = 1600; | |
216 t7screenCompass.LayerIndex = 0; | |
217 | |
218 t7l1.Image = &t7screen; | |
219 t7l1.WindowNumberOfTextLines = 2; | |
220 t7l1.WindowLineSpacing = 19; // Abstand von Y0 | |
221 t7l1.WindowTab = 100; // vermtl. ohne Verwendung in diesem Fenster | |
222 t7l1.WindowX0 = 0; | |
223 t7l1.WindowX1 = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET; | |
224 t7l1.WindowY0 = 318; | |
225 t7l1.WindowY1 = 479; | |
226 | |
227 t7l2.Image = &t7screen; | |
228 t7l2.WindowNumberOfTextLines = 2; | |
229 t7l2.WindowLineSpacing = 22; // Abstand von Y0 | |
230 t7l2.WindowTab = 100; // vermtl. ohne Verwendung in diesem Fenster | |
231 t7l2.WindowX0 = 0; | |
232 t7l2.WindowX1 = t7l1.WindowX1; | |
233 t7l2.WindowY0 = 142; | |
234 t7l2.WindowY1 = t7l1.WindowY0 - 5; | |
235 | |
236 t7l3.Image = &t7screen; | |
237 t7l3.WindowNumberOfTextLines = 2; | |
238 t7l3.WindowLineSpacing = 58; // Abstand von Y0 | |
239 t7l3.WindowTab = 100; // vermtl. ohne Verwendung in diesem Fenster | |
240 t7l3.WindowX0 = 0; | |
241 t7l3.WindowX1 = t7l1.WindowX1; | |
242 t7l3.WindowY0 = 0; | |
243 t7l3.WindowY1 = t7l2.WindowY0 - 5; | |
244 | |
245 t7r1.Image = &t7screen; | |
246 t7r1.WindowNumberOfTextLines = 2; | |
247 t7r1.WindowLineSpacing = t7l1.WindowLineSpacing; | |
248 t7r1.WindowTab = 100; | |
249 t7r1.WindowX0 = 550; | |
250 t7r1.WindowX1 = 799; | |
251 t7r1.WindowY0 = t7l1.WindowY0; | |
252 t7r1.WindowY1 = 479; | |
253 | |
254 t7r2.Image = &t7screen; | |
255 t7r2.WindowNumberOfTextLines = 2; | |
256 t7r2.WindowLineSpacing = t7l2.WindowLineSpacing; | |
257 t7r2.WindowTab = 100; | |
258 t7r2.WindowX0 = 550; | |
259 t7r2.WindowX1 = 799; | |
260 t7r2.WindowY0 = t7l2.WindowY0; | |
261 t7r2.WindowY1 = t7l2.WindowY1; | |
262 | |
263 t7r3.Image = &t7screen; | |
264 t7r3.WindowNumberOfTextLines = 2; | |
265 t7r3.WindowLineSpacing = 0;//t7l3.WindowLineSpacing; | |
266 t7r3.WindowTab = 100; | |
267 t7r3.WindowX0 = CUSTOMBOX_LINE_RIGHT + CUSTOMBOX_OUTSIDE_OFFSET; | |
268 t7r3.WindowX1 = 799; | |
269 t7r3.WindowY0 = t7l3.WindowY0; | |
270 t7r3.WindowY1 = t7l3.WindowY1; | |
271 | |
272 t7cC.Image = &t7screen; | |
273 t7cC.WindowNumberOfTextLines = 3; | |
274 t7cC.WindowLineSpacing = 95; // Abstand von Y0 | |
275 t7cC.WindowTab = 100; | |
276 t7cC.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
277 t7cC.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
278 t7cC.WindowY0 = 90; | |
279 t7cC.WindowY1 = 434 - 95; | |
280 | |
281 t7cH.Image = &t7screen; | |
282 t7cH.WindowNumberOfTextLines = 1; | |
283 t7cH.WindowLineSpacing = 95; // Abstand von Y0 | |
284 t7cH.WindowTab = 100; | |
285 t7cH.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
286 t7cH.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
287 t7cH.WindowY0 = 434 - 94; | |
288 t7cH.WindowY1 = 434; | |
289 | |
290 t7cW.Image = &t7screen; | |
291 t7cW.WindowNumberOfTextLines = 3; | |
292 t7cW.WindowLineSpacing = 95; // Abstand von Y0 | |
293 t7cW.WindowTab = 100; | |
294 t7cW.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
295 t7cW.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
296 t7cW.WindowY0 = 90; | |
297 t7cW.WindowY1 = 434 - 95; | |
298 | |
299 t7surfaceL.Image = &t7screen; | |
300 t7surfaceL.WindowNumberOfTextLines = 9; | |
301 t7surfaceL.WindowLineSpacing = 53; | |
302 t7surfaceL.WindowTab = 100; | |
303 t7surfaceL.WindowX0 = 0; | |
304 t7surfaceL.WindowX1 = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET; | |
305 t7surfaceL.WindowY0 = 0; | |
306 t7surfaceL.WindowY1 = 480; | |
307 | |
308 t7surfaceR.Image = &t7screen; | |
309 t7surfaceR.WindowNumberOfTextLines = 9; | |
310 t7surfaceR.WindowLineSpacing = 53; | |
311 t7surfaceR.WindowTab = 100; | |
312 t7surfaceR.WindowX0 = CUSTOMBOX_LINE_RIGHT + CUSTOMBOX_OUTSIDE_OFFSET; | |
313 t7surfaceR.WindowX1 = 800; | |
314 t7surfaceR.WindowY0 = 0; | |
315 t7surfaceR.WindowY1 = 480; | |
316 | |
317 t7cY0free.Image = &t7screen; | |
318 t7cY0free.WindowNumberOfTextLines = 1; | |
319 t7cY0free.WindowLineSpacing = 95; | |
320 t7cY0free.WindowTab = 100; | |
321 t7cY0free.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
322 t7cY0free.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
323 t7cY0free.WindowY0 = 90; | |
324 t7cY0free.WindowY1 = 434 - 95; | |
325 | |
326 t7batt.Image = &t7screen; | |
327 t7batt.WindowNumberOfTextLines = 1; | |
328 t7batt.WindowLineSpacing = 10; | |
329 t7batt.WindowTab = 100; | |
330 t7batt.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
331 t7batt.WindowX0 = t7batt.WindowX1 - (52+52); | |
332 t7batt.WindowY1 = 479; | |
333 t7batt.WindowY0 = t7batt.WindowY1 - 25; | |
334 | |
335 t7charge.Image = &t7screen; | |
336 t7charge.WindowNumberOfTextLines = 1; | |
337 t7charge.WindowLineSpacing = 10; | |
338 t7charge.WindowTab = 100; | |
339 t7charge.WindowX1 = t7batt.WindowX1 - 18; | |
340 t7charge.WindowX0 = t7charge.WindowX1 - 14; | |
341 t7charge.WindowY1 = 479; | |
342 t7charge.WindowY0 = t7batt.WindowY1 - 25; | |
343 | |
344 t7voltage.Image = &t7screen; | |
345 t7voltage.WindowNumberOfTextLines = 1; | |
346 t7voltage.WindowLineSpacing = 10; | |
347 t7voltage.WindowTab = 100; | |
348 t7voltage.WindowX0 = t7charge.WindowX0 - 10; | |
349 t7voltage.WindowX1 = t7voltage.WindowX0 + (18*3)+ 9; | |
350 t7voltage.WindowY1 = 479; | |
351 t7voltage.WindowY0 = t7batt.WindowY1 - 25; | |
352 | |
353 t7c1.Image = &t7screen; | |
354 t7c1.WindowNumberOfTextLines = 1; | |
355 t7c1.WindowLineSpacing = 10; | |
356 t7c1.WindowTab = 100; | |
357 t7c1.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
358 t7c1.WindowX1 = t7batt.WindowX0 - 18; | |
359 t7c1.WindowY0 = 435; | |
360 t7c1.WindowY1 = 479; | |
361 | |
362 t7c2.Image = &t7screen; | |
363 t7c2.WindowNumberOfTextLines = 1; | |
364 t7c2.WindowLineSpacing = 0; // Abstand von Y0 | |
365 t7c2.WindowTab = 100; | |
366 t7c2.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
367 t7c2.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
368 t7c2.WindowY0 = 0; | |
369 t7c2.WindowY1 = 69; | |
370 | |
371 t7pCompass.Image = &t7screenCompass; | |
372 t7pCompass.WindowNumberOfTextLines = 1; | |
373 t7pCompass.WindowLineSpacing = 100; // Abstand von Y0 | |
374 t7pCompass.WindowTab = 100; | |
375 t7pCompass.WindowX0 = 0; | |
376 t7pCompass.WindowX1 = 1600-1; | |
377 t7pCompass.WindowY0 = 0; | |
378 t7pCompass.WindowY1 = 100-1; | |
379 | |
380 init_t7_compass(); | |
381 } | |
382 | |
383 | |
384 void t7_refresh_sleepmode_fun(void) | |
385 { | |
386 uint32_t oldScreen; | |
387 | |
388 oldScreen = t7screen.FBStartAdress; | |
389 t7screen.FBStartAdress = getFrame(22); | |
390 | |
391 t7_refresh_sleep_design_fun(); | |
392 | |
393 if(get_globalState() == StStop) | |
394 { | |
395 GFX_SetFramesTopBottom(t7screen.FBStartAdress, NULL,480); | |
396 } | |
397 releaseFrame(22,oldScreen); | |
398 } | |
399 | |
400 | |
401 void t7_refresh(void) | |
402 { | |
403 static uint8_t last_mode = MODE_SURFACE; | |
404 | |
405 // uint32_t oldScreen;//, oldPlugin; | |
406 SStateList status; | |
407 get_globalStateList(&status); | |
408 | |
409 t7screen.FBStartAdress = getFrame(22); | |
410 | |
411 background.pointer = 0; | |
412 | |
413 if(stateUsed->mode == MODE_DIVE) | |
414 { | |
415 if(last_mode != MODE_DIVE) | |
416 { | |
417 last_mode = MODE_DIVE; | |
418 /* lower left corner primary */ | |
419 selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary; | |
420 /* custom view primary OR debug if automatic return is off */ | |
421 if((settingsGetPointer()->tX_customViewTimeout == 0) && (settingsGetPointer()->showDebugInfo)) | |
422 selection_customview = CVIEW_noneOrDebug; | |
423 else | |
424 selection_customview = settingsGetPointer()->tX_customViewPrimary; | |
425 } | |
426 | |
427 if(status.page == PageSurface) | |
428 set_globalState(StD); | |
429 | |
430 if(stateUsed->diveSettings.diveMode == DIVEMODE_Gauge) | |
431 { | |
432 settingsGetPointer()->design = 5; | |
433 releaseAllFramesExcept(22,t7screen.FBStartAdress); | |
434 releaseFrame(22,t7screen.FBStartAdress); | |
435 return; | |
436 } | |
437 else if(stateUsed->diveSettings.diveMode == DIVEMODE_Apnea) | |
438 { | |
439 settingsGetPointer()->design = 6; | |
440 releaseAllFramesExcept(22,t7screen.FBStartAdress); | |
441 releaseFrame(22,t7screen.FBStartAdress); | |
442 return; | |
443 } | |
444 else if(DataEX_scooterFoundAndValidLicence()) // new for t9 hw 160711 | |
445 { | |
446 settingsGetPointer()->design = 9; | |
447 releaseAllFramesExcept(22,t7screen.FBStartAdress); | |
448 releaseFrame(22,t7screen.FBStartAdress); | |
449 return; | |
450 } | |
451 else | |
452 { | |
453 t7_refresh_divemode(); | |
454 } | |
455 } | |
456 else // from if(stateUsed->mode == MODE_DIVE) | |
457 { | |
458 if(last_mode != MODE_SURFACE) | |
459 { | |
460 last_mode = MODE_SURFACE; | |
461 selection_customview = customviewsSurface[0]; | |
462 } | |
463 if(status.page == PageDive) | |
464 set_globalState(StS); | |
465 | |
466 if(settingsGetPointer()->showDebugInfo) | |
467 t7_refresh_surface_debugmode(); | |
468 else | |
469 t7_refresh_surface(); | |
470 } | |
471 | |
472 tHome_show_lost_connection_count(&t7screen); | |
473 | |
474 if(status.base == BaseHome) | |
475 { | |
476 if(background.pointer) | |
477 { | |
478 GFX_SetFrameTop(t7screen.FBStartAdress); | |
479 GFX_SetFrameBottom(background.pointer,background.x0 , background.y0, background.width, background.height); | |
480 } | |
481 else | |
482 GFX_SetFramesTopBottom(t7screen.FBStartAdress, NULL,480); | |
483 } | |
484 | |
485 releaseAllFramesExcept(22,t7screen.FBStartAdress); | |
486 } | |
487 | |
488 /* Private functions ---------------------------------------------------------*/ | |
489 | |
490 void t7_fill_surfacetime_helper(SSurfacetime *outArray, uint32_t inputMinutes, uint32_t inputSeconds) | |
491 { | |
492 inputSeconds += inputMinutes * 60; | |
493 | |
494 outArray->Total = inputSeconds; | |
495 | |
496 outArray->Days = inputSeconds / 86400;// (24*60*60); | |
497 inputSeconds -= 86400 * (uint32_t)outArray->Days; | |
498 | |
499 outArray->Hours = inputSeconds / 3600;// (60*60); | |
500 inputSeconds -= 3600 * (uint32_t)outArray->Hours; | |
501 | |
502 outArray->Minutes = inputSeconds / 60;; | |
503 inputSeconds -= 60 * (uint32_t)outArray->Minutes; | |
504 | |
505 outArray->Seconds = inputSeconds; | |
506 } | |
507 | |
508 void t7_refresh_sleep_design_fun(void) | |
509 { | |
510 static uint16_t state = 0; | |
511 uint16_t ytop = 0; | |
512 | |
513 state +=1; | |
514 if(state > 800) | |
515 state = 1; | |
516 | |
517 if(state > 400) | |
518 ytop = 800 - state; | |
519 else | |
520 ytop = 0 + state; | |
521 Gfx_write_label_var(&t7screen, 300,800, ytop,&FontT48,CLUT_Font020,"SLEEP SLEEP SLEEP"); | |
522 } | |
523 | |
524 void t7_refresh_surface(void) | |
525 { | |
526 char text[256]; | |
527 uint8_t date[3], year,month,day; | |
528 uint32_t color; | |
529 uint8_t customview_warnings = 0; | |
530 | |
531 RTC_DateTypeDef Sdate; | |
532 RTC_TimeTypeDef Stime; | |
533 RTC_DateTypeDef SdateFirmware; | |
534 | |
535 uint8_t dateNotSet = 0; | |
536 | |
537 uint8_t oxygen_percentage, gasOffset, actualGasID; | |
538 // uint16_t bottleFirstGas_bar; | |
539 point_t start, stop;//, other; | |
540 | |
541 // update in all customview modes | |
542 if(DataEX_check_RTE_version__needs_update() || font_update_required()) | |
543 updateNecessary = 1; | |
544 else | |
545 updateNecessary = 0; | |
546 | |
547 /* buttons */ | |
548 text[0] = TXT_2BYTE; | |
549 text[1] = TXT2BYTE_ButtonLogbook; | |
550 text[2] = 0; | |
551 write_content_simple(&t7screen, 0, 800, 480-24, &FontT24,text,CLUT_ButtonSurfaceScreen); | |
552 | |
553 text[0] = '\001'; | |
554 text[1] = TXT_2BYTE; | |
555 text[2] = TXT2BYTE_ButtonView; | |
556 text[3] = 0; | |
557 write_content_simple(&t7screen, 0, 800, 480-24, &FontT24,text,CLUT_ButtonSurfaceScreen); | |
558 | |
559 text[0] = '\002'; | |
560 text[1] = TXT_2BYTE; | |
561 text[2] = TXT2BYTE_ButtonMenu; | |
562 text[3] = 0; | |
563 write_content_simple(&t7screen, 0, 800, 480-24, &FontT24,text,CLUT_ButtonSurfaceScreen); | |
564 | |
565 /* | |
566 // scooter connected? | |
567 if(bC_getData(0,0,0,0) == BC_CONNECTED) | |
568 { | |
569 text[0] = '\f'; | |
570 text[1] = '\002'; | |
571 memcpy(&text[2],&settingsGetPointer()->scooterDeviceName,19); | |
572 text[21] = 0; | |
573 GFX_write_string_color(&FontT24,&t7r1,text,0,CLUT_NiceGreen); | |
574 } | |
575 */ | |
576 | |
577 /* was power on reset */ | |
578 //..... | |
579 /* removed hw 160802 in V1.1.1 | |
580 if(errorsInSettings) | |
581 { | |
582 sprintf(text,"Settings: %u",errorsInSettings); | |
583 GFX_write_string_color(&FontT42,&t7surfaceR,text,4,CLUT_WarningRed); | |
584 } | |
585 else | |
586 */ | |
587 if(DataEX_was_power_on()) | |
588 GFX_write_string_color(&FontT42,&t7surfaceR,"cold start",4,CLUT_WarningRed); | |
589 | |
590 /* time and date */ | |
591 translateDate(stateUsed->lifeData.dateBinaryFormat, &Sdate); | |
592 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime); | |
593 | |
594 firmwareGetDate(&SdateFirmware); | |
595 if(tHome_DateCode(&Sdate) < tHome_DateCode(&SdateFirmware)) | |
596 dateNotSet = 1; | |
597 else | |
598 dateNotSet = 0; | |
599 /* | |
600 if(Stime.Seconds % 2) | |
601 snprintf(text,255,"\001%02d:%02d",Stime.Hours,Stime.Minutes); | |
602 else | |
603 snprintf(text,255,"\001%02d\021:\020%02d",Stime.Hours,Stime.Minutes); | |
604 GFX_write_string(&FontT54,&t7surfaceR,text,3); | |
605 */ | |
606 // debug version: | |
607 if(Stime.Seconds % 2) | |
608 snprintf(text,255,"\001%02d:%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); | |
609 else if(dateNotSet) | |
610 snprintf(text,255,"\001\021%02d:%02d:%02d\020",Stime.Hours,Stime.Minutes,Stime.Seconds); | |
611 else | |
612 snprintf(text,255,"\001%02d\021:\020%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); | |
613 GFX_write_string(&FontT54,&t7surfaceR,text,3); | |
614 | |
615 if(settingsGetPointer()->date_format == DDMMYY) | |
616 { | |
617 day = 0; | |
618 month = 1; | |
619 year = 2; | |
620 } | |
621 else | |
622 if(settingsGetPointer()->date_format == MMDDYY) | |
623 { | |
624 day = 1; | |
625 month = 0; | |
626 year = 2; | |
627 } | |
628 else | |
629 { | |
630 day = 2; | |
631 month = 1; | |
632 year = 0; | |
633 } | |
634 date[day] = Sdate.Date; | |
635 date[month] = Sdate.Month; | |
636 date[year] = Sdate.Year; | |
637 | |
638 if((Stime.Seconds % 2) || (dateNotSet == 0)) | |
639 snprintf(text,255,"\001%02d.%02d.%02d",date[0],date[1],date[2]); | |
640 else | |
641 snprintf(text,255,"\001\021%02d.%02d.%02d",date[0],date[1],date[2]); | |
642 | |
643 GFX_write_string(&FontT54,&t7surfaceR,text,5); | |
644 | |
645 if(!DataEX_was_power_on() && !errorsInSettings) | |
646 { | |
647 text[0] = '\001'; | |
648 text[1] = '\004'; | |
649 text[2] = TXT_2BYTE; | |
650 text[3] = TXT2BYTE_Sunday; | |
651 text[4] = 0; | |
652 if(Sdate.WeekDay != RTC_WEEKDAY_SUNDAY) | |
653 text[3] += Sdate.WeekDay; | |
654 | |
655 if(!(Stime.Seconds % 2) && (dateNotSet == 1)) | |
656 text[1] = '\021'; | |
657 | |
658 GFX_write_string(&FontT24,&t7surfaceR,text,4); | |
659 } | |
660 | |
661 /* DEBUG uTick Pressure and Compass */ | |
662 /* | |
663 snprintf(text,255,"\001%u",stateRealGetPointer()->pressure_uTick_new - stateRealGetPointer()->pressure_uTick_old); | |
664 GFX_write_string(&FontT42,&t7surfaceR,text,1); | |
665 snprintf(text,255,"\001%u",HAL_GetTick() - stateRealGetPointer()->pressure_uTick_local_new); | |
666 GFX_write_string(&FontT42,&t7surfaceR,text,2); | |
667 | |
668 snprintf(text,255,"\001%u",stateRealGetPointer()->compass_uTick_new - stateRealGetPointer()->compass_uTick_old); | |
669 GFX_write_string(&FontT42,&t7surfaceR,text,6); | |
670 snprintf(text,255,"\001%u",HAL_GetTick() - stateRealGetPointer()->compass_uTick_local_new); | |
671 GFX_write_string(&FontT42,&t7surfaceR,text,7); | |
672 | |
673 static uint32_t bildschirmRefresh = 0; | |
674 snprintf(text,255,"\001%u",HAL_GetTick() - bildschirmRefresh); | |
675 GFX_write_string(&FontT42,&t7surfaceR,text,8); | |
676 bildschirmRefresh = HAL_GetTick(); | |
677 | |
678 static uint16_t bildschirmRefreshCount = 1; | |
679 if(bildschirmRefreshCount>10) | |
680 bildschirmRefreshCount = 1; | |
681 for(int i=0;i<bildschirmRefreshCount;i++) | |
682 text[i] = '.'; | |
683 text[bildschirmRefreshCount++] = 0; | |
684 GFX_write_string(&FontT42,&t7surfaceR,text,4); | |
685 */ | |
686 | |
687 /* noFlyTime or DesaturationTime */ | |
688 | |
689 if((!display_count_high_time) && (stateUsed->lifeData.no_fly_time_minutes)) | |
690 { | |
691 SSurfacetime NoFlyTime = {0,0,0,0}; | |
692 t7_fill_surfacetime_helper(&NoFlyTime,stateUsed->lifeData.no_fly_time_minutes, 0); | |
693 | |
694 if(NoFlyTime.Days) | |
695 { | |
696 snprintf(text,30,"\001%02d\016\016d\017 %02d\016\016h\017",NoFlyTime.Days, NoFlyTime.Hours); | |
697 } | |
698 else | |
699 { | |
700 snprintf(text,20,"\001%02d:%02d",NoFlyTime.Hours, NoFlyTime.Minutes); | |
701 } | |
702 | |
703 GFX_write_string(&FontT54,&t7surfaceR,text,7); | |
704 | |
705 text[0] = '\001'; | |
706 text[1] = '\022'; | |
707 text[2] = '\016'; | |
708 text[3] = '\016'; | |
709 text[4] = TXT_2BYTE; | |
710 text[5] = TXT2BYTE_noFly; | |
711 text[6] = 0; | |
712 GFX_write_string(&FontT48,&t7surfaceR,text,6); | |
713 } | |
714 else | |
715 if(stateUsed->lifeData.desaturation_time_minutes) | |
716 { | |
717 SSurfacetime DesatTime = {0,0,0,0}; | |
718 t7_fill_surfacetime_helper(&DesatTime,stateUsed->lifeData.desaturation_time_minutes, 0); | |
719 | |
720 if(DesatTime.Days) | |
721 { | |
722 snprintf(text,30,"\001%02d\016\016d\017 %02d\016\016h\017",DesatTime.Days, DesatTime.Hours); | |
723 } | |
724 else | |
725 { | |
726 snprintf(text,20,"\001%02d:%02d",DesatTime.Hours, DesatTime.Minutes); | |
727 } | |
728 GFX_write_string(&FontT54,&t7surfaceR,text,7); | |
729 | |
730 text[0] = '\001'; | |
731 text[1] = '\022'; | |
732 text[2] = '\016'; | |
733 text[3] = '\016'; | |
734 text[4] = TXT_2BYTE; | |
735 text[5] = TXT2BYTE_Desaturation; | |
736 text[6] = 0; | |
737 GFX_write_string(&FontT48,&t7surfaceR,text,6); | |
738 } | |
739 | |
740 /* Time since last dive */ | |
741 if(stateUsed->lifeData.surface_time_seconds) | |
742 { | |
743 SSurfacetime SurfTime = {0,0,0,0}; | |
744 t7_fill_surfacetime_helper(&SurfTime, 0, stateUsed->lifeData.surface_time_seconds); | |
745 | |
746 if(SurfTime.Days == 0) | |
747 { | |
748 snprintf(text,20,"\001\022%02d:%02d",SurfTime.Hours, SurfTime.Minutes); | |
749 } | |
750 else | |
751 { | |
752 snprintf(text,30,"\001\022%02d\016\016d\017 %02d\016\016h\017",SurfTime.Days, SurfTime.Hours); | |
753 } | |
754 | |
755 GFX_write_string(&FontT54,&t7surfaceR,text,2); | |
756 | |
757 | |
758 text[0] = '\001'; | |
759 text[1] = '\022'; | |
760 text[2] = '\016'; | |
761 text[3] = '\016'; | |
762 text[4] = TXT_2BYTE; | |
763 text[5] = TXT2BYTE_TimeSinceLastDive; | |
764 text[6] = 0; | |
765 GFX_write_string(&FontT48,&t7surfaceR,text,1); | |
766 } | |
767 | |
768 /* beta version */ | |
769 if( firmwareDataGetPointer()->versionBeta ) | |
770 { | |
771 snprintf(text,255,"\025 BETA"); | |
772 GFX_write_string(&FontT48,&t7surfaceL,text,2); | |
773 } | |
774 | |
775 /* surface pressure and temperature */ | |
776 if(stateUsed->sensorErrorsRTE == 0) | |
777 { | |
778 snprintf(text,30,"%01.0f\022\016\016 mbar", stateUsed->lifeData.pressure_surface_bar * 1000.0f); | |
779 GFX_write_string(&FontT48,&t7surfaceL,text,3); | |
780 | |
781 if(settingsGetPointer()->nonMetricalSystem) | |
782 snprintf(text,40,"%01.0f\140\022\016\016 fahrenheit",unit_temperature_float(stateUsed->lifeData.temperature_celsius)); | |
783 else | |
784 snprintf(text,30,"%01.0f\140\022\016\016 celsius",stateUsed->lifeData.temperature_celsius); | |
785 GFX_write_string(&FontT48,&t7surfaceL,text,4); | |
786 } | |
787 else | |
788 { | |
789 snprintf(text,30,"ERR\022\016\016 mbar"); | |
790 GFX_write_string(&FontT48,&t7surfaceL,text,3); | |
791 | |
792 if(settingsGetPointer()->nonMetricalSystem) | |
793 snprintf(text,40,"ERR\022\016\016 fahrenheit"); | |
794 else | |
795 snprintf(text,30,"ERR\022\016\016 celsius"); | |
796 GFX_write_string(&FontT48,&t7surfaceL,text,4); | |
797 } | |
798 | |
799 | |
800 /* gas mix and selection */ | |
801 if((stateUsed->diveSettings.diveMode == DIVEMODE_Gauge) || (stateUsed->diveSettings.diveMode == DIVEMODE_Apnea)) | |
802 { | |
803 if(stateUsed->diveSettings.diveMode == DIVEMODE_Gauge) | |
804 text[0] = TXT_Gauge; | |
805 else | |
806 text[0] = TXT_Apnoe; | |
807 | |
808 text[1] = 0; | |
809 GFX_write_string(&FontT48,&t7surfaceL,text,6); | |
810 } | |
811 else | |
812 { | |
813 text[0] = '\021'; | |
814 text[1] = '1'; | |
815 text[2] = '\177'; | |
816 text[3] = '\177'; | |
817 text[4] = 10; | |
818 text[5] = '\021'; | |
819 text[6] = '2'; | |
820 text[7] = '\177'; | |
821 text[8] = '\177'; | |
822 text[9] = 10; | |
823 text[10] = '\021'; | |
824 text[11] = '3'; | |
825 text[12] = '\177'; | |
826 text[13] = '\177'; | |
827 text[14] = 10; | |
828 text[15] = '\021'; | |
829 text[16] = '4'; | |
830 text[17] = '\177'; | |
831 text[18] = '\177'; | |
832 text[19] = 10; | |
833 text[20] = '\021'; | |
834 text[21] = '5'; | |
835 text[22] = 0; | |
836 | |
837 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) | |
838 gasOffset = NUM_OFFSET_DILUENT; | |
839 else | |
840 gasOffset = 0; | |
841 for(int i=1;i<=5;i++) | |
842 { | |
843 if(stateUsed->diveSettings.gas[i+gasOffset].note.ub.active) | |
844 text[(i-1)*5] -= 1; | |
845 } | |
846 GFX_write_string(&FontT48,&t7surfaceL,text,6); | |
847 | |
848 | |
849 oxygen_percentage = 100; | |
850 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage; | |
851 oxygen_percentage -= stateUsed->lifeData.actualGas.helium_percentage; | |
852 | |
853 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[0]); | |
854 GFX_write_string(&FontT48,&t7surfaceL,text,7); | |
855 | |
856 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; | |
857 /* | |
858 bottleFirstGas_bar = stateUsed->lifeData.bottle_bar[actualGasID]; | |
859 if(bottleFirstGas_bar) | |
860 { | |
861 snprintf(text,255,"%3u\022\016\016 bar",bottleFirstGas_bar); | |
862 GFX_write_string(&FontT48,&t7surfaceL,text,8); | |
863 } | |
864 */ | |
865 // after gas name :-) | |
866 if(actualGasID > gasOffset) // security | |
867 { | |
868 start.y = t7surfaceL.WindowY0 + (3 * t7surfaceL.WindowLineSpacing); | |
869 start.x = t7surfaceL.WindowX0 + ((stateUsed->lifeData.actualGas.GasIdInSettings - gasOffset - 1) * 35); | |
870 stop.x = start.x + 25; | |
871 stop.y = start.y + 52; | |
872 GFX_draw_box2(&t7screen, start, stop, CLUT_Font020, 1); | |
873 } | |
874 } | |
875 | |
876 /* dive mode */ | |
877 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) | |
878 GFX_write_string(&FontT24,&t7c1,"\f\002" "CCR",0); | |
879 else | |
880 GFX_write_string(&FontT24,&t7c1,"\f\002" "OC",0); | |
881 // GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80" "CCR",0); | |
882 | |
883 /*battery */ | |
884 | |
885 text[0] = '3'; | |
886 text[1] = '1'; | |
887 text[2] = '1'; | |
888 text[3] = '1'; | |
889 text[4] = '1'; | |
890 text[5] = '1'; | |
891 text[6] = '1'; | |
892 text[7] = '1'; | |
893 text[8] = '1'; | |
894 text[9] = '1'; | |
895 text[10] = '1'; | |
896 text[11] = '0'; | |
897 text[12] = 0; | |
898 | |
899 for(int i=1;i<=10;i++) | |
900 { | |
901 if( stateUsed->lifeData.battery_charge > (9 * i)) | |
902 text[i] += 1; | |
903 } | |
904 | |
905 if(stateUsed->chargeStatus == CHARGER_off) | |
906 { | |
907 if(stateUsed->warnings.lowBattery) | |
908 { | |
909 if(warning_count_high_time) | |
910 { | |
911 for(int i=1;i<=10;i++) | |
912 text[i] = '1'; | |
913 } | |
914 else | |
915 { | |
916 text[1] = '2'; | |
917 } | |
918 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_WarningRed); | |
919 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) | |
920 { | |
921 snprintf(text,16,"\004\025\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); | |
922 if(warning_count_high_time) | |
923 text[0] = '\a'; | |
924 GFX_write_string(&FontT24,&t7batt,text,0); | |
925 } | |
926 else | |
927 { | |
928 snprintf(text,6,"\f%.1fV",stateUsed->lifeData.battery_voltage); | |
929 GFX_write_string(&FontT24,&t7voltage,text,0); | |
930 } | |
931 } | |
932 else | |
933 { | |
934 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryStandard); | |
935 | |
936 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) | |
937 { | |
938 snprintf(text,16,"\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); | |
939 GFX_write_string(&FontT24,&t7batt,text,0); | |
940 } | |
941 else | |
942 { | |
943 snprintf(text,6,"\f%.1fV",stateUsed->lifeData.battery_voltage); | |
944 GFX_write_string(&FontT24,&t7voltage,text,0); | |
945 } | |
946 } | |
947 } | |
948 else | |
949 { | |
950 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryCharging); | |
951 | |
952 switch(stateUsed->chargeStatus) | |
953 { | |
954 case CHARGER_running: | |
955 default: | |
956 color = CLUT_BatteryStandard; | |
957 break; | |
958 case CHARGER_complete: | |
959 color = CLUT_BatteryCharging; | |
960 break; | |
961 case CHARGER_lostConnection: | |
962 color = CLUT_BatteryProblem; | |
963 break; | |
964 } | |
965 text[0] = '4'; | |
966 text[1] = 0; | |
967 GFX_write_string_color(&Batt24,&t7charge,text,0,color); | |
968 } | |
969 | |
970 | |
971 | |
972 customview_warnings = t7_test_customview_warnings_surface_mode(); | |
973 if(customview_warnings && warning_count_high_time) | |
974 t7_show_customview_warnings_surface_mode(); | |
975 else | |
976 t7_refresh_customview(); | |
977 draw_frame(0,0, CLUT_pluginboxSurface, CLUT_Font020); | |
978 } | |
979 | |
980 | |
981 void t7_refresh_surface_debugmode_wireless_info(void) | |
982 { | |
983 char text[400]; | |
984 uint8_t colorDataLost = 0; | |
985 int txtPointer = 0; | |
986 uint8_t numberOfBytes = 0; | |
987 | |
988 GFX_DrawCfgWindow textWindow = | |
989 { | |
990 .Image = &t7screen, | |
991 .WindowNumberOfTextLines = 5, | |
992 .WindowLineSpacing = 70, | |
993 .WindowTab = 220, | |
994 .WindowX0 = 10, | |
995 .WindowX1 = 790, | |
996 .WindowY0 = 10, | |
997 .WindowY1 = 380 | |
998 }; | |
999 | |
1000 Gfx_write_label_var(&t7screen, 10,600, 10,&FontT42,CLUT_DiveMainLabel,"Wireless Data"); | |
1001 | |
1002 if(stateUsed->data_old__lost_connection_to_slave) | |
1003 { | |
1004 Gfx_write_label_var(&t7screen, 600,800,10,&FontT42,CLUT_Font020,"CPU2?"); | |
1005 colorDataLost = 1; | |
1006 } | |
1007 | |
1008 txtPointer = 0; | |
1009 for(int i=0;i<4;i++) | |
1010 { | |
1011 if((!stateUsed->lifeData.wireless_data[i].ageInMilliSeconds) || colorDataLost) | |
1012 text[txtPointer++] = '\021'; | |
1013 | |
1014 numberOfBytes = stateUsed->lifeData.wireless_data[i].numberOfBytes; | |
1015 if((numberOfBytes > 0) && (numberOfBytes <= 10)) | |
1016 { | |
1017 txtPointer += snprintf(&text[txtPointer],20,"%02u s %02u\t" | |
1018 ,(stateUsed->lifeData.wireless_data[i].ageInMilliSeconds)/1000 | |
1019 ,stateUsed->lifeData.wireless_data[i].status | |
1020 ); | |
1021 if(numberOfBytes > 8) ///< lifeData.wireless_data[i].data[j] has only size of 8 | |
1022 numberOfBytes = 8; | |
1023 for(int j=0;j<numberOfBytes;j++) | |
1024 { | |
1025 txtPointer += snprintf(&text[txtPointer],4," %02X" | |
1026 ,stateUsed->lifeData.wireless_data[i].data[j] | |
1027 ); | |
1028 } | |
1029 } | |
1030 text[txtPointer++] = '\n'; | |
1031 text[txtPointer++] = '\r'; | |
1032 text[txtPointer++] = '\020'; | |
1033 text[txtPointer] = 0; | |
1034 } | |
1035 GFX_write_string(&FontT48,&textWindow,text,1); | |
1036 | |
1037 } | |
1038 | |
1039 | |
1040 void t7_refresh_surface_debugmode(void) | |
1041 { | |
1042 if(selection_customview%2 == 1) | |
1043 { | |
1044 t7_refresh_surface_debugmode_wireless_info(); | |
1045 return; | |
1046 } | |
1047 | |
1048 // could be warning, now just to set RTE variables | |
1049 DataEX_check_RTE_version__needs_update(); | |
1050 | |
1051 | |
1052 char TextL1[4*TEXTSIZE]; | |
1053 uint32_t color; | |
1054 // uint8_t gasIdFirst; | |
1055 SSettings* pSettings = settingsGetPointer(); | |
1056 extern SDataExchangeSlaveToMaster dataIn; | |
1057 | |
1058 SWindowGimpStyle windowGimp; | |
1059 | |
1060 RTC_DateTypeDef Sdate; | |
1061 RTC_TimeTypeDef Stime; | |
1062 | |
1063 translateDate(stateUsed->lifeData.dateBinaryFormat, &Sdate); | |
1064 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime); | |
1065 | |
1066 | |
1067 if(stateUsed->data_old__lost_connection_to_slave) | |
1068 { | |
1069 Gfx_write_label_var(&t7screen, 500,800, 0,&FontT42,CLUT_DiveMainLabel,"old"); | |
1070 snprintf(TextL1,TEXTSIZE,"%X %X %X %X",dataIn.header.checkCode[0],dataIn.header.checkCode[1],dataIn.header.checkCode[2],dataIn.header.checkCode[3]); | |
1071 Gfx_write_label_var(&t7screen, 500,800, 45,&FontT48,CLUT_Font020,TextL1); | |
1072 } | |
1073 else | |
1074 if(DataEX_lost_connection_count()) | |
1075 { | |
1076 snprintf(TextL1,TEXTSIZE,"\002%i",DataEX_lost_connection_count()); | |
1077 Gfx_write_label_var(&t7screen, 600,800, 45,&FontT48,CLUT_Font020,TextL1); | |
1078 } | |
1079 | |
1080 snprintf(TextL1,TEXTSIZE,"\002%i",blockedFramesCount()); | |
1081 Gfx_write_label_var(&t7screen, 600,800, 0,&FontT48,CLUT_Font020,TextL1); | |
1082 | |
1083 if(stateUsed->lifeData.compass_DX_f | stateUsed->lifeData.compass_DY_f | stateUsed->lifeData.compass_DZ_f) | |
1084 { | |
1085 snprintf(TextL1,TEXTSIZE,"X %i",stateUsed->lifeData.compass_DX_f); | |
1086 Gfx_write_label_var(&t7screen, 0,400, 45,&FontT48,CLUT_Font020,TextL1); | |
1087 snprintf(TextL1,TEXTSIZE,"Y %i",stateUsed->lifeData.compass_DY_f); | |
1088 Gfx_write_label_var(&t7screen, 0,400,145,&FontT48,CLUT_Font020,TextL1); | |
1089 snprintf(TextL1,TEXTSIZE,"Z %i",stateUsed->lifeData.compass_DZ_f); | |
1090 Gfx_write_label_var(&t7screen, 0,400,255,&FontT48,CLUT_Font020,TextL1); | |
1091 return; | |
1092 } | |
1093 snprintf(TextL1,TEXTSIZE,"%01.0f mbar",stateUsed->lifeData.pressure_ambient_bar * 1000.0f); | |
1094 Gfx_write_label_var(&t7screen, 0,400, 0,&FontT42,CLUT_DiveMainLabel,"Ambient Pressure"); | |
1095 Gfx_write_label_var(&t7screen, 0,400, 45,&FontT48,CLUT_Font020,TextL1); | |
1096 | |
1097 snprintf(TextL1,TEXTSIZE,"%01.2f C",stateUsed->lifeData.temperature_celsius); | |
1098 Gfx_write_label_var(&t7screen, 0,400,100,&FontT42,CLUT_DiveMainLabel,"Temperature"); | |
1099 Gfx_write_label_var(&t7screen, 0,400,145,&FontT48,CLUT_Font020,TextL1); | |
1100 | |
1101 snprintf(TextL1,TEXTSIZE,"%03.0f %03.0f %03.0f",stateUsed->lifeData.compass_heading,stateUsed->lifeData.compass_roll,stateUsed->lifeData.compass_pitch); | |
1102 Gfx_write_label_var(&t7screen, 0,400,200,&FontT42,CLUT_DiveMainLabel,"Heading Roll Pitch"); | |
1103 Gfx_write_label_var(&t7screen, 0,400,255,&FontT48,CLUT_Font020,TextL1); | |
1104 | |
1105 snprintf(TextL1,TEXTSIZE,"%01.0f mbar",stateUsed->lifeData.pressure_surface_bar * 1000.0f); | |
1106 Gfx_write_label_var(&t7screen, 0,400,310,&FontT42,CLUT_DiveMainLabel,"Surface Pressure"); | |
1107 Gfx_write_label_var(&t7screen, 0,400,355,&FontT48,CLUT_Font020,TextL1); | |
1108 | |
1109 // gasIdFirst = stateUsed->lifeData.actualGas.GasIdInSettings; | |
1110 snprintf(TextL1,TEXTSIZE,"%u.%u",dataIn.RTE_VERSION_high,dataIn.RTE_VERSION_low); | |
1111 Gfx_write_label_var(&t7screen, 320,500,100,&FontT42,CLUT_DiveMainLabel,"RTE"); | |
1112 Gfx_write_label_var(&t7screen, 320,500,145,&FontT48,CLUT_Font020,TextL1); | |
1113 | |
1114 Gfx_write_label_var(&t7screen, 500,800,100,&FontT42,CLUT_DiveMainLabel,"Battery"); | |
1115 snprintf(TextL1,TEXTSIZE,"%01.4f V",stateUsed->lifeData.battery_voltage); | |
1116 Gfx_write_label_var(&t7screen, 500,800,145,&FontT48,CLUT_Font020,TextL1); | |
1117 snprintf(TextL1,TEXTSIZE,"%03.1f %%",stateUsed->lifeData.battery_charge); | |
1118 Gfx_write_label_var(&t7screen, 500,800,200,&FontT48,CLUT_Font020,TextL1); | |
1119 if(stateUsed->chargeStatus != CHARGER_off) | |
1120 { | |
1121 switch(stateUsed->chargeStatus) | |
1122 { | |
1123 case CHARGER_running: | |
1124 default: | |
1125 color = CLUT_BatteryStandard; | |
1126 break; | |
1127 case CHARGER_complete: | |
1128 color = CLUT_BatteryCharging; | |
1129 break; | |
1130 case CHARGER_lostConnection: | |
1131 color = CLUT_BatteryProblem; | |
1132 break; | |
1133 } | |
1134 TextL1[0] = '4'; | |
1135 TextL1[1] = 0; | |
1136 Gfx_write_label_var(&t7screen, 660,800,200,&Batt24,color,TextL1); | |
1137 } | |
1138 | |
1139 extern uint32_t base_tempLightLevel; | |
1140 | |
1141 snprintf(TextL1,TEXTSIZE,"# %u (%u)",stateUsed->lifeData.ambient_light_level, base_tempLightLevel); | |
1142 Gfx_write_label_var(&t7screen, 401,600,310,&FontT42,CLUT_DiveMainLabel,"Light"); | |
1143 Gfx_write_label_var(&t7screen, 401,800,355,&FontT48,CLUT_Font020,TextL1); | |
1144 | |
1145 // snprintf(TextL1,TEXTSIZE,"# %u",stateUsed->lifeData.ambient_light_level); | |
1146 // Gfx_write_label_var(&t7screen, 601,800,310,&FontT42,CLUT_DiveMainLabel,"Light"); | |
1147 // Gfx_write_label_var(&t7screen, 601,800,355,&FontT48,CLUT_Font020,TextL1); | |
1148 | |
1149 | |
1150 | |
1151 if(Sdate.Year < 15) | |
1152 { | |
1153 if(warning_count_high_time) | |
1154 { | |
1155 snprintf(TextL1,4*TEXTSIZE,"\017 %02d-%02d-%02d %02d:%02d:%02d", Sdate.Date, Sdate.Month, 2000 + Sdate.Year,Stime.Hours, Stime.Minutes, Stime.Seconds); | |
1156 Gfx_write_label_var(&t7screen, 0,800,420,&FontT48,CLUT_Font020,TextL1); | |
1157 } | |
1158 } | |
1159 else | |
1160 { | |
1161 if(pSettings->customtext[0]) | |
1162 { | |
1163 if(pSettings->customtext[59]) | |
1164 pSettings->customtext[59] = 0; | |
1165 Gfx_write_label_var(&t7screen, 0,400,420,&FontT24,CLUT_Font020,pSettings->customtext); | |
1166 } | |
1167 else | |
1168 { | |
1169 snprintf(TextL1,4*TEXTSIZE,"\017 %02d-%02d-%02d %02d:%02d:%02d Dives: %u", Sdate.Date, Sdate.Month, 2000 + Sdate.Year,Stime.Hours, Stime.Minutes, Stime.Seconds,pSettings->totalDiveCounter ); | |
1170 Gfx_write_label_var(&t7screen, 0,800,420,&FontT48,CLUT_Font020,TextL1); | |
1171 } | |
1172 } | |
1173 | |
1174 windowGimp.left = 400; | |
1175 windowGimp.top = 0; | |
1176 GFX_draw_image_monochrome(&t7screen, windowGimp, &ImgOSTC, 0); | |
1177 } | |
1178 | |
1179 /* CUSTOMVIEW | |
1180 * in the middle of the screen | |
1181 */ | |
1182 | |
1183 uint8_t t7_test_customview_warnings(void) | |
1184 { | |
1185 uint8_t count = 0; | |
1186 | |
1187 count = 0; | |
1188 count += stateUsed->warnings.decoMissed; | |
1189 count += stateUsed->warnings.ppO2Low; | |
1190 count += stateUsed->warnings.ppO2High; | |
1191 //count += stateUsed->warnings.lowBattery; | |
1192 count += stateUsed->warnings.sensorLinkLost; | |
1193 count += stateUsed->warnings.fallback; | |
1194 return count; | |
1195 } | |
1196 | |
1197 | |
1198 uint8_t t7_test_customview_warnings_surface_mode(void) | |
1199 { | |
1200 uint8_t count = 0; | |
1201 count = 0; | |
1202 count += stateUsed->cnsHigh_at_the_end_of_dive; | |
1203 count += stateUsed->decoMissed_at_the_end_of_dive; | |
1204 return count; | |
1205 } | |
1206 | |
1207 | |
1208 void t7_show_customview_warnings_surface_mode(void) | |
1209 { | |
1210 char text[256]; | |
1211 uint8_t textpointer, lineFree; | |
1212 | |
1213 text[0] = '\025'; | |
1214 text[1] = '\f'; | |
1215 text[2] = '\001'; | |
1216 text[3] = TXT_Warning; | |
1217 text[4] = 0; | |
1218 GFX_write_string(&FontT42,&t7cH,text,0); | |
1219 | |
1220 textpointer = 0; | |
1221 lineFree = 5; | |
1222 | |
1223 if(stateUsed->decoMissed_at_the_end_of_dive) | |
1224 { | |
1225 text[textpointer++] = TXT_2BYTE; | |
1226 text[textpointer++] = TXT2BYTE_WarnDecoMissed; | |
1227 text[textpointer++] = '\n'; | |
1228 text[textpointer++] = '\r'; | |
1229 text[textpointer] = 0; | |
1230 lineFree--; | |
1231 } | |
1232 | |
1233 if(stateUsed->cnsHigh_at_the_end_of_dive) | |
1234 { | |
1235 text[textpointer++] = TXT_2BYTE; | |
1236 text[textpointer++] = TXT2BYTE_WarnCnsHigh; | |
1237 text[textpointer++] = '\n'; | |
1238 text[textpointer++] = '\r'; | |
1239 text[textpointer] = 0; | |
1240 lineFree--; | |
1241 } | |
1242 if(textpointer != 0) | |
1243 GFX_write_string(&FontT48,&t7cW,text,1); | |
1244 } | |
1245 | |
1246 | |
1247 void t7_show_customview_warnings(void) | |
1248 { | |
1249 char text[256]; | |
1250 uint8_t textpointer, lineFree; | |
1251 | |
1252 text[0] = '\025'; | |
1253 text[1] = '\f'; | |
1254 text[2] = '\001'; | |
1255 text[3] = TXT_Warning; | |
1256 text[4] = 0; | |
1257 GFX_write_string(&FontT42,&t7cH,text,0); | |
1258 | |
1259 textpointer = 0; | |
1260 lineFree = 5; | |
1261 | |
1262 if(lineFree && stateUsed->warnings.decoMissed) | |
1263 { | |
1264 text[textpointer++] = TXT_2BYTE; | |
1265 text[textpointer++] = TXT2BYTE_WarnDecoMissed; | |
1266 text[textpointer++] = '\n'; | |
1267 text[textpointer++] = '\r'; | |
1268 text[textpointer] = 0; | |
1269 lineFree--; | |
1270 } | |
1271 | |
1272 if(lineFree && stateUsed->warnings.fallback) | |
1273 { | |
1274 text[textpointer++] = TXT_2BYTE; | |
1275 text[textpointer++] = TXT2BYTE_WarnFallback; | |
1276 text[textpointer++] = '\n'; | |
1277 text[textpointer++] = '\r'; | |
1278 text[textpointer] = 0; | |
1279 lineFree--; | |
1280 } | |
1281 | |
1282 if(lineFree && stateUsed->warnings.ppO2Low) | |
1283 { | |
1284 text[textpointer++] = TXT_2BYTE; | |
1285 text[textpointer++] = TXT2BYTE_WarnPPO2Low; | |
1286 text[textpointer++] = '\n'; | |
1287 text[textpointer++] = '\r'; | |
1288 text[textpointer] = 0; | |
1289 lineFree--; | |
1290 } | |
1291 | |
1292 if(lineFree && stateUsed->warnings.ppO2High) | |
1293 { | |
1294 text[textpointer++] = TXT_2BYTE; | |
1295 text[textpointer++] = TXT2BYTE_WarnPPO2High; | |
1296 text[textpointer++] = '\n'; | |
1297 text[textpointer++] = '\r'; | |
1298 text[textpointer] = 0; | |
1299 lineFree--; | |
1300 } | |
1301 | |
1302 if(lineFree && stateUsed->warnings.sensorLinkLost) | |
1303 { | |
1304 text[textpointer++] = TXT_2BYTE; | |
1305 text[textpointer++] = TXT2BYTE_WarnSensorLinkLost; | |
1306 text[textpointer++] = '\n'; | |
1307 text[textpointer++] = '\r'; | |
1308 text[textpointer] = 0; | |
1309 lineFree--; | |
1310 } | |
1311 /* | |
1312 if(lineFree && stateUsed->warnings.lowBattery) | |
1313 { | |
1314 text[textpointer++] = TXT_2BYTE; | |
1315 text[textpointer++] = TXT2BYTE_WarnBatteryLow; | |
1316 text[textpointer++] = '\n'; | |
1317 text[textpointer++] = '\r'; | |
1318 text[textpointer] = 0; | |
1319 lineFree--; | |
1320 } | |
1321 */ | |
1322 GFX_write_string(&FontT48,&t7cW,text,1); | |
1323 } | |
1324 | |
1325 | |
1326 void t7_set_customview_to_primary(void) | |
1327 { | |
1328 if(stateUsed->mode == MODE_DIVE) | |
1329 selection_customview = settingsGetPointer()->tX_customViewPrimary; | |
1330 } | |
1331 | |
1332 | |
1333 // for CVIEW_END is none_or_debug | |
1334 void t7_change_customview(void) | |
1335 { | |
1336 const uint8_t *pViews; | |
1337 _Bool cv_disabled = 0; | |
1338 | |
1339 if(stateUsed->mode == MODE_DIVE) | |
1340 pViews = customviewsDive; | |
1341 else | |
1342 pViews = customviewsSurface; | |
1343 | |
1344 while((*pViews != CVIEW_END) && (*pViews != selection_customview)) | |
1345 {pViews++;} | |
1346 | |
1347 if(*pViews < CVIEW_END) | |
1348 pViews++; | |
1349 | |
1350 | |
1351 if(*pViews == CVIEW_END) | |
1352 { | |
1353 if(stateUsed->mode == MODE_DIVE) | |
1354 pViews = customviewsDive; | |
1355 else | |
1356 pViews = customviewsSurface; | |
1357 } | |
1358 | |
1359 if(stateUsed->mode == MODE_DIVE) | |
1360 { | |
1361 do | |
1362 { | |
1363 cv_disabled = 0; | |
1364 for(int i=0;i<6;i++) | |
1365 { | |
1366 if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(cv_configuration, cv_changelist[i])) | |
1367 { | |
1368 cv_disabled = 1; | |
1369 break; | |
1370 } | |
1371 } | |
1372 if(cv_disabled) | |
1373 { | |
1374 if(*pViews < CVIEW_END) | |
1375 { | |
1376 pViews++; | |
1377 } | |
1378 else | |
1379 { | |
1380 pViews = customviewsDive; | |
1381 } | |
1382 } | |
1383 } while(cv_disabled); | |
1384 } | |
1385 | |
1386 | |
1387 // if((*pViews == CVIEW_Scooter) && (getLicence() != LICENCEBONEX)) | |
1388 // pViews++; | |
1389 | |
1390 selection_customview = *pViews; | |
1391 } | |
1392 | |
1393 | |
1394 uint8_t t7_get_length_of_customtext(void) | |
1395 { | |
1396 uint8_t i = 0; | |
1397 settingsGetPointer()->customtext[60-1] = 0; | |
1398 while(settingsGetPointer()->customtext[i] > 0) | |
1399 i++; | |
1400 return i; | |
1401 } | |
1402 | |
1403 | |
1404 void t7_refresh_customview(void) | |
1405 { | |
1406 if((selection_customview == CVIEW_Scooter) && (getLicence() != LICENCEBONEX)) | |
1407 t7_change_customview(); | |
1408 if((selection_customview == CVIEW_Scooter) && (!DataEX_scooterFoundAndValidLicence() && (stateRealGetPointer()->mode == MODE_DIVE))) | |
1409 t7_change_customview(); | |
1410 if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) | |
1411 t7_change_customview(); | |
1412 if((selection_customview == CVIEW_sensors_mV) &&(stateUsed->diveSettings.ccrOption == 0)) | |
1413 t7_change_customview(); | |
1414 if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) | |
1415 t7_change_customview(); | |
1416 | |
1417 char text[256]; | |
1418 uint16_t textpointer = 0; | |
1419 int16_t start; | |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
1420 uint8_t lineCountCustomtext = 0; |
38 | 1421 int16_t shiftWindowY0; |
1422 RTC_DateTypeDef Sdate; | |
1423 RTC_TimeTypeDef Stime; | |
1424 float fPpO2limitHigh, fPpO2limitLow, fPpO2ofGasAtThisDepth; // CVIEW_Gaslist | |
1425 const SGasLine * pGasLine; // CVIEW_Gaslist | |
1426 uint8_t oxygen, helium; // CVIEW_Gaslist | |
1427 float depth, surface, fraction_nitrogen, fraction_helium, ead, end; // CVIEW_EADTime | |
1428 | |
1429 switch(selection_customview) | |
1430 { | |
1431 case CVIEW_noneOrDebug: | |
1432 if(settingsGetPointer()->showDebugInfo) | |
1433 { | |
1434 // header | |
1435 strcpy(text,"\032\f\001Debug"); | |
1436 GFX_write_string(&FontT42,&t7cH,text,0); | |
1437 // content | |
1438 t7_debug(); | |
1439 } | |
1440 break; | |
1441 | |
1442 case CVIEW_SummaryOfLeftCorner: | |
1443 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Summary); | |
1444 GFX_write_string(&FontT42,&t7cH,text,0); | |
1445 // content | |
1446 t7_SummaryOfLeftCorner(); | |
1447 break; | |
1448 | |
1449 case CVIEW_CompassDebug: | |
1450 snprintf(text,100,"\032\f\001Compass raw"); | |
1451 GFX_write_string(&FontT42,&t7cH,text,0); | |
1452 /* | |
1453 pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading; | |
1454 pStateReal->lifeData.compass_roll = dataIn.data[dataIn.boolCompassData].compass_roll; | |
1455 pStateReal->lifeData.compass_pitch = dataIn.data[dataIn.boolCompassData].compass_pitch; | |
1456 | |
1457 pStateReal->lifeData.compass_DX_f = dataIn.data[dataIn.boolCompassData].compass_DX_f; | |
1458 pStateReal->lifeData.compass_DY_f = dataIn.data[dataIn.boolCompassData].compass_DY_f; | |
1459 pStateReal->lifeData.compass_DZ_f = dataIn.data[dataIn.boolCompassData].compass_DZ_f; | |
1460 */ | |
1461 snprintf(text,255,"%1.1f\n\r%1.1f\n\r%1.1f\n\r%i\n\r%i\n\r%i" | |
1462 ,stateUsed->lifeData.compass_heading | |
1463 ,stateUsed->lifeData.compass_roll | |
1464 ,stateUsed->lifeData.compass_pitch | |
1465 ,stateUsed->lifeData.compass_DX_f | |
1466 ,stateUsed->lifeData.compass_DY_f | |
1467 ,stateUsed->lifeData.compass_DZ_f | |
1468 ); | |
1469 | |
1470 t7cY0free.WindowY0 = t7cC.WindowY0 - 10; | |
1471 t7cY0free.WindowLineSpacing = 48; | |
1472 t7cY0free.WindowNumberOfTextLines = 6; | |
1473 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
1474 break; | |
1475 | |
1476 case CVIEW_Hello: | |
1477 t7_logo_OSTC(); | |
1478 t7cC.WindowLineSpacing = 53; | |
1479 t7cC.WindowNumberOfTextLines = 5; | |
1480 shiftWindowY0 = 18; | |
1481 | |
1482 if(updateNecessary)//if(DataEX_check_RTE_version__needs_update() || font_update_required()) | |
1483 { | |
1484 if(warning_count_high_time) | |
1485 { | |
1486 shiftWindowY0 += 20; | |
1487 t7cC.WindowY0 -= shiftWindowY0; | |
1488 textpointer = 0; | |
1489 text[textpointer++] = TXT_2BYTE; | |
1490 text[textpointer++] = TXT2BYTE_PleaseUpdate; | |
1491 text[textpointer++] = '\n'; | |
1492 text[textpointer++] = '\r'; | |
1493 if(DataEX_check_RTE_version__needs_update()) | |
1494 { | |
1495 text[textpointer++] = TXT_2BYTE; | |
1496 text[textpointer++] = TXT2BYTE_RTE; | |
1497 text[textpointer++] = '\n'; | |
1498 text[textpointer++] = '\r'; | |
1499 } | |
1500 if(font_update_required()) | |
1501 { | |
1502 text[textpointer++] = TXT_2BYTE; | |
1503 text[textpointer++] = TXT2BYTE_Fonts; | |
1504 } | |
1505 text[textpointer++] = 0; | |
1506 GFX_write_string_color(&FontT42,&t7cC,text,1, CLUT_WarningRed); | |
1507 t7cC.WindowY0 += shiftWindowY0; | |
1508 } | |
1509 t7cC.WindowNumberOfTextLines = 3; | |
1510 } | |
1511 else // customtext | |
1512 { | |
1513 lineCountCustomtext = t7_customtextPrepare(text); | |
1514 if(lineCountCustomtext <= 2) | |
1515 shiftWindowY0 += 20+26; // nach unten | |
1516 else | |
1517 if(lineCountCustomtext <= 3) | |
1518 shiftWindowY0 += 20; // nach unten | |
1519 t7cC.WindowY0 -= shiftWindowY0; | |
1520 | |
1521 GFX_write_string(&FontT42,&t7cC,text,1); | |
1522 t7cC.WindowNumberOfTextLines = 3; | |
1523 t7cC.WindowY0 += shiftWindowY0; | |
1524 } | |
1525 if(lineCountCustomtext <= 4) | |
1526 { | |
1527 snprintf(text,100,"\001#%0u V%01u.%01u.%01u", | |
1528 settingsGetPointer()->serialLow + (256 * settingsGetPointer()->serialHigh), | |
1529 firmwareDataGetPointer()->versionFirst, | |
1530 firmwareDataGetPointer()->versionSecond, | |
1531 firmwareDataGetPointer()->versionThird | |
1532 ); | |
1533 GFX_write_string(&FontT24,&t7cC,text,0); | |
1534 } | |
1535 break; | |
1536 | |
1537 case CVIEW_Scooter: | |
1538 snprintf(text,100,"\032\f\001Scooter"); | |
1539 GFX_write_string(&FontT42,&t7cH,text,0); | |
1540 t7_scooter(); | |
1541 break; | |
1542 | |
1543 case CVIEW_Gaslist: | |
1544 // a lot of code taken from tMenuGas.c | |
1545 // header | |
1546 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Gaslist); | |
1547 GFX_write_string(&FontT42,&t7cH,text,0); | |
1548 // content | |
1549 textpointer = 0; | |
1550 t7cY0free.WindowY0 = t7cC.WindowY0 - 10; | |
1551 t7cY0free.WindowLineSpacing = 48+9; | |
1552 t7cY0free.WindowNumberOfTextLines = 5; // NUM_GASES == 5 | |
1553 t7cY0free.WindowTab = 420; | |
1554 | |
1555 pGasLine = settingsGetPointer()->gas; | |
1556 if(actualLeftMaxDepth(stateUsed)) | |
1557 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_deco) / 100; | |
1558 else | |
1559 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_std) / 100; | |
1560 fPpO2limitLow = (float)(settingsGetPointer()->ppO2_min) / 100; | |
1561 for(int gasId=1;gasId<=NUM_GASES;gasId++) | |
1562 { | |
1563 textpointer = 0; | |
1564 fPpO2ofGasAtThisDepth = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * pGasLine[gasId].oxygen_percentage / 100; | |
1565 if(pGasLine[gasId].note.ub.active == 0) | |
1566 strcpy(&text[textpointer++],"\021"); | |
1567 else if((fPpO2ofGasAtThisDepth > fPpO2limitHigh) || (fPpO2ofGasAtThisDepth < fPpO2limitLow)) | |
1568 strcpy(&text[textpointer++],"\025"); | |
1569 else | |
1570 strcpy(&text[textpointer++],"\030"); | |
1571 | |
1572 text[textpointer++] = ' '; | |
1573 oxygen = pGasLine[gasId].oxygen_percentage; | |
1574 helium = pGasLine[gasId].helium_percentage; | |
1575 textpointer += write_gas(&text[textpointer], oxygen, helium); | |
1576 // Wechseltiefe | |
1577 if(pGasLine[gasId].depth_meter) | |
1578 { | |
1579 textpointer += snprintf(&text[textpointer],7,"\t%u %c%c",unit_depth_integer(pGasLine[gasId].depth_meter), unit_depth_char1(), unit_depth_char2()); | |
1580 } | |
1581 GFX_write_string(&FontT42, &t7cY0free, text, gasId); | |
1582 } | |
1583 break; | |
1584 | |
1585 case CVIEW_EADTime: | |
1586 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Info ); | |
1587 GFX_write_string(&FontT42,&t7cH,text,0); | |
1588 textpointer = 0; | |
1589 | |
1590 t7cY0free.WindowY0 = t7cC.WindowY0 - 10; | |
1591 t7cY0free.WindowLineSpacing = 48; | |
1592 t7cY0free.WindowNumberOfTextLines = 6; | |
1593 | |
1594 // time | |
1595 snprintf(text,100,"\032\001%c%c",TXT_2BYTE,TXT2BYTE_Clock ); | |
1596 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
1597 | |
1598 translateDate(stateRealGetPointer()->lifeData.dateBinaryFormat, &Sdate); | |
1599 translateTime(stateRealGetPointer()->lifeData.timeBinaryFormat, &Stime); | |
1600 if(Stime.Seconds % 2) | |
1601 textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d",Stime.Hours,Stime.Minutes); | |
1602 else | |
1603 textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d",Stime.Hours,Stime.Minutes); | |
1604 GFX_write_string(&FontT42, &t7cY0free, text, 2); | |
1605 | |
1606 // EAD / END | |
1607 // The equivalent air depth can be calculated for depths in metres as follows: | |
1608 // EAD = (Depth + 10) � Fraction of N2 / 0.79 - 10 (wikipedia) | |
1609 // The equivalent narcotic depth can be calculated for depths in metres as follows: | |
1610 // END = (Depth + 10) � (1 - Fraction of helium) - 10 (wikipedia) | |
1611 decom_get_inert_gases((float)stateUsed->lifeData.pressure_ambient_bar,&(stateUsed->lifeData.actualGas),&fraction_nitrogen,&fraction_helium); | |
1612 depth = stateUsed->lifeData.pressure_ambient_bar; | |
1613 surface = stateUsed->lifeData.pressure_surface_bar; | |
1614 ead = 10.f * ((depth * fraction_nitrogen/0.79f) - surface); | |
1615 end = 10.0f * ((depth * (1.f - fraction_helium)) - surface); | |
1616 if(ead < 0) | |
1617 ead = 0; | |
1618 if(end < 0) | |
1619 end = 0; | |
1620 | |
1621 snprintf(text,100,"\032\001EAD"); | |
1622 GFX_write_string(&FontT42, &t7cY0free, text, 3); | |
1623 snprintf(text,100,"\030\001%01.1f %c%c" | |
1624 , unit_depth_float(ead) | |
1625 , unit_depth_char1() | |
1626 , unit_depth_char2() | |
1627 ); | |
1628 GFX_write_string(&FontT42, &t7cY0free, text, 4); | |
1629 | |
1630 snprintf(text,100,"\032\001END"); | |
1631 GFX_write_string(&FontT42, &t7cY0free, text, 5); | |
1632 snprintf(text,100,"\030\001%01.1f %c%c" | |
1633 , unit_depth_float(ead) | |
1634 , unit_depth_char1() | |
1635 , unit_depth_char2() | |
1636 ); | |
1637 GFX_write_string(&FontT42, &t7cY0free, text, 6); | |
1638 break; | |
1639 | |
1640 case CVIEW_Profile: | |
1641 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Profile); | |
1642 GFX_write_string(&FontT42,&t7cH,text,0); | |
1643 textpointer = 0; | |
1644 t7_miniLiveLogProfile(); | |
1645 break; | |
1646 | |
1647 case CVIEW_Tissues: | |
1648 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Tissues); | |
1649 GFX_write_string(&FontT42,&t7cH,text,0); | |
1650 textpointer = 0; | |
1651 t7_tissues(stateUsed); | |
1652 break; | |
1653 | |
1654 case CVIEW_sensors: | |
1655 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_O2monitor); | |
1656 GFX_write_string(&FontT42,&t7cH,text,0); | |
1657 textpointer = 0; | |
1658 text[textpointer++] = '\030'; // main color | |
1659 for(int i=0;i<3;i++) | |
1660 { | |
1661 if(stateUsed->diveSettings.ppo2sensors_deactivated & (1<<i)) | |
1662 { | |
1663 text[textpointer++] = '\031'; // labelcolor | |
1664 text[textpointer++] = '\001'; | |
1665 text[textpointer++] = '-'; | |
1666 text[textpointer++] = '\n'; | |
1667 text[textpointer++] = '\r'; | |
1668 text[textpointer++] = '\030'; // main color | |
1669 text[textpointer] = 0; | |
1670 } | |
1671 else | |
1672 { | |
1673 if(stateUsed->warnings.sensorOutOfBounds[i]) | |
1674 text[textpointer++] = '\025'; // Warning Red | |
1675 textpointer += snprintf(&text[textpointer],100,"\001%01.2f\n\r\030",stateUsed->lifeData.ppO2Sensor_bar[i]); | |
1676 } | |
1677 } | |
1678 t7cC.WindowLineSpacing = 95; | |
1679 t7cC.WindowNumberOfTextLines = 3; | |
1680 text[textpointer] = 0; | |
1681 GFX_write_string(&FontT105,&t7cC,text,1); | |
1682 break; | |
1683 | |
1684 case CVIEW_sensors_mV: | |
1685 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_O2voltage); | |
1686 GFX_write_string(&FontT42,&t7cH,text,0); | |
1687 textpointer = 0; | |
1688 text[textpointer++] = '\030'; | |
1689 for(int i=0;i<3;i++) | |
1690 { | |
1691 if(stateUsed->diveSettings.ppo2sensors_deactivated & (1<<i)) | |
1692 { | |
1693 text[textpointer++] = '\031'; | |
1694 text[textpointer++] = '\001'; | |
1695 text[textpointer++] = '-'; | |
1696 text[textpointer++] = '\n'; | |
1697 text[textpointer++] = '\r'; | |
1698 text[textpointer++] = '\030'; | |
1699 text[textpointer] = 0; | |
1700 } | |
1701 else | |
1702 { | |
1703 if(stateUsed->warnings.sensorOutOfBounds[i]) | |
1704 text[textpointer++] = '\025'; | |
1705 textpointer += snprintf(&text[textpointer],100,"\001%01.1f mV\n\r\030",(stateUsed->lifeData.sensorVoltage_mV[i])); | |
1706 } | |
1707 } | |
1708 t7cC.WindowLineSpacing = 95; | |
1709 t7cC.WindowNumberOfTextLines = 3; | |
1710 text[textpointer] = 0; | |
1711 GFX_write_string(&FontT48,&t7cC,text,1); | |
1712 break; | |
1713 | |
1714 case CVIEW_Compass: | |
1715 default: | |
1716 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE, TXT2BYTE_Compass); | |
1717 GFX_write_string(&FontT42,&t7cH,text,0); | |
1718 t7_compass((uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading); | |
1719 t7cY0free.WindowY0 = 230; | |
1720 t7cY0free.WindowX0 += 15; | |
1721 snprintf(text,100,"\030\001%03i`",(uint16_t)stateUsed->lifeData.compass_heading); | |
1722 GFX_write_string(&FontT54,&t7cY0free,text,0); | |
1723 t7cY0free.WindowX0 -= 15; | |
1724 break; | |
1725 | |
1726 case CVIEW_Decolist: | |
1727 snprintf(text,100,"\032\f\001 %c%c", TXT_2BYTE, TXT2BYTE_Decolist); | |
1728 GFX_write_string(&FontT42,&t7cH,text,0); | |
1729 | |
1730 const SDecoinfo * pDecoinfo; | |
1731 uint8_t depthNext, depthLast, depthSecond, depthInc; | |
1732 | |
1733 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) | |
1734 pDecoinfo = &stateUsed->decolistBuehlmann; | |
1735 else | |
1736 pDecoinfo = &stateUsed->decolistVPM; | |
1737 | |
1738 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); | |
1739 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); | |
1740 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); | |
1741 | |
1742 if(settingsGetPointer()->nonMetricalSystem) | |
1743 { | |
1744 depthLast = (uint8_t)unit_depth_integer(depthLast); | |
1745 depthSecond = (uint8_t)unit_depth_integer(depthSecond); | |
1746 depthInc = (uint8_t)unit_depth_integer(depthInc); | |
1747 } | |
1748 | |
1749 for(start=DECOINFO_STRUCT_MAX_STOPS-1; start>0; start--) | |
1750 if(pDecoinfo->output_stop_length_seconds[start]) break; | |
1751 start -= 6; | |
1752 if(start < 0) start = 0; | |
1753 | |
1754 textpointer = 0; | |
1755 for(int i=start;i<6+start;i++) | |
1756 { | |
1757 if(i == 0) | |
1758 depthNext = depthLast; | |
1759 else | |
1760 depthNext = depthSecond + (( i - 1 )* depthInc); | |
1761 | |
1762 if(pDecoinfo->output_stop_length_seconds[i]) | |
1763 textpointer += snprintf(&text[textpointer],20,"\030\034 %2u\016\016%c%c\017%3i'\n\r",depthNext, unit_depth_char1(), unit_depth_char2(), (pDecoinfo->output_stop_length_seconds[i]+59)/60); | |
1764 else | |
1765 textpointer += snprintf(&text[textpointer],20,"\031\034 %2u\016\016%c%c\017\n\r",depthNext, unit_depth_char1(), unit_depth_char2()); | |
1766 if(textpointer > 200) break; | |
1767 } | |
1768 t7cY0free.WindowY0 = t7cC.WindowY0 - 10; | |
1769 t7cY0free.WindowLineSpacing = 48; | |
1770 t7cY0free.WindowNumberOfTextLines = 6; | |
1771 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
1772 break; | |
1773 } | |
1774 } | |
1775 | |
1776 | |
1777 | |
1778 /* DIVE MODE | |
1779 */ | |
1780 void t7_refresh_divemode(void) | |
1781 { | |
1782 char TextL1[TEXTSIZE]; | |
1783 char TextL2[TEXTSIZE]; | |
1784 | |
1785 char TextR1[TEXTSIZE]; | |
1786 char TextR2[TEXTSIZE]; | |
1787 char TextR3[TEXTSIZE]; | |
1788 | |
1789 char TextC1[2*TEXTSIZE]; | |
1790 char TextC2[TEXTSIZE]; | |
1791 uint8_t textPointer; | |
1792 | |
1793 point_t start, stop; | |
1794 uint8_t color; | |
1795 int textlength; | |
1796 | |
1797 uint16_t nextstopLengthSeconds = 0; | |
1798 uint8_t nextstopDepthMeter = 0; | |
1799 uint8_t oxygen_percentage = 0; | |
1800 SDivetime Divetime = {0,0,0, 0}; | |
1801 SDivetime SafetyStopTime = {0,0,0,0}; | |
1802 SDivetime TimeoutTime = {0,0,0,0}; | |
1803 uint8_t customview_warnings = 0; | |
1804 const SDecoinfo * pDecoinfo; | |
1805 | |
1806 Divetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time; | |
1807 Divetime.Minutes = Divetime.Total / 60; | |
1808 Divetime.Seconds = Divetime.Total - ( Divetime.Minutes * 60 ); | |
1809 | |
1810 SafetyStopTime.Total = timer_Safetystop_GetCountDown(); | |
1811 SafetyStopTime.Minutes = SafetyStopTime.Total / 60; | |
1812 SafetyStopTime.Seconds = SafetyStopTime.Total - (SafetyStopTime.Minutes * 60); | |
1813 | |
1814 TimeoutTime.Total = settingsGetPointer()->timeoutDiveReachedZeroDepth - stateUsed->lifeData.counterSecondsShallowDepth; | |
1815 if(TimeoutTime.Total > settingsGetPointer()->timeoutDiveReachedZeroDepth) | |
1816 { | |
1817 TimeoutTime.Total = 0; | |
1818 } | |
1819 TimeoutTime.Minutes = TimeoutTime.Total / 60; | |
1820 TimeoutTime.Seconds = TimeoutTime.Total - (TimeoutTime.Minutes * 60); | |
1821 | |
1822 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) | |
1823 pDecoinfo = &stateUsed->decolistBuehlmann; | |
1824 else | |
1825 pDecoinfo = &stateUsed->decolistVPM; | |
1826 | |
1827 if(pDecoinfo->output_time_to_surface_seconds) | |
1828 { | |
1829 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); | |
1830 } | |
1831 else | |
1832 { | |
1833 nextstopDepthMeter = 0; | |
1834 nextstopLengthSeconds = 0; | |
1835 } | |
1836 | |
1837 /* depth */ | |
1838 float depth = 0; | |
1839 float depthThisCall = unit_depth_float(stateUsed->lifeData.depth_meter); | |
1840 if(is_stateUsedSetToSim()) | |
1841 { | |
1842 depth = (depthThisCall + depthLastCall[0] + depthLastCall[1] + depthLastCall[2] + depthLastCall[3] + depthLastCall[4] + depthLastCall[5] + depthLastCall[6] + depthLastCall[7] + depthLastCall[8]) / 10.0f; | |
1843 | |
1844 idDepthLastCall++; | |
1845 if(idDepthLastCall >= 9) | |
1846 idDepthLastCall = 0; | |
1847 depthLastCall[idDepthLastCall] = depthThisCall; | |
1848 } | |
1849 else | |
1850 { | |
1851 depth = (depthThisCall + depthLastCall[0] + depthLastCall[1] + depthLastCall[2]) / 4.0f; | |
1852 | |
1853 idDepthLastCall++; | |
1854 if(idDepthLastCall >= 3) | |
1855 idDepthLastCall = 0; | |
1856 depthLastCall[idDepthLastCall] = depthThisCall; | |
1857 } | |
1858 | |
1859 if(depth <= 0.3f) | |
1860 depth = 0; | |
1861 | |
1862 if(settingsGetPointer()->nonMetricalSystem) | |
1863 snprintf(TextL1,TEXTSIZE,"\032\f[feet]"); | |
1864 else | |
1865 snprintf(TextL1,TEXTSIZE,"\032\f%c",TXT_Depth); | |
1866 GFX_write_string(&FontT24,&t7l1,TextL1,0); | |
1867 | |
1868 if((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10)) | |
1869 { | |
1870 snprintf(TextL1,TEXTSIZE,"\f\002%.0f %c%c/min " | |
1871 , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min) | |
1872 , unit_depth_char1() | |
1873 , unit_depth_char2() | |
1874 ); | |
1875 GFX_write_string(&FontT24,&t7l1,TextL1,0); | |
1876 } | |
1877 | |
1878 if( depth < 100) | |
1879 snprintf(TextL1,TEXTSIZE,"\020%01.1f",depth); | |
1880 else | |
1881 snprintf(TextL1,TEXTSIZE,"\020%01.0f",depth); | |
1882 | |
1883 t7_colorscheme_mod(TextL1); | |
1884 GFX_write_string(&FontT144,&t7l1,TextL1,1); | |
1885 | |
1886 /* max depth */ | |
1887 snprintf(TextL2,TEXTSIZE,"\032\f%c",TXT_MaxDepth); | |
1888 GFX_write_string(&FontT42,&t7l2,TextL2,0); | |
1889 | |
1890 if(unit_depth_float(stateUsed->lifeData.max_depth_meter) < 100) | |
1891 snprintf(TextL2,TEXTSIZE,"\020%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); | |
1892 else | |
1893 snprintf(TextL2,TEXTSIZE,"\020%01.0f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); | |
1894 | |
1895 t7_colorscheme_mod(TextL2); | |
1896 GFX_write_string(&FontT105,&t7l2,TextL2,1); | |
1897 | |
1898 /* ascentrate graph */ | |
1899 if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) | |
1900 { | |
1901 start.y = t7l1.WindowY0 - 1; | |
1902 for(int i = 0; i<4;i++) | |
1903 { | |
1904 start.y += 5*6; | |
1905 stop.y = start.y; | |
1906 start.x = CUSTOMBOX_LINE_LEFT - 1; | |
1907 stop.x = start.x - 17; | |
1908 GFX_draw_line(&t7screen, start, stop, 0); | |
1909 // start.x = CUSTOMBOX_LINE_RIGHT + 2; old right too | |
1910 // stop.x = start.x + 17; | |
1911 // GFX_draw_line(&t7screen, start, stop, 0); | |
1912 } | |
1913 // new thick bar design Sept. 2015 | |
1914 start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 3 - 5; | |
1915 stop.x = start.x; | |
1916 start.y = t7l1.WindowY0 - 1; | |
1917 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 6); | |
1918 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 | |
1919 if(stop.y >= 470) | |
1920 stop.y = 470; | |
1921 start.y += 7; // starte etwas weiter oben | |
1922 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) | |
1923 color = CLUT_EverythingOkayGreen; | |
1924 else | |
1925 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) | |
1926 color = CLUT_WarningYellow; | |
1927 else | |
1928 color = CLUT_WarningRed; | |
1929 | |
1930 GFX_draw_thick_line(12,&t7screen, start, stop, color); | |
1931 } | |
1932 //snprintf(TextL2,TEXTSIZE,"\f%.1f m/min",stateUsed->lifeData.ascent_rate_meter_per_min); | |
1933 | |
1934 /* divetime */ | |
1935 if(stateUsed->lifeData.counterSecondsShallowDepth) | |
1936 { | |
1937 snprintf(TextR1,TEXTSIZE,"\f\002\136 %u:%02u",TimeoutTime.Minutes, TimeoutTime.Seconds); | |
1938 GFX_write_string(&FontT42,&t7r1,TextR1,0); | |
1939 } | |
1940 else | |
1941 { | |
1942 snprintf(TextR1,TEXTSIZE,"\032\f\002%c",TXT_Divetime); | |
1943 GFX_write_string(&FontT42,&t7r1,TextR1,0); | |
1944 } | |
1945 | |
1946 if(Divetime.Minutes < 1000) | |
1947 snprintf(TextR1,TEXTSIZE,"\020\016\002%u:%02u",Divetime.Minutes, Divetime.Seconds); | |
1948 else | |
1949 snprintf(TextR1,TEXTSIZE,"\020\016\002%u'",Divetime.Minutes); | |
1950 t7_colorscheme_mod(TextR1); | |
1951 GFX_write_string(&FontT105,&t7r1,TextR1,1); | |
1952 | |
1953 /* next deco stop */ | |
1954 if(nextstopDepthMeter) | |
1955 { | |
1956 snprintf(TextR2,TEXTSIZE,"\032\f\002%c",TXT_Decostop); | |
1957 GFX_write_string(&FontT42,&t7r2,TextR2,0); | |
1958 textlength = snprintf(TextR2,TEXTSIZE,"\020\002%u%c%c %u'" | |
1959 , unit_depth_integer(nextstopDepthMeter) | |
1960 , unit_depth_char1_T105() | |
1961 , unit_depth_char2_T105() | |
1962 , (nextstopLengthSeconds+59)/60); | |
1963 t7_colorscheme_mod(TextR2); | |
1964 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) | |
1965 TextR2[0] = '\021'; | |
1966 if(textlength <= 9) | |
1967 GFX_write_string(&FontT105,&t7r2,TextR2,1); | |
1968 else | |
1969 GFX_write_string(&FontT54,&t7r2,TextR2,1); | |
1970 } | |
1971 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit())) | |
1972 { | |
1973 snprintf(TextR2,TEXTSIZE,"\032\f\002%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2); | |
1974 GFX_write_string(&FontT42,&t7r2,TextR2,0); | |
1975 snprintf(TextR2,TEXTSIZE,"\020\016\002%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds); | |
1976 t7_colorscheme_mod(TextR2); | |
1977 GFX_write_string(&FontT105,&t7r2,TextR2,1); | |
1978 } | |
1979 | |
1980 /* tts - option 1 | |
1981 * ndl - option 2 | |
1982 * empty - option 3 */ | |
1983 if(pDecoinfo->output_time_to_surface_seconds) | |
1984 { | |
1985 snprintf(TextR3,TEXTSIZE,"\032\f\002%c",TXT_TTS); | |
1986 GFX_write_string(&FontT42,&t7r3,TextR3,0); | |
1987 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60) | |
1988 snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 30)/ 60); | |
1989 else | |
1990 snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_time_to_surface_seconds / 3600); | |
1991 t7_colorscheme_mod(TextR3); | |
1992 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) | |
1993 TextR2[0] = '\021'; | |
1994 GFX_write_string(&FontT105,&t7r3,TextR3,1); | |
1995 } | |
1996 else if(pDecoinfo->output_ndl_seconds) | |
1997 { | |
1998 snprintf(TextR3,TEXTSIZE,"\032\f\002%c",TXT_Nullzeit); | |
1999 GFX_write_string(&FontT42,&t7r3,TextR3,0); | |
2000 if(pDecoinfo->output_ndl_seconds < 1000 * 60) | |
2001 snprintf(TextR3,TEXTSIZE,"\020\002%i'",pDecoinfo->output_ndl_seconds/60); | |
2002 else | |
2003 snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_ndl_seconds/3600); | |
2004 t7_colorscheme_mod(TextR3); | |
2005 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) | |
2006 TextR2[0] = '\021'; | |
2007 GFX_write_string(&FontT105,&t7r3,TextR3,1); | |
2008 } | |
2009 | |
2010 /* Menu Selection (and gas mix) */ | |
2011 if(get_globalState() == StDMGAS) | |
2012 { | |
2013 textPointer = 0; | |
2014 TextR1[textPointer++] = '\a'; | |
2015 // TextR1[textPointer++] = '\f'; | |
2016 TextR1[textPointer++] = '\001'; | |
2017 TextR1[textPointer++] = ' '; | |
2018 textPointer += tHome_gas_writer(stateUsed->diveSettings.gas[actualBetterGasId()].oxygen_percentage,stateUsed->diveSettings.gas[actualBetterGasId()].helium_percentage,&TextR1[textPointer]); | |
2019 TextR1[textPointer++] = '?'; | |
2020 TextR1[textPointer++] = ' '; | |
2021 TextR1[textPointer++] = 0; | |
2022 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | |
2023 } | |
2024 else if(get_globalState() == StDMSPT) | |
2025 { | |
2026 textPointer = 0; | |
2027 TextR1[textPointer++] = '\a'; | |
2028 TextR1[textPointer++] = '\001'; | |
2029 TextR1[textPointer++] = ' '; | |
2030 textPointer += snprintf(&TextR1[textPointer],5,"%f01.2",((float)(stateUsed->diveSettings.setpoint[actualBetterSetpointId()].setpoint_cbar))/100); | |
2031 TextR1[textPointer++] = '?'; | |
2032 TextR1[textPointer++] = ' '; | |
2033 TextR1[textPointer++] = 0; | |
2034 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | |
2035 } | |
2036 else if(get_globalState() == StDMENU) | |
2037 { | |
2038 snprintf(TextR1,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveMenuQ); | |
2039 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | |
2040 } | |
2041 else if(get_globalState() == StDSIM1) | |
2042 { | |
2043 snprintf(TextR1,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
2044 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | |
2045 } | |
2046 else if(get_globalState() == StDSIM2) | |
2047 { | |
2048 if(settingsGetPointer()->nonMetricalSystem) | |
2049 snprintf(TextR1,TEXTSIZE,"\a\001" " Sim:-3.33ft "); | |
2050 else | |
2051 snprintf(TextR1,TEXTSIZE,"\a\001" " Sim:-1m "); | |
2052 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | |
2053 | |
2054 snprintf(TextR1,TEXTSIZE,"\a\f %u %c%c" | |
2055 , unit_depth_integer(simulation_get_aim_depth()) | |
2056 , unit_depth_char1() | |
2057 , unit_depth_char2() | |
2058 ); | |
2059 GFX_write_string_color(&FontT42,&t7l1,TextR1,0,CLUT_WarningYellow); | |
2060 | |
2061 } | |
2062 else if(get_globalState() == StDSIM3) | |
2063 { | |
2064 if(settingsGetPointer()->nonMetricalSystem) | |
2065 snprintf(TextR1,TEXTSIZE,"\a\001" " Sim:+3.33ft "); | |
2066 else | |
2067 snprintf(TextR1,TEXTSIZE,"\a\001" " Sim:+1m "); | |
2068 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | |
2069 snprintf(TextR1,TEXTSIZE,"\a\f %u %c%c" | |
2070 , unit_depth_integer(simulation_get_aim_depth()) | |
2071 , unit_depth_char1() | |
2072 , unit_depth_char2() | |
2073 ); | |
2074 GFX_write_string_color(&FontT42,&t7l1,TextR1,0,CLUT_WarningYellow); | |
2075 } | |
2076 else if(get_globalState() == StDSIM4) | |
2077 { | |
2078 snprintf(TextR1,TEXTSIZE,"\a\001" " Sim:+5' "); | |
2079 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | |
2080 snprintf(TextR1,TEXTSIZE,"\a\f %u %c%c" | |
2081 , unit_depth_integer(simulation_get_aim_depth()) | |
2082 , unit_depth_char1() | |
2083 , unit_depth_char2() | |
2084 ); | |
2085 GFX_write_string_color(&FontT42,&t7l1,TextR1,0,CLUT_WarningYellow); | |
2086 } | |
2087 else | |
2088 { | |
2089 /* gas mix */ | |
2090 oxygen_percentage = 100; | |
2091 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage; | |
2092 oxygen_percentage -= stateUsed->lifeData.actualGas.helium_percentage; | |
2093 | |
2094 textPointer = 0; | |
2095 TextC2[textPointer++] = '\020'; | |
2096 if(stateUsed->warnings.betterGas && warning_count_high_time) | |
2097 { | |
2098 TextC2[textPointer++] = '\a'; | |
2099 } | |
2100 else | |
2101 { | |
2102 float fPpO2limitHigh, fPpO2now; | |
2103 | |
2104 if(actualLeftMaxDepth(stateUsed)) | |
2105 fPpO2limitHigh = settingsGetPointer()->ppO2_max_deco; | |
2106 else | |
2107 fPpO2limitHigh = settingsGetPointer()->ppO2_max_std; | |
2108 | |
2109 fPpO2now = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * oxygen_percentage; | |
2110 | |
2111 if((fPpO2now > fPpO2limitHigh) || (fPpO2now < (float)(settingsGetPointer()->ppO2_min))) | |
2112 TextC2[textPointer++] = '\025'; | |
2113 } | |
2114 TextC2[textPointer++] = '\002'; | |
2115 textPointer += tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&TextC2[textPointer]); | |
2116 | |
2117 if(stateUsed->warnings.betterGas && warning_count_high_time) | |
2118 { | |
2119 if(TextC2[0] == '\020') | |
2120 { | |
2121 TextC2[0] = '\004'; // NOP | |
2122 } | |
2123 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow); | |
2124 } | |
2125 else | |
2126 { | |
2127 t7_colorscheme_mod(TextC2); | |
2128 GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers | |
2129 } | |
2130 | |
2131 if(stateUsed->diveSettings.ccrOption) | |
2132 { | |
2133 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) | |
2134 { | |
2135 snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); | |
2136 if(stateUsed->warnings.betterSetpoint && warning_count_high_time && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR)) | |
2137 { | |
2138 TextC2[0] = '\a'; // inverse instead of color \020 | |
2139 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow); | |
2140 } | |
2141 else | |
2142 { | |
2143 t7_colorscheme_mod(TextC2); | |
2144 GFX_write_string(&FontT48,&t7c2,TextC2,0); | |
2145 } | |
2146 } | |
2147 } | |
2148 else if(settingsGetPointer()->alwaysShowPPO2) | |
2149 { | |
2150 snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); | |
2151 t7_colorscheme_mod(TextC2); | |
2152 GFX_write_string(&FontT48,&t7c2,TextC2,0); | |
2153 } | |
2154 } | |
2155 | |
2156 /* algorithm, ccr, bailout and battery */ | |
2157 /* and permanent warnings (CNS) */ | |
2158 | |
2159 if((stateUsed->warnings.cnsHigh) && display_count_high_time) | |
2160 { | |
2161 TextC2[0] = '\f'; | |
2162 TextC2[1] = TXT_2BYTE; | |
2163 TextC2[2] = TXT2BYTE_WarnCnsHigh; | |
2164 TextC2[3] = 0; | |
2165 GFX_write_string_color(&FontT48,&t7c1,TextC2,0,CLUT_WarningRed); | |
2166 } | |
2167 else | |
2168 { | |
2169 if(stateUsed->warnings.aGf) | |
2170 { | |
2171 GFX_write_string_color(&FontT48,&t7c1,"\f" "aGF",0,CLUT_WarningYellow); | |
2172 } | |
2173 else if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) | |
2174 { | |
2175 GFX_write_string(&FontT48,&t7c1,"\027\f" "GF",0); | |
2176 } | |
2177 else | |
2178 { | |
2179 GFX_write_string(&FontT48,&t7c1,"\027\f" "VPM",0); | |
2180 } | |
2181 | |
2182 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) | |
2183 GFX_write_string(&FontT24,&t7c1,"\027\f\002" "CCR",0); | |
2184 // GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80" "CCR",0); | |
2185 else | |
2186 if(stateUsed->diveSettings.ccrOption) | |
2187 GFX_write_string(&FontT24,&t7c1,"\f\002\024" "Bailout",0); | |
2188 // GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80\024" "Bailout",0); | |
2189 } | |
2190 TextC1[0] = '\020'; | |
2191 TextC1[1] = '3'; | |
2192 TextC1[2] = '1'; | |
2193 TextC1[3] = '1'; | |
2194 TextC1[4] = '1'; | |
2195 TextC1[5] = '1'; | |
2196 TextC1[6] = '1'; | |
2197 TextC1[7] = '1'; | |
2198 TextC1[8] = '1'; | |
2199 TextC1[9] = '1'; | |
2200 TextC1[10] = '1'; | |
2201 TextC1[11] = '1'; | |
2202 TextC1[12] = '0'; | |
2203 TextC1[13] = 0; | |
2204 | |
2205 for(int i=1;i<=10;i++) | |
2206 { | |
2207 if( stateUsed->lifeData.battery_charge > (9 * i)) | |
2208 TextC1[i+1] += 1; | |
2209 } | |
2210 | |
2211 if(stateUsed->warnings.lowBattery) | |
2212 { | |
2213 TextC1[0] = '\025'; | |
2214 if(warning_count_high_time) | |
2215 { | |
2216 for(int i=2;i<=11;i++) | |
2217 TextC1[i] = '1'; | |
2218 } | |
2219 else | |
2220 { | |
2221 TextC1[2] = '2'; | |
2222 } | |
2223 GFX_write_string(&Batt24,&t7batt,TextC1,0); | |
2224 | |
2225 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) | |
2226 { | |
2227 snprintf(TextC1,16,"\004\025\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); | |
2228 if(warning_count_high_time) | |
2229 TextC1[0] = '\a'; | |
2230 GFX_write_string(&FontT24,&t7batt,TextC1,0); | |
2231 } | |
2232 } | |
2233 else | |
2234 { | |
2235 t7_colorscheme_mod(TextC1); | |
2236 GFX_write_string(&Batt24,&t7batt,TextC1,0); | |
2237 | |
2238 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140)) | |
2239 { | |
2240 snprintf(TextC1,16,"\020\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge); | |
2241 t7_colorscheme_mod(TextC1); | |
2242 GFX_write_string(&FontT24,&t7batt,TextC1,0); | |
2243 } | |
2244 } | |
2245 | |
2246 /* customizable left lower corner */ | |
2247 t7_refresh_divemode_userselected_left_lower_corner(); | |
2248 | |
2249 | |
2250 /* customview - option 1 | |
2251 * warning - option 2 */ | |
2252 if(stateUsed->warnings.numWarnings) | |
2253 customview_warnings = t7_test_customview_warnings(); | |
2254 | |
2255 background.pointer = NULL; | |
2256 if(customview_warnings && warning_count_high_time) | |
2257 t7_show_customview_warnings(); | |
2258 else | |
2259 t7_refresh_customview(); | |
2260 | |
2261 /* the frame */ | |
2262 draw_frame(1,1, CLUT_DIVE_pluginbox, CLUT_DIVE_FieldSeperatorLines); | |
2263 } | |
2264 | |
2265 void t7_set_field_to_primary(void) | |
2266 { | |
2267 if(stateUsed->mode == MODE_DIVE) | |
2268 selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary; | |
2269 } | |
2270 | |
2271 void t7_change_field(void) | |
2272 { | |
2273 const uint8_t minVal = 0; | |
2274 const uint8_t maxValGF = 8; | |
2275 const uint8_t maxValVPM = 7; | |
2276 uint8_t maxNow = maxValGF; | |
2277 | |
2278 selection_custom_field++; | |
2279 | |
2280 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | |
2281 maxNow = maxValVPM; | |
2282 | |
2283 if(selection_custom_field > maxNow) | |
2284 selection_custom_field = minVal; | |
2285 } | |
2286 | |
2287 | |
2288 void t7_refresh_divemode_userselected_left_lower_corner(void) | |
2289 { | |
2290 if(!selection_custom_field) | |
2291 return; | |
2292 | |
2293 char headerText[10]; | |
2294 char text[TEXTSIZE]; | |
2295 uint8_t textpointer = 0; | |
2296 _Bool tinyHeaderFont = 0; | |
2297 uint8_t line = 0; | |
2298 | |
2299 SDivetime Stopwatch = {0,0,0,0}; | |
2300 float fAverageDepth, fAverageDepthAbsolute; | |
2301 const SDecoinfo * pDecoinfoStandard; | |
2302 const SDecoinfo * pDecoinfoFuture; | |
2303 float fCNS; | |
2304 | |
2305 float temperatureThisCall; | |
2306 float temperature; | |
2307 | |
2308 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) | |
2309 { | |
2310 pDecoinfoStandard = &stateUsed->decolistBuehlmann; | |
2311 pDecoinfoFuture = &stateUsed->decolistFutureBuehlmann; | |
2312 } | |
2313 else | |
2314 { | |
2315 pDecoinfoStandard = &stateUsed->decolistVPM; | |
2316 pDecoinfoFuture = &stateUsed->decolistFutureVPM; | |
2317 } | |
2318 | |
2319 Stopwatch.Total = timer_Stopwatch_GetTime(); | |
2320 Stopwatch.Minutes = Stopwatch.Total / 60; | |
2321 Stopwatch.Seconds = Stopwatch.Total - ( Stopwatch.Minutes * 60 ); | |
2322 fAverageDepth = timer_Stopwatch_GetAvarageDepth_Meter(); | |
2323 fAverageDepthAbsolute = stateUsed->lifeData.average_depth_meter; | |
2324 | |
2325 headerText[0] = '\032'; | |
2326 headerText[1] = '\f'; | |
2327 | |
2328 switch(selection_custom_field) | |
2329 { | |
2330 /* Temperature */ | |
2331 case 1: | |
2332 default: | |
2333 // mean value | |
2334 temperatureThisCall = unit_temperature_float(stateUsed->lifeData.temperature_celsius); | |
2335 temperature = (temperatureThisCall + temperatureLastCall[0] + temperatureLastCall[1] + temperatureLastCall[2]) / 4.0f; | |
2336 idTemperatureLastCall++; | |
2337 if(idTemperatureLastCall >= 3) | |
2338 idTemperatureLastCall = 0; | |
2339 temperatureLastCall[idTemperatureLastCall] = temperatureThisCall; | |
2340 // output | |
2341 headerText[2] = TXT_Temperature; | |
2342 textpointer = snprintf(text,TEXTSIZE,"\020\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F | |
2343 if(settingsGetPointer()->nonMetricalSystem == 0) | |
2344 text[textpointer++] = 'C'; | |
2345 else | |
2346 text[textpointer++] = 'F'; | |
2347 text[textpointer++] = 0; | |
2348 tinyHeaderFont = 0; | |
2349 break; | |
2350 | |
2351 /* Average Depth */ | |
2352 case 2: | |
2353 headerText[2] = TXT_AvgDepth; | |
2354 if(settingsGetPointer()->nonMetricalSystem) | |
2355 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(fAverageDepthAbsolute)); | |
2356 else | |
2357 snprintf(text,TEXTSIZE,"\020%01.1f",fAverageDepthAbsolute); | |
2358 break; | |
2359 | |
2360 /* ppO2 */ | |
2361 case 3: | |
2362 headerText[2] = TXT_ppO2; | |
2363 snprintf(text,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); | |
2364 break; | |
2365 | |
2366 /* Stop Uhr */ | |
2367 case 4: | |
2368 headerText[2] = TXT_Stopwatch; | |
2369 if(settingsGetPointer()->nonMetricalSystem) | |
2370 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.0f",Stopwatch.Minutes, Stopwatch.Seconds,unit_depth_float(fAverageDepth)); | |
2371 else | |
2372 snprintf(text,TEXTSIZE,"\020\016\016%u:%02u\n\r%01.1f",Stopwatch.Minutes, Stopwatch.Seconds,fAverageDepth); | |
2373 tinyHeaderFont = 1; | |
2374 line = 1; | |
2375 break; | |
2376 | |
2377 /* Ceiling */ | |
2378 case 5: | |
2379 headerText[2] = TXT_Ceiling; | |
2380 if((pDecoinfoStandard->output_ceiling_meter > 99.9f) || (settingsGetPointer()->nonMetricalSystem)) | |
2381 snprintf(text,TEXTSIZE,"\020%01.0f",unit_depth_float(pDecoinfoStandard->output_ceiling_meter)); | |
2382 else | |
2383 snprintf(text,TEXTSIZE,"\020%01.1f",pDecoinfoStandard->output_ceiling_meter); | |
2384 break; | |
2385 | |
2386 /* Future TTS */ | |
2387 case 6: | |
2388 headerText[2] = TXT_FutureTTS; | |
2389 snprintf(text,TEXTSIZE,"\020\016\016@+%u'\n\r" "%i' TTS",settingsGetPointer()->future_TTS, pDecoinfoFuture->output_time_to_surface_seconds / 60); | |
2390 tinyHeaderFont = 1; | |
2391 line = 1; | |
2392 break; | |
2393 | |
2394 /* CNS */ | |
2395 case 7: | |
2396 headerText[2] = TXT_CNS; | |
2397 fCNS = stateUsed->lifeData .cns; | |
2398 if(fCNS > 999) | |
2399 fCNS = 999; | |
2400 snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",fCNS); | |
2401 break; | |
2402 | |
2403 /* actual GF */ | |
2404 case 8: | |
2405 headerText[2] = TXT_ActualGradient; | |
2406 snprintf(text,TEXTSIZE,"\020%.0f",100 * pDecoinfoStandard->output_relative_gradient); | |
2407 break; | |
2408 } | |
2409 headerText[3] = 0; | |
2410 | |
2411 if(tinyHeaderFont) | |
2412 GFX_write_string(&FontT24,&t7l3,headerText,0); | |
2413 else | |
2414 GFX_write_string(&FontT42,&t7l3,headerText,0); | |
2415 | |
2416 t7_colorscheme_mod(text); | |
2417 GFX_write_string(&FontT105,&t7l3,text,line); | |
2418 } | |
2419 | |
2420 /* Private functions ---------------------------------------------------------*/ | |
2421 | |
2422 uint8_t t7_customtextPrepare(char * text) | |
2423 { | |
2424 uint8_t i, j, textptr, lineCount; | |
2425 char nextChar; | |
2426 | |
2427 textptr = 0; | |
2428 lineCount = 0; | |
2429 | |
2430 text[textptr++] = TXT_MINIMAL; | |
2431 | |
2432 j = 0; | |
2433 i = 0; | |
2434 do | |
2435 { | |
2436 j += i; | |
2437 i = 0; | |
2438 do | |
2439 { | |
2440 nextChar = settingsGetPointer()->customtext[i+j]; | |
2441 i++; | |
2442 if((!nextChar) || (nextChar =='\n') || (nextChar =='\r')) | |
2443 break; | |
2444 text[textptr++] = nextChar; | |
2445 } while (i < 12); | |
2446 | |
2447 if(!nextChar) | |
2448 break; | |
2449 | |
2450 if(lineCount < 3) | |
2451 { | |
2452 text[textptr++] = '\n'; | |
2453 text[textptr++] = '\r'; | |
2454 } | |
2455 lineCount++; | |
2456 for(uint8_t k=0;k<2;k++) | |
2457 { | |
2458 nextChar = settingsGetPointer()->customtext[i+j+k]; | |
2459 if((nextChar =='\n') || (nextChar =='\r')) | |
2460 i++; | |
2461 else | |
2462 break; | |
2463 } | |
2464 | |
2465 } while (lineCount < 4); | |
2466 | |
2467 text[textptr] = 0; | |
2468 return lineCount; | |
2469 } | |
2470 | |
2471 /* could be extended to search for \020 inside | |
2472 */ | |
2473 void t7_colorscheme_mod(char *text) | |
2474 { | |
2475 if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard()) | |
2476 { | |
2477 text[0] = '\027'; | |
2478 } | |
2479 } | |
2480 | |
2481 | |
2482 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide) | |
2483 { | |
2484 point_t LeftLow, WidthHeight; | |
2485 point_t start, stop; | |
2486 | |
2487 // plugin box | |
2488 LeftLow.x = CUSTOMBOX_LINE_LEFT; | |
2489 WidthHeight.x = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_LINE_LEFT; | |
2490 LeftLow.y = 60; | |
2491 WidthHeight.y = 440 - LeftLow.y; | |
2492 GFX_draw_box(&t7screen, LeftLow, WidthHeight, 1, colorBox); | |
2493 | |
2494 if(PluginBoxHeader) | |
2495 { | |
2496 // plugin box - header | |
2497 start.x = CUSTOMBOX_LINE_LEFT; | |
2498 stop.x = CUSTOMBOX_LINE_RIGHT; | |
2499 stop.y = start.y = 440 - 60; | |
2500 GFX_draw_line(&t7screen, start, stop, colorBox); | |
2501 } | |
2502 | |
2503 if(LinesOnTheSides) | |
2504 { | |
2505 // aufteilung links | |
2506 start.x = 0; | |
2507 stop.x = CUSTOMBOX_LINE_LEFT; | |
2508 stop.y = start.y = t7l1.WindowY0 - 1; | |
2509 GFX_draw_line(&t7screen, start, stop, colorLinesOnTheSide); | |
2510 stop.y = start.y = t7l2.WindowY0 -1; | |
2511 GFX_draw_line(&t7screen, start, stop, colorLinesOnTheSide); | |
2512 | |
2513 // aufteilung rechts | |
2514 start.x = CUSTOMBOX_LINE_RIGHT; | |
2515 stop.x = 799; | |
2516 stop.y = start.y = t7l1.WindowY0 - 1; | |
2517 GFX_draw_line(&t7screen, start, stop, colorLinesOnTheSide); | |
2518 stop.y = start.y = t7l2.WindowY0 - 1; | |
2519 GFX_draw_line(&t7screen, start, stop, colorLinesOnTheSide); | |
2520 } | |
2521 } | |
2522 | |
2523 | |
2524 /* Compass like TCOS shellfish | |
2525 * input is 0 to 359 | |
2526 * 2 px / 1 degree | |
2527 * Range is 148 degree with CUSTOMBOX_SPACE_INSIDE = 296 | |
2528 * one side is 74 degree (less than 90 degree) | |
2529 * internal 360 + 180 degree of freedom | |
2530 * use positive values only, shift by 360 below 90 mid position | |
2531 */ | |
2532 | |
2533 | |
2534 point_t t7_compass_circle(uint8_t id, uint16_t degree) | |
2535 { | |
2536 float fCos, fSin; | |
2537 const float piMult = ((2 * 3.14159) / 360); | |
2538 // const int radius[4] = {95,105,115,60}; | |
2539 const int radius[4] = {95,105,115,100}; | |
2540 const point_t offset = {.x = 400, .y = 250}; | |
2541 | |
2542 static point_t r[4][360] = { 0 }; | |
2543 | |
2544 if(r[0][0].y == 0) | |
2545 { | |
2546 for(int i=0;i<360;i++) | |
2547 { | |
2548 fCos = cos(i * piMult); | |
2549 fSin = sin(i * piMult); | |
2550 for(int j=0;j<4;j++) | |
2551 { | |
2552 r[j][i].x = offset.x + (int)(fSin * radius[j]); | |
2553 r[j][i].y = offset.y + (int)(fCos * radius[j]); | |
2554 } | |
2555 } | |
2556 } | |
2557 if(id > 3) id = 0; | |
2558 if(degree > 359) degree = 0; | |
2559 return r[id][degree]; | |
2560 } | |
2561 | |
2562 /* range should be 0 to 30 bar if 300 meter with 100% of nitrogen or helium | |
2563 * T24 is 28 high | |
2564 */ | |
2565 void t7_tissues(const SDiveState * pState) | |
2566 { | |
2567 point_t start, change, stop; | |
2568 float value; | |
2569 uint16_t front, cns100pixel; | |
2570 char text[256]; | |
2571 uint8_t textpointer = 0; | |
2572 uint8_t color; | |
2573 | |
2574 float percent_N2; | |
2575 float percent_He; | |
2576 float partial_pressure_N2; | |
2577 float partial_pressure_He; | |
2578 | |
2579 | |
2580 /* N2 */ | |
2581 t7cY0free.WindowLineSpacing = 28 + 48 + 14; | |
2582 t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing; | |
2583 t7cY0free.WindowNumberOfTextLines = 3; | |
2584 | |
2585 text[textpointer++] = '\030'; | |
2586 text[textpointer++] = TXT_2BYTE; | |
2587 text[textpointer++] = TXT2BYTE_Nitrogen; | |
2588 text[textpointer++] = '\n'; | |
2589 text[textpointer++] = '\r'; | |
2590 text[textpointer++] = TXT_2BYTE; | |
2591 text[textpointer++] = TXT2BYTE_Helium; | |
2592 text[textpointer++] = '\n'; | |
2593 text[textpointer++] = '\r'; | |
2594 text[textpointer++] = TXT_2BYTE; | |
2595 text[textpointer++] = TXT2BYTE_CNS; | |
2596 text[textpointer++] = 0; | |
2597 | |
2598 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
2599 | |
2600 start.y = t7cH.WindowY0 - 5; | |
2601 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
2602 stop.x = start.x + CUSTOMBOX_SPACE_INSIDE; | |
2603 | |
2604 for(int i=0;i<16;i++) | |
2605 { | |
2606 stop.y = start.y; | |
2607 change.y = start.y; | |
2608 | |
2609 value = pState->lifeData.tissue_nitrogen_bar[i] - 0.7512f; | |
2610 value *= 80;//20 | |
2611 | |
2612 if(value < 0) | |
2613 front = 0; | |
2614 else | |
2615 if(value > CUSTOMBOX_SPACE_INSIDE) | |
2616 front = CUSTOMBOX_SPACE_INSIDE; | |
2617 else | |
2618 front = (uint16_t)value; | |
2619 | |
2620 change.x = start.x + front; | |
2621 if(change.x != start.x) | |
2622 GFX_draw_thick_line(1,&t7screen, start, change, CLUT_Font030); | |
2623 if(change.x != stop.x) | |
2624 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font031); | |
2625 | |
2626 start.y -= 3; | |
2627 } | |
2628 | |
2629 /* He */ | |
2630 start.y -= 28 + 14; | |
2631 for(int i=0;i<16;i++) | |
2632 { | |
2633 stop.y = start.y; | |
2634 change.y = start.y; | |
2635 | |
2636 value = pState->lifeData.tissue_helium_bar[i]; | |
2637 value *= 80;//20 | |
2638 | |
2639 if(value < 0) | |
2640 front = 0; | |
2641 else if(value > CUSTOMBOX_SPACE_INSIDE) | |
2642 front = CUSTOMBOX_SPACE_INSIDE; | |
2643 else | |
2644 front = (uint16_t)value; | |
2645 | |
2646 change.x = start.x + front; | |
2647 if(change.x != start.x) | |
2648 GFX_draw_thick_line(1,&t7screen, start, change, CLUT_Font030); | |
2649 if(change.x != stop.x) | |
2650 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font031); | |
2651 | |
2652 start.y -= 3; | |
2653 } | |
2654 | |
2655 /* CNS == Oxygen */ | |
2656 start.y -= 28 + 14; | |
2657 | |
2658 cns100pixel = (8 * CUSTOMBOX_SPACE_INSIDE) / 10; | |
2659 value = pState->lifeData.cns; | |
2660 value *= cns100pixel; | |
2661 value /= 100; | |
2662 | |
2663 if(value < 0) | |
2664 front = 0; | |
2665 else if(value > CUSTOMBOX_SPACE_INSIDE) | |
2666 front = CUSTOMBOX_SPACE_INSIDE; | |
2667 else | |
2668 front = (uint16_t)value; | |
2669 | |
2670 if(pState->lifeData.cns < 95) | |
2671 color = CLUT_Font030; | |
2672 else if(pState->lifeData.cns < 100) | |
2673 color = CLUT_WarningYellow; | |
2674 else | |
2675 color = CLUT_WarningRed; | |
2676 | |
2677 for(int i=0;i<16;i++) | |
2678 { | |
2679 stop.y = start.y; | |
2680 change.y = start.y; | |
2681 | |
2682 change.x = start.x + front; | |
2683 if(change.x != start.x) | |
2684 GFX_draw_thick_line(1,&t7screen, start, change, color); | |
2685 if(change.x != stop.x) | |
2686 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font031); | |
2687 | |
2688 start.y -= 3; | |
2689 } | |
2690 | |
2691 /* where is the onload/offload limit for N2 and He */ | |
2692 decom_get_inert_gases(pState->lifeData.pressure_ambient_bar, &pState->lifeData.actualGas, &percent_N2, &percent_He); | |
2693 partial_pressure_N2 = (pState->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * percent_N2; | |
2694 partial_pressure_He = (pState->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * percent_He; | |
2695 | |
2696 // Nitrogen vertical bar | |
2697 start.y = t7cH.WindowY0 + 1 - 5; | |
2698 stop.y = start.y - (3 * 15) - 1; | |
2699 if((percent_N2 > 0) && (partial_pressure_N2 > 0.8f))//(0.8f + 0.5f))) | |
2700 { | |
2701 value = partial_pressure_N2; | |
2702 value *= 80;//20 | |
2703 | |
2704 if(value < 0) | |
2705 front = 3; | |
2706 else if(value + 5 > CUSTOMBOX_SPACE_INSIDE) | |
2707 front = CUSTOMBOX_SPACE_INSIDE - 3; | |
2708 else | |
2709 front = (uint16_t)value; | |
2710 } | |
2711 else | |
2712 { | |
2713 front = 1; | |
2714 } | |
2715 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + front; | |
2716 stop.x = start.x; | |
2717 GFX_draw_thick_line(2,&t7screen, start, stop, CLUT_EverythingOkayGreen); | |
2718 | |
2719 | |
2720 // Helium vertical bar | |
2721 start.y = t7cH.WindowY0 + 1 - 5 - 3*16 - 28 - 14; | |
2722 stop.y = start.y - (3 * 15) - 1; | |
2723 if((percent_He > 0) && (partial_pressure_He > 0.01f)) // 0.5f | |
2724 { | |
2725 | |
2726 value = partial_pressure_He; | |
2727 value *= 80;//20 | |
2728 | |
2729 if(value < 0) | |
2730 front = 3; | |
2731 else if(value + 5 > CUSTOMBOX_SPACE_INSIDE) | |
2732 front = CUSTOMBOX_SPACE_INSIDE - 3; | |
2733 else | |
2734 front = (uint16_t)value; | |
2735 } | |
2736 else | |
2737 { | |
2738 front = 1; | |
2739 } | |
2740 | |
2741 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + front; | |
2742 stop.x = start.x; | |
2743 GFX_draw_thick_line(2,&t7screen, start, stop, CLUT_EverythingOkayGreen); | |
2744 | |
2745 // Oxygen vertical bar | |
2746 start.y = t7cH.WindowY0 + 1 - 5 - 6*16 - 2*28 - 2*14; | |
2747 stop.y = start.y - (3 * 15) - 1; | |
2748 | |
2749 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + cns100pixel; | |
2750 stop.x = start.x; | |
2751 GFX_draw_thick_line(2, &t7screen, start, stop, CLUT_WarningRed); | |
2752 } | |
2753 | |
2754 | |
2755 void t7_debug(void) | |
2756 { | |
2757 char text[256+50]; | |
2758 uint8_t textpointer = 0; | |
2759 | |
2760 t7cY0free.WindowLineSpacing = 28 + 48 + 14; | |
2761 t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing; | |
2762 t7cY0free.WindowNumberOfTextLines = 3; | |
2763 | |
2764 textpointer += snprintf(&text[textpointer],50,"Ambient [bar]\n\r"); | |
2765 textpointer += snprintf(&text[textpointer],50,"Surface [bar] + salt\n\r"); | |
2766 // textpointer += snprintf(&text[textpointer],50,"Difference [mbar]\n\r"); | |
2767 textpointer += snprintf(&text[textpointer],50,"ShallowCounter [s]\n\r"); | |
2768 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
2769 | |
2770 t7cY0free.WindowY0 -= 52; | |
2771 // snprintf(text,60,"%0.2f\n\r%0.2f %u%%\n\r%0.0f",stateUsed->lifeData.pressure_ambient_bar, stateUsed->lifeData.pressure_surface_bar, settingsGetPointer()->salinity, 1000 * (stateUsed->lifeData.pressure_ambient_bar-stateUsed->lifeData.pressure_surface_bar)); | |
2772 snprintf(text,60, | |
2773 "%0.2f\n\r" | |
2774 "%0.2f %u%%\n\r" | |
2775 "%u" | |
2776 ,stateUsed->lifeData.pressure_ambient_bar | |
2777 ,stateUsed->lifeData.pressure_surface_bar | |
2778 ,settingsGetPointer()->salinity | |
2779 ,stateUsed->lifeData.counterSecondsShallowDepth); | |
2780 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
2781 } | |
2782 | |
2783 | |
2784 void t7_SummaryOfLeftCorner(void) | |
2785 { | |
2786 char text[256+60]; | |
2787 uint8_t textpointer = 0; | |
2788 | |
2789 const SDecoinfo * pDecoinfoStandard; | |
2790 const SDecoinfo * pDecoinfoFuture; | |
2791 float fCNS; | |
2792 | |
2793 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) | |
2794 { | |
2795 pDecoinfoStandard = &stateUsed->decolistBuehlmann; | |
2796 pDecoinfoFuture = &stateUsed->decolistFutureBuehlmann; | |
2797 } | |
2798 else | |
2799 { | |
2800 pDecoinfoStandard = &stateUsed->decolistVPM; | |
2801 pDecoinfoFuture = &stateUsed->decolistFutureVPM; | |
2802 } | |
2803 | |
2804 fCNS = stateUsed->lifeData .cns; | |
2805 if(fCNS > 999) | |
2806 fCNS = 999; | |
2807 | |
2808 t7cY0free.WindowY0 = t7cC.WindowY0 - 10; | |
2809 t7cY0free.WindowLineSpacing = 48; | |
2810 t7cY0free.WindowNumberOfTextLines = 6; | |
2811 t7cY0free.WindowTab = 420; | |
2812 | |
2813 // header | |
2814 textpointer = 0; | |
2815 text[textpointer++] = '\032'; | |
2816 text[textpointer++] = '\016'; | |
2817 text[textpointer++] = '\016'; | |
2818 text[textpointer++] = TXT_ppO2; | |
2819 text[textpointer++] = '\n'; | |
2820 text[textpointer++] = '\r'; | |
2821 text[textpointer++] = TXT_Ceiling; | |
2822 text[textpointer++] = '\n'; | |
2823 text[textpointer++] = '\r'; | |
2824 text[textpointer++] = TXT_ActualGradient; | |
2825 text[textpointer++] = '\n'; | |
2826 text[textpointer++] = '\r'; | |
2827 text[textpointer++] = TXT_CNS; | |
2828 text[textpointer++] = '\n'; | |
2829 text[textpointer++] = '\r'; | |
2830 text[textpointer++] = TXT_FutureTTS; | |
2831 text[textpointer++] = '\017'; | |
2832 text[textpointer++] = 0; | |
2833 t7cY0free.WindowX0 += 10; | |
2834 t7cY0free.WindowY0 += 10; | |
2835 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
2836 t7cY0free.WindowX0 -= 10; | |
2837 t7cY0free.WindowY0 -= 10; | |
2838 | |
2839 textpointer = 0; | |
2840 text[textpointer++] = '\t'; | |
2841 textpointer += snprintf(&text[textpointer],10,"\020%01.2f", stateUsed->lifeData.ppO2); | |
2842 text[textpointer++] = '\n'; | |
2843 text[textpointer++] = '\r'; | |
2844 text[textpointer++] = '\t'; | |
2845 if((pDecoinfoStandard->output_ceiling_meter > 99.9f) || (settingsGetPointer()->nonMetricalSystem)) | |
2846 textpointer += snprintf(&text[textpointer],10,"\020%01.1f",unit_depth_float(pDecoinfoStandard->output_ceiling_meter)); | |
2847 else | |
2848 textpointer += snprintf(&text[textpointer],10,"\020%01.0f",pDecoinfoStandard->output_ceiling_meter); | |
2849 text[textpointer++] = '\n'; | |
2850 text[textpointer++] = '\r'; | |
2851 text[textpointer++] = '\t'; | |
2852 textpointer += snprintf(&text[textpointer],10,"\020%.0f", 100 * pDecoinfoStandard->output_relative_gradient); | |
2853 text[textpointer++] = '\n'; | |
2854 text[textpointer++] = '\r'; | |
2855 text[textpointer++] = '\t'; | |
2856 textpointer += snprintf(&text[textpointer],10,"\020%.0f\016\016%%\017",fCNS); | |
2857 text[textpointer++] = '\n'; | |
2858 text[textpointer++] = '\r'; | |
2859 text[textpointer++] = '\t'; | |
2860 textpointer += snprintf(&text[textpointer],10,"\020%i'", pDecoinfoFuture->output_time_to_surface_seconds / 60); | |
2861 text[textpointer++] = 0; | |
2862 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
2863 } | |
2864 | |
2865 | |
2866 void t7_scooter(void) | |
2867 { | |
2868 float scooterTemperatureLocal; | |
2869 uint16_t scooterSpeedLocal; | |
2870 // uint16_t scooterDrehzhl; | |
2871 uint8_t scooterResidualCapacity; | |
2872 // float scooterVoltage; | |
2873 // uint8_t scooterCurrent; | |
2874 //uint16_t scooterWattHours; | |
2875 // uint16_t bkpX0, bkpX1; | |
2876 uint16_t ageInMilliSeconds; | |
2877 | |
2878 uint8_t textSize; | |
2879 | |
2880 scooterTemperatureLocal = unit_temperature_float(((float)(stateUsed->lifeData.scooterTemperature)) / 10.0f); | |
2881 scooterSpeedLocal = unit_speed_integer(stateUsed->lifeData.scooterSpeed); | |
2882 scooterResidualCapacity = stateUsed_scooterRemainingBattCapacity(); | |
2883 | |
2884 // scooterDrehzhl = stateUsed->lifeData.scooterDrehzahl; | |
2885 // scooterVoltage = stateUsed->lifeData.scooterSpannung; | |
2886 // scooterCurrent = stateUsed->lifeData.scooterAmpere; | |
2887 // scooterWattHours = stateUsed->lifeData.scooterWattstunden; | |
2888 | |
2889 ageInMilliSeconds = stateUsed->lifeData.scooterAgeInMilliSeconds; | |
2890 if(!ageInMilliSeconds) | |
2891 ageInMilliSeconds = 9999; | |
2892 | |
2893 char text[256+60]; | |
2894 uint8_t textpointer = 0; | |
2895 | |
2896 t7cY0free.WindowLineSpacing = 28 + 48 + 14; | |
2897 t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing; | |
2898 t7cY0free.WindowNumberOfTextLines = 3; | |
2899 | |
2900 // header | |
2901 // text[textpointer++] = '\032'; | |
2902 text[textpointer++] = TXT_2BYTE; | |
2903 text[textpointer++] = TXT2BYTE_ScooterRestkapazitaet; | |
2904 text[textpointer++] = '\n'; | |
2905 text[textpointer++] = '\r'; | |
2906 text[textpointer++] = TXT_2BYTE; | |
2907 text[textpointer++] = TXT2BYTE_ScooterTemperature; | |
2908 text[textpointer++] = '\n'; | |
2909 text[textpointer++] = '\r'; | |
2910 text[textpointer++] = TXT_2BYTE; | |
2911 text[textpointer++] = TXT2BYTE_ScooterSpeed; | |
2912 text[textpointer++] = 0; | |
2913 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
2914 | |
2915 /* | |
2916 snprintf(text,60, | |
2917 "\032" | |
2918 "%0u" "\016\016 Wh used\017" | |
2919 ,stateUsed->lifeData.scooterWattstunden); | |
2920 */ | |
2921 | |
2922 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
2923 | |
2924 /* | |
2925 snprintf(text,60, | |
2926 "\030" | |
2927 "\n\r" | |
2928 "\n\r" | |
2929 "%0u" "\022\016\016 rpm\017\030" | |
2930 ,stateUsed->lifeData.scooterDrehzahl); | |
2931 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
2932 */ | |
2933 // data | |
2934 t7cY0free.WindowY0 -= 52; | |
2935 if(settingsGetPointer()->nonMetricalSystem == 0) | |
2936 { | |
2937 textSize = snprintf(text,60, | |
2938 "\030" | |
2939 "%0u" "\022\016\016 %%\017\030" | |
2940 "\n\r" | |
2941 "%0.0f\140" "\022\016\016 C\017\030" | |
2942 "\n\r" | |
2943 "%u" "\022\016\016 m/min\017\030" | |
2944 ,scooterResidualCapacity,scooterTemperatureLocal,scooterSpeedLocal); | |
2945 } | |
2946 else | |
2947 { | |
2948 textSize = snprintf(text,60, | |
2949 "\030" | |
2950 "%0u" "\022\016\016 %%\017\030" | |
2951 "\n\r" | |
2952 "%0.0f\140" "\022\016\016 Fht\017\030" | |
2953 "\n\r" | |
2954 "%u" "\022\016\016 ft/min\017\030" | |
2955 ,scooterResidualCapacity,scooterTemperatureLocal,scooterSpeedLocal); | |
2956 } | |
2957 // connection active | |
2958 if(ageInMilliSeconds > 1500) | |
2959 { | |
2960 for(int i=0; i < textSize -2; i++) | |
2961 { | |
2962 if(text[i] == '\030') | |
2963 text[i] = '\031'; | |
2964 } | |
2965 } | |
2966 // write data | |
2967 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
2968 | |
2969 // age stamp | |
2970 if(ageInMilliSeconds < 9999) | |
2971 { | |
2972 t7cY0free.WindowY0 -= 30; | |
2973 snprintf(text,60, | |
2974 "\021\001%u" | |
2975 ,ageInMilliSeconds); | |
2976 GFX_write_string(&FontT24, &t7cY0free, text, 0); | |
2977 } | |
2978 } | |
2979 | |
2980 | |
2981 void t7_scooter_May2016_01(void) | |
2982 { | |
2983 float scooterTemperature; | |
2984 uint16_t scooterDrehzhl; | |
2985 uint8_t scooterResidualCapacity; | |
2986 float scooterSpeed; | |
2987 float scooterVoltage; | |
2988 uint8_t scooterCurrent; | |
2989 // uint16_t scooterWattHours; | |
2990 uint16_t bkpX0, bkpX1; | |
2991 | |
2992 uint16_t ageInMilliSeconds; | |
2993 uint8_t textSize; | |
2994 // old scooterStatus = bC_getData(0,&scooterTemperature,&scooterDrehzhl,&scooterResidualCapacity); | |
2995 | |
2996 scooterDrehzhl = stateUsed->lifeData.scooterDrehzahl; | |
2997 scooterTemperature = ((float)(stateUsed->lifeData.scooterTemperature)) / 10.0f; | |
2998 scooterResidualCapacity = stateUsed_scooterRemainingBattCapacity(); | |
2999 | |
3000 scooterVoltage = stateUsed->lifeData.scooterSpannung; | |
3001 scooterCurrent = stateUsed->lifeData.scooterAmpere; | |
3002 // scooterWattHours = stateUsed->lifeData.scooterWattstunden; | |
3003 | |
3004 ageInMilliSeconds = stateUsed->lifeData.scooterAgeInMilliSeconds; | |
3005 | |
3006 scooterSpeed = scooterDrehzhl * 80 / 3300; | |
3007 | |
3008 char text[256+60]; | |
3009 | |
3010 t7cY0free.WindowLineSpacing = (28 + 48 + 14)/2; | |
3011 t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 5 * t7cY0free.WindowLineSpacing; | |
3012 t7cY0free.WindowNumberOfTextLines = 6; | |
3013 | |
3014 t7cY0free.WindowY0 -= 7; | |
3015 | |
3016 bkpX0 = t7cY0free.WindowX0; | |
3017 bkpX1 = t7cY0free.WindowX1; | |
3018 t7cY0free.WindowX0 = 430; | |
3019 | |
3020 textSize = snprintf(text,120, | |
3021 "\022\016\016" | |
3022 "%%" | |
3023 "\n\r" | |
3024 "celsius" | |
3025 "\n\r" | |
3026 "rpm" | |
3027 "\n\r" | |
3028 "m/min" | |
3029 "\n\r" | |
3030 "Ampere" | |
3031 "\n\r" | |
3032 "Volt" | |
3033 // "\n\r" | |
3034 // "Wh" | |
3035 ); | |
3036 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
3037 | |
3038 t7cY0free.WindowX0 = bkpX0; | |
3039 t7cY0free.WindowX1 = 420; | |
3040 | |
3041 textSize = snprintf(text,120, | |
3042 "\030" | |
3043 "\002" | |
3044 "%0u" | |
3045 "\n\r" | |
3046 "\002" | |
3047 "%0.0f" | |
3048 "\n\r" | |
3049 "\002" | |
3050 "%0u" | |
3051 "\n\r" | |
3052 "\002" | |
3053 "%0.0f" | |
3054 "\n\r" | |
3055 "\002" | |
3056 "%0u" | |
3057 "\n\r" | |
3058 "\002" | |
3059 "%0.1f" | |
3060 // "\n\r" | |
3061 // "%0u" "\022\016\016 Wh\017\030" | |
3062 ,scooterResidualCapacity,scooterTemperature,scooterDrehzhl,scooterSpeed | |
3063 ,scooterCurrent,scooterVoltage);//,scooterWattHours); | |
3064 | |
3065 if((ageInMilliSeconds > 1500) || (stateUsed->lifeData.scooterType == 0xFF)) | |
3066 { | |
3067 for(int i=0; i < textSize -2; i++) | |
3068 { | |
3069 if(text[i] == '\030') | |
3070 text[i] = '\031'; | |
3071 } | |
3072 } | |
3073 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
3074 | |
3075 t7cY0free.WindowX0 = bkpX0; | |
3076 t7cY0free.WindowX1 = bkpX1; | |
3077 | |
3078 t7cY0free.WindowY0 -= 30; | |
3079 snprintf(text,60, | |
3080 "\021\001%u" | |
3081 ,ageInMilliSeconds); | |
3082 GFX_write_string(&FontT24, &t7cY0free, text, 0); | |
3083 | |
3084 } | |
3085 | |
3086 void t7_scooter_alt(void) | |
3087 { | |
3088 float scooterTemperature; | |
3089 uint16_t scooterDrehzhl; | |
3090 uint8_t scooterStatus; | |
3091 uint8_t scooterResidualCapacity; | |
3092 float scooterSpeed; | |
3093 uint16_t ageInMilliSeconds; | |
3094 uint8_t textSize; | |
3095 // old scooterStatus = bC_getData(0,&scooterTemperature,&scooterDrehzhl,&scooterResidualCapacity); | |
3096 | |
3097 scooterStatus = 2;//BC_CONNECTED; | |
3098 scooterDrehzhl = stateUsed->lifeData.scooterDrehzahl; | |
3099 scooterTemperature = ((float)(stateUsed->lifeData.scooterTemperature)) / 10.0f; | |
3100 scooterResidualCapacity = stateUsed_scooterRemainingBattCapacity(); | |
3101 ageInMilliSeconds = stateUsed->lifeData.scooterAgeInMilliSeconds; | |
3102 if(!ageInMilliSeconds) | |
3103 ageInMilliSeconds = 9999; | |
3104 | |
3105 scooterSpeed = scooterDrehzhl * 80 / 3300; | |
3106 | |
3107 char text[256+60]; | |
3108 uint8_t textpointer = 0; | |
3109 | |
3110 //float percent_N2; | |
3111 //float percent_He; | |
3112 //float partial_pressure_N2; | |
3113 //float partial_pressure_He; | |
3114 | |
3115 t7cY0free.WindowLineSpacing = 28 + 48 + 14; | |
3116 t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing; | |
3117 t7cY0free.WindowNumberOfTextLines = 3; | |
3118 | |
3119 text[textpointer++] = '\032'; | |
3120 text[textpointer++] = TXT_2BYTE; | |
3121 text[textpointer++] = TXT2BYTE_ScooterRestkapazitaet; | |
3122 text[textpointer++] = '\n'; | |
3123 text[textpointer++] = '\r'; | |
3124 text[textpointer++] = TXT_2BYTE; | |
3125 text[textpointer++] = TXT2BYTE_ScooterTemperature; | |
3126 text[textpointer++] = '\n'; | |
3127 text[textpointer++] = '\r'; | |
3128 text[textpointer++] = TXT_2BYTE; | |
3129 text[textpointer++] = TXT2BYTE_ScooterSpeed; | |
3130 text[textpointer++] = 0; | |
3131 | |
3132 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
3133 | |
3134 if(scooterStatus == 2)//BC_CONNECTED) | |
3135 { | |
3136 t7cY0free.WindowY0 -= 52; | |
3137 textSize = snprintf(text,60, | |
3138 "\030" | |
3139 "%0u" "\022\016\016 %%\017\030" | |
3140 "\n\r" | |
3141 "%0.0f\140" "\022\016\016 celsius\017\030" | |
3142 "\n\r" | |
3143 "%0.0f" "\022\016\016 m/min\017\030" | |
3144 ,scooterResidualCapacity,scooterTemperature,scooterSpeed); | |
3145 | |
3146 if(ageInMilliSeconds > 1500) | |
3147 { | |
3148 for(int i=0; i < textSize -2; i++) | |
3149 { | |
3150 if(text[i] == '\030') | |
3151 text[i] = '\031'; | |
3152 } | |
3153 } | |
3154 // snprintf(text,60,"\031%0.2f\n\r%0.2f\n\r%u",scooterWatt,scooterTemperature,scooterDrehzhl); | |
3155 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
3156 | |
3157 t7cY0free.WindowY0 -= 30; | |
3158 snprintf(text,60, | |
3159 "\021\001%u" | |
3160 ,ageInMilliSeconds); | |
3161 GFX_write_string(&FontT24, &t7cY0free, text, 0); | |
3162 | |
3163 } | |
3164 } | |
3165 | |
3166 | |
3167 /* | |
3168 point_t start, change, stop; | |
3169 float value; | |
3170 uint16_t front; | |
3171 uint8_t color; | |
3172 | |
3173 | |
3174 start.y = t7cH.WindowY0 - 5; | |
3175 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
3176 stop.x = start.x + CUSTOMBOX_SPACE_INSIDE; | |
3177 | |
3178 | |
3179 for(int i=0;i<16;i++) | |
3180 { | |
3181 stop.y = start.y; | |
3182 change.y = start.y; | |
3183 | |
3184 value = pState->lifeData.tissue_nitrogen_bar[i] - 0.7512f; | |
3185 value *= 20; | |
3186 | |
3187 if(value < 0) | |
3188 front = 0; | |
3189 else | |
3190 if(value > CUSTOMBOX_SPACE_INSIDE) | |
3191 front = CUSTOMBOX_SPACE_INSIDE; | |
3192 else | |
3193 front = (uint16_t)value; | |
3194 | |
3195 change.x = start.x + front; | |
3196 if(change.x != start.x) | |
3197 GFX_draw_thick_line(1,&t7screen, start, change, CLUT_Font020); | |
3198 if(change.x != stop.x) | |
3199 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font021); | |
3200 | |
3201 start.y -= 3; | |
3202 } | |
3203 | |
3204 // He | |
3205 start.y -= 28 + 14; | |
3206 for(int i=0;i<16;i++) | |
3207 { | |
3208 stop.y = start.y; | |
3209 change.y = start.y; | |
3210 | |
3211 value = pState->lifeData.tissue_helium_bar[i]; | |
3212 value *= 20; | |
3213 | |
3214 if(value < 0) | |
3215 front = 0; | |
3216 else | |
3217 if(value > CUSTOMBOX_SPACE_INSIDE) | |
3218 front = CUSTOMBOX_SPACE_INSIDE; | |
3219 else | |
3220 front = (uint16_t)value; | |
3221 | |
3222 change.x = start.x + front; | |
3223 if(change.x != start.x) | |
3224 GFX_draw_thick_line(1,&t7screen, start, change, CLUT_Font020); | |
3225 if(change.x != stop.x) | |
3226 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font021); | |
3227 | |
3228 start.y -= 3; | |
3229 } | |
3230 | |
3231 // CNS == Oxygen | |
3232 start.y -= 28 + 14; | |
3233 | |
3234 value = pState->lifeData.cns; | |
3235 value *= (CUSTOMBOX_SPACE_INSIDE/2); | |
3236 value /= 100; | |
3237 | |
3238 if(value < 0) | |
3239 front = 0; | |
3240 else | |
3241 if(value > CUSTOMBOX_SPACE_INSIDE) | |
3242 front = CUSTOMBOX_SPACE_INSIDE; | |
3243 else | |
3244 front = (uint16_t)value; | |
3245 | |
3246 if(pState->lifeData.cns < 95) | |
3247 color = CLUT_Font020; | |
3248 else | |
3249 if(pState->lifeData.cns < 100) | |
3250 color = CLUT_WarningYellow; | |
3251 else | |
3252 color = CLUT_WarningRed; | |
3253 | |
3254 for(int i=0;i<16;i++) | |
3255 { | |
3256 stop.y = start.y; | |
3257 change.y = start.y; | |
3258 | |
3259 change.x = start.x + front; | |
3260 if(change.x != start.x) | |
3261 GFX_draw_thick_line(1,&t7screen, start, change, color); | |
3262 if(change.x != stop.x) | |
3263 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font021); | |
3264 | |
3265 start.y -= 3; | |
3266 } | |
3267 | |
3268 // where is the onload/offload limit for N2 and He | |
3269 decom_get_inert_gases(pState->lifeData.pressure_ambient_bar, &pState->lifeData.actualGas, &percent_N2, &percent_He); | |
3270 partial_pressure_N2 = (pState->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * percent_N2; | |
3271 partial_pressure_He = (pState->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * percent_He; | |
3272 | |
3273 if((percent_N2 > 0) && (partial_pressure_N2 > (0.8f + 0.5f))) | |
3274 { | |
3275 start.y = t7cH.WindowY0 + 1 - 5; | |
3276 stop.y = start.y - (3 * 15) - 1; | |
3277 | |
3278 value = partial_pressure_N2; | |
3279 value *= 20; | |
3280 | |
3281 if(value < 0) | |
3282 front = 3; | |
3283 else | |
3284 if(value + 5 > CUSTOMBOX_SPACE_INSIDE) | |
3285 front = CUSTOMBOX_SPACE_INSIDE - 3; | |
3286 else | |
3287 front = (uint16_t)value; | |
3288 | |
3289 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + front; | |
3290 stop.x = start.x; | |
3291 GFX_draw_thick_line(2,&t7screen, start, stop, CLUT_EverythingOkayGreen); | |
3292 } | |
3293 | |
3294 if((percent_He > 0) && (partial_pressure_He > 0.5f)) | |
3295 { | |
3296 start.y = t7cH.WindowY0 + 1 - 5 - 3*16 - 28 - 14; | |
3297 stop.y = start.y - (3 * 15) - 1; | |
3298 | |
3299 value = partial_pressure_He; | |
3300 value *= 20; | |
3301 | |
3302 if(value < 0) | |
3303 front = 3; | |
3304 else | |
3305 if(value + 5 > CUSTOMBOX_SPACE_INSIDE) | |
3306 front = CUSTOMBOX_SPACE_INSIDE - 3; | |
3307 else | |
3308 front = (uint16_t)value; | |
3309 | |
3310 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + front; | |
3311 stop.x = start.x; | |
3312 GFX_draw_thick_line(2,&t7screen, start, stop, CLUT_EverythingOkayGreen); | |
3313 } | |
3314 | |
3315 start.y = t7cH.WindowY0 + 1 - 5 - 6*16 - 2*28 - 2*14; | |
3316 stop.y = start.y - (3 * 15) - 1; | |
3317 | |
3318 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_SPACE_INSIDE/2; | |
3319 stop.x = start.x; | |
3320 GFX_draw_thick_line(2, &t7screen, start, stop, CLUT_WarningRed); | |
3321 */ | |
3322 | |
3323 /* | |
3324 void t7_clock(void) | |
3325 { | |
3326 point_t start, stop; | |
3327 | |
3328 | |
3329 for(uint16_t i=0;i<360;i+=30) | |
3330 { | |
3331 start = t7_compass_circle(1,i); | |
3332 stop = t7_compass_circle(2,i); | |
3333 start.x += 280; // standard center is 400, 250 | |
3334 stop.x += 280; | |
3335 GFX_draw_thick_line(5,&t7screen, start, stop, CLUT_CompassSubTick); | |
3336 | |
3337 start.x = 400+280; | |
3338 start.y = 250; | |
3339 stop = t7_compass_circle(2,58); | |
3340 stop.x += 280; | |
3341 GFX_draw_thick_line(3,&t7screen, start, stop, CLUT_CompassNorthTick); | |
3342 stop = t7_compass_circle(0,302); | |
3343 stop.x += 280; | |
3344 GFX_draw_thick_line(3,&t7screen, start, stop, CLUT_CompassNorthTick); | |
3345 } | |
3346 } | |
3347 */ | |
3348 | |
3349 //static float testCC = 180; | |
3350 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading) | |
3351 { | |
3352 | |
3353 /* | |
3354 static uint16_t lastHeading = 0; | |
3355 float differenceCompass, resultKalman; | |
3356 | |
3357 if(testCC > lastHeading) | |
3358 differenceCompass = testCC - lastHeading; | |
3359 else | |
3360 differenceCompass = lastHeading - testCC; | |
3361 | |
3362 resultKalman = Kalman_getAngle(differenceCompass, 2, 0.1); | |
3363 if(testCC > lastHeading) | |
3364 ActualHeading = lastHeading + resultKalman; | |
3365 else | |
3366 ActualHeading = lastHeading - resultKalman; | |
3367 | |
3368 lastHeading = ActualHeading; | |
3369 */ | |
3370 uint16_t LeftBorderHeading, LineHeading; | |
3371 uint32_t offsetPicture; | |
3372 point_t start, stop, center; | |
3373 static int32_t LastHeading = 0; | |
3374 int32_t newHeading = 0; | |
3375 int32_t diff = 0; | |
3376 int32_t diff2 = 0; | |
3377 | |
3378 int32_t diffAbs = 0; | |
3379 int32_t diffAbs2 = 0; | |
3380 | |
3381 newHeading = ActualHeading; | |
3382 | |
3383 diff = newHeading - LastHeading; | |
3384 | |
3385 if(newHeading < LastHeading) | |
3386 diff2 = newHeading + 360 - LastHeading; | |
3387 else | |
3388 diff2 = newHeading - 360 - LastHeading; | |
3389 | |
3390 diffAbs = diff; | |
3391 if(diffAbs < 0) | |
3392 diffAbs *= -1; | |
3393 | |
3394 diffAbs2 = diff2; | |
3395 if(diffAbs2 < 0) | |
3396 diffAbs2 *= -1; | |
3397 | |
3398 | |
3399 if(diffAbs <= diffAbs2) | |
3400 newHeading = LastHeading + (diff / 2); | |
3401 else | |
3402 newHeading = LastHeading + (diff2 / 2); | |
3403 | |
3404 if(newHeading < 0) | |
3405 newHeading += 360; | |
3406 else | |
3407 if(newHeading >= 360) | |
3408 newHeading -= 360; | |
3409 | |
3410 LastHeading = newHeading; | |
3411 ActualHeading = newHeading; | |
3412 /* | |
3413 if (ActualHeading < 90) | |
3414 ActualHeading += 360; | |
3415 | |
3416 if(ActualHeading > LastHeading) | |
3417 { | |
3418 if((ActualHeading - LastHeading) < 25) | |
3419 ActualHeading = LastHeading + 1; | |
3420 } | |
3421 else | |
3422 if(ActualHeading < LastHeading) | |
3423 { | |
3424 if((LastHeading - ActualHeading) < 25) | |
3425 ActualHeading = LastHeading - 1; | |
3426 } | |
3427 */ | |
3428 if (ActualHeading < 90) | |
3429 ActualHeading += 360; | |
3430 | |
3431 // new hw 160822 | |
3432 // if (ActualHeading >= 360 + 90) | |
3433 // ActualHeading = 360; | |
3434 | |
3435 LeftBorderHeading = 2 * (ActualHeading - (CUSTOMBOX_SPACE_INSIDE/4)); | |
3436 | |
3437 offsetPicture = LeftBorderHeading * t7screenCompass.ImageHeight * 2; | |
3438 | |
3439 background.pointer = t7screenCompass.FBStartAdress+offsetPicture; | |
3440 background.x0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
3441 background.y0 = 65; | |
3442 background.width = CUSTOMBOX_SPACE_INSIDE; | |
3443 background.height = t7screenCompass.ImageHeight; | |
3444 | |
3445 | |
3446 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + (CUSTOMBOX_SPACE_INSIDE/2); | |
3447 stop.x = start.x; | |
3448 start.y = 65; | |
3449 stop.y = start.y + 55; | |
3450 GFX_draw_line(&t7screen, start, stop, CLUT_Font030); | |
3451 | |
3452 | |
3453 center.x = start.x; | |
3454 center.y = 300; | |
3455 | |
3456 stop.x = center.x + 44; | |
3457 stop.y = center.y + 24; | |
3458 | |
3459 | |
3460 while(ActualHeading > 359) ActualHeading -= 360; | |
3461 | |
3462 LineHeading = 360 - ActualHeading; | |
3463 GFX_draw_thick_line(9,&t7screen, t7_compass_circle(0,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font030); // North | |
3464 LineHeading += 90; | |
3465 if(LineHeading > 359) LineHeading -= 360; | |
3466 GFX_draw_thick_line(9,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); // Maintick | |
3467 LineHeading += 90; | |
3468 if(LineHeading > 359) LineHeading -= 360; | |
3469 GFX_draw_thick_line(9,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3470 LineHeading += 90; | |
3471 if(LineHeading > 359) LineHeading -= 360; | |
3472 GFX_draw_thick_line(9,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3473 | |
3474 LineHeading = 360 - ActualHeading; | |
3475 LineHeading += 45; | |
3476 if(LineHeading > 359) LineHeading -= 360; | |
3477 GFX_draw_thick_line(5,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); // Subtick | |
3478 LineHeading += 90; | |
3479 if(LineHeading > 359) LineHeading -= 360; | |
3480 GFX_draw_thick_line(5,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3481 LineHeading += 90; | |
3482 if(LineHeading > 359) LineHeading -= 360; | |
3483 GFX_draw_thick_line(5,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3484 LineHeading += 90; | |
3485 if(LineHeading > 359) LineHeading -= 360; | |
3486 GFX_draw_thick_line(5,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3487 | |
3488 LineHeading = 360 - ActualHeading; | |
3489 LineHeading += 22; | |
3490 if(LineHeading > 359) LineHeading -= 360; | |
3491 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); // Subtick | |
3492 LineHeading += 45; | |
3493 if(LineHeading > 359) LineHeading -= 360; | |
3494 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3495 LineHeading += 45; | |
3496 if(LineHeading > 359) LineHeading -= 360; | |
3497 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3498 LineHeading += 45; | |
3499 if(LineHeading > 359) LineHeading -= 360; | |
3500 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3501 LineHeading += 45; | |
3502 if(LineHeading > 359) LineHeading -= 360; | |
3503 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); // Subtick | |
3504 LineHeading += 45; | |
3505 if(LineHeading > 359) LineHeading -= 360; | |
3506 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3507 LineHeading += 45; | |
3508 if(LineHeading > 359) LineHeading -= 360; | |
3509 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3510 LineHeading += 45; | |
3511 if(LineHeading > 359) LineHeading -= 360; | |
3512 GFX_draw_thick_line(3,&t7screen, t7_compass_circle(1,LineHeading), t7_compass_circle(2,LineHeading), CLUT_Font031); | |
3513 | |
3514 if(UserSetHeading) | |
3515 { | |
3516 LineHeading = UserSetHeading + 360 - ActualHeading; | |
3517 if(LineHeading > 359) LineHeading -= 360; | |
3518 GFX_draw_thick_line(9,&t7screen, t7_compass_circle(3,LineHeading), t7_compass_circle(2,LineHeading), CLUT_CompassUserHeadingTick); | |
3519 | |
3520 // R�ckpeilung, User Back Heading | |
3521 LineHeading = UserSetHeading + 360 + 180 - ActualHeading; | |
3522 if(LineHeading > 359) LineHeading -= 360; | |
3523 if(LineHeading > 359) LineHeading -= 360; | |
3524 GFX_draw_thick_line(9,&t7screen, t7_compass_circle(3,LineHeading), t7_compass_circle(2,LineHeading), CLUT_CompassUserBackHeadingTick); | |
3525 } | |
3526 | |
3527 center.x = start.x; | |
3528 center.y = 250; | |
3529 GFX_draw_circle(&t7screen, center, 116, CLUT_Font030); | |
3530 GFX_draw_circle(&t7screen, center, 118, CLUT_Font030); | |
3531 GFX_draw_circle(&t7screen, center, 117, CLUT_Font030); | |
3532 | |
3533 | |
3534 } | |
3535 | |
3536 | |
3537 /* Font_T42: N is 27 px, S is 20 px, W is 36 px, E is 23 px | |
3538 * max is NW with 63 px | |
3539 * Font_T24: N is 15 px, S is 12 px, W is 20 px, E is 13 px | |
3540 * max is NW with 35 px | |
3541 * NE is 28 px | |
3542 * SW is 32 px | |
3543 * SE is 25 px | |
3544 * space between each is 45 px * 2 | |
3545 * FirstItem List | |
3546 * \177 \177 prepare for size | |
3547 */ | |
3548 void init_t7_compass(void) | |
3549 { | |
3550 t7screenCompass.FBStartAdress = getFrame(21); | |
3551 | |
3552 char text[256]; | |
3553 uint8_t textpointer = 0; | |
3554 | |
3555 text[textpointer++] = '\030'; | |
3556 text[textpointer++] = '\177'; | |
3557 text[textpointer++] = '\177'; | |
3558 text[textpointer++] = 76; // 90 - 14 | |
3559 text[textpointer++] = '\016'; | |
3560 text[textpointer++] = '\016'; | |
3561 text[textpointer++] = 'N'; | |
3562 text[textpointer++] = 'E'; // 96 + 28 = 124 total | |
3563 text[textpointer++] = '\017'; | |
3564 text[textpointer++] = '\177'; | |
3565 text[textpointer++] = '\177'; | |
3566 text[textpointer++] = 64; // 90 - 14 - 12 | |
3567 text[textpointer++] = 'E'; // 124 + 74 + 23 = 221 total | |
3568 text[textpointer++] = '\177'; | |
3569 text[textpointer++] = '\177'; | |
3570 text[textpointer++] = 66; // 90 - 11 - 13 | |
3571 text[textpointer++] = '\016'; | |
3572 text[textpointer++] = '\016'; | |
3573 text[textpointer++] = 'S'; | |
3574 text[textpointer++] = 'E'; | |
3575 text[textpointer++] = '\017'; | |
3576 text[textpointer++] = '\177'; | |
3577 text[textpointer++] = '\177'; | |
3578 text[textpointer++] = 68; // 90 - 12 - 10 | |
3579 text[textpointer++] = 'S'; | |
3580 text[textpointer++] = '\177'; | |
3581 text[textpointer++] = '\177'; | |
3582 text[textpointer++] = 64; // 90 - 10 - 16 | |
3583 text[textpointer++] = '\016'; | |
3584 text[textpointer++] = '\016'; | |
3585 text[textpointer++] = 'S'; | |
3586 text[textpointer++] = 'W'; | |
3587 text[textpointer++] = '\017'; | |
3588 text[textpointer++] = '\177'; | |
3589 text[textpointer++] = '\177'; | |
3590 text[textpointer++] = 56; // 90 - 16 - 18 | |
3591 text[textpointer++] = 'W'; | |
3592 text[textpointer++] = '\177'; | |
3593 text[textpointer++] = '\177'; | |
3594 text[textpointer++] = 54; // 90 - 18 - 18 | |
3595 text[textpointer++] = '\016'; | |
3596 text[textpointer++] = '\016'; | |
3597 text[textpointer++] = 'N'; | |
3598 text[textpointer++] = 'W'; | |
3599 text[textpointer++] = '\017'; | |
3600 text[textpointer++] = '\177'; | |
3601 text[textpointer++] = '\177'; | |
3602 text[textpointer++] = 59; // 90 - 17 - 14 | |
3603 text[textpointer++] = 'N'; | |
3604 text[textpointer++] = '\177'; | |
3605 text[textpointer++] = '\177'; | |
3606 text[textpointer++] = 63; // 90 - 13 - 14 | |
3607 text[textpointer++] = '\016'; | |
3608 text[textpointer++] = '\016'; | |
3609 text[textpointer++] = 'N'; | |
3610 text[textpointer++] = 'E'; | |
3611 text[textpointer++] = '\017'; | |
3612 text[textpointer++] = '\177'; | |
3613 text[textpointer++] = '\177'; | |
3614 text[textpointer++] = 64; // 90 - 14 - 12 | |
3615 text[textpointer++] = 'E'; | |
3616 text[textpointer++] = '\177'; | |
3617 text[textpointer++] = '\177'; | |
3618 text[textpointer++] = 66; // 90 - 11 - 13 | |
3619 text[textpointer++] = '\016'; | |
3620 text[textpointer++] = '\016'; | |
3621 text[textpointer++] = 'S'; | |
3622 text[textpointer++] = 'E'; | |
3623 text[textpointer++] = '\017'; | |
3624 text[textpointer++] = '\177'; | |
3625 text[textpointer++] = '\177'; | |
3626 text[textpointer++] = 68; // 90 - 12 - 10 | |
3627 text[textpointer++] = 'S'; | |
3628 text[textpointer++] = '\177'; | |
3629 text[textpointer++] = '\177'; | |
3630 text[textpointer++] = 64; // 90 - 10 - 16 | |
3631 text[textpointer++] = '\016'; | |
3632 text[textpointer++] = '\016'; | |
3633 text[textpointer++] = 'S'; | |
3634 text[textpointer++] = 'W'; | |
3635 text[textpointer++] = '\017'; | |
3636 text[textpointer++] = 0; // end | |
3637 | |
3638 GFX_write_string(&FontT42,&t7pCompass,text,1); | |
3639 | |
3640 releaseAllFramesExcept(21,t7screenCompass.FBStartAdress); | |
3641 } | |
3642 | |
3643 | |
3644 void t7_miniLiveLogProfile(void) | |
3645 { | |
3646 SWindowGimpStyle wintemp; | |
3647 wintemp.left = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
3648 wintemp.right = wintemp.left + CUSTOMBOX_SPACE_INSIDE; | |
3649 wintemp.top = 480 - t7l1.WindowY0; | |
3650 wintemp.bottom = wintemp. top + 200; | |
3651 | |
3652 uint16_t max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 10); | |
3653 | |
3654 GFX_graph_print(&t7screen, &wintemp, 0,1,0, max_depth, getMiniLiveLogbookPointerToData(), getMiniLiveLogbookActualDataLength(), CLUT_Font030, NULL); | |
3655 } | |
3656 | |
3657 void t7_logo_OSTC(void) | |
3658 { | |
3659 SWindowGimpStyle windowGimp; | |
3660 /* OSTC logo */ | |
3661 windowGimp.left = t7l1.WindowX1 + 32; | |
3662 windowGimp.top = 40 + 32; | |
3663 GFX_draw_image_monochrome(&t7screen, windowGimp, &ImgOSTC, 0); | |
3664 } |