Mercurial > public > ostc4
annotate Discovery/Src/show_logbook.c @ 104:22a1094545f3 kittz
Tested and alive.
author | Dmitry Romanov <kitt@bk.ru> |
---|---|
date | Mon, 24 Dec 2018 16:15:02 +0300 |
parents | 4276d56eb37c |
children | 3834b6272ee5 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/show_logbook.c | |
5 /// \brief show_logbook_logbook_show_log_page1 / | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 07-July-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 #include "base.h" | |
30 #include "logbook.h" | |
31 #include "gfx_colors.h" | |
32 #include "gfx_engine.h" | |
33 #include "gfx_fonts.h" | |
34 #include "show_logbook.h" | |
35 #include "unit.h" | |
36 | |
37 #include <stdint.h> | |
38 #include <stdio.h> | |
39 #include <stdlib.h> // for abs() | |
40 | |
41 /* Private variables ---------------------------------------------------------*/ | |
42 | |
43 GFX_DrawCfgScreen tLOGscreen; | |
44 GFX_DrawCfgScreen tLOGbackground; | |
45 | |
46 | |
47 void print_gas_name(char* output,uint8_t lengh,uint8_t oxygen,uint8_t helium); | |
48 int16_t get_colour(int16_t color); | |
49 | |
50 /* Overview */ | |
51 void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); | |
52 /* Temperature */ | |
53 void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); | |
54 /* Gas List */ | |
55 void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); | |
56 /* ppO2 */ | |
57 void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); | |
58 | |
59 | |
60 inline uint32_t MinU32LOG(uint32_t a, uint32_t b) | |
61 { | |
62 return ((a<b)?a:b); | |
63 } | |
64 | |
65 uint32_t MaxU32LOG(uint32_t a, uint32_t b) | |
66 { | |
67 return((a>b)?a:b); | |
68 } | |
69 | |
70 void write_label_(GFX_DrawCfgScreen *screenInput, SWindowGimpStyle win, const tFont *Font, uint8_t color, const char *text) | |
71 { | |
72 GFX_DrawCfgWindow hgfx; | |
73 | |
74 if( win.right > 799) | |
75 win.right = 799; | |
76 | |
77 if(win.top > 479) | |
78 win.top = 479; | |
79 hgfx.Image = screenInput; | |
80 hgfx.WindowNumberOfTextLines = 1; | |
81 hgfx.WindowLineSpacing = 0; | |
82 hgfx.WindowTab = 0; | |
83 hgfx.WindowX0 = win.left; | |
84 hgfx.WindowX1 = win.right; | |
85 hgfx.WindowY1 = 479 - win.top; | |
86 if(hgfx.WindowY1 < Font->height) | |
87 hgfx.WindowY0 = 0; | |
88 else | |
89 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
90 | |
91 GFX_write_label(Font, &hgfx, text, color); | |
92 } | |
93 | |
94 | |
95 /** | |
96 ****************************************************************************** | |
97 * @brief GFX write label. / print coordinate system & depth graph | |
98 * @author Peter Ryser | |
99 * @version V0.0.1 | |
100 * @date 07-July-2014 | |
101 ****************************************************************************** | |
102 * | |
103 * @param hgfx: | |
104 * @param window: WindowGimpStyle | |
105 * @param mode: different modes depending witch page uses the function | |
106 * @param dataLength: | |
107 * @param depthdata: | |
108 * @param colordata: 1 | |
109 * @retval None | |
110 */ | |
111 void show_logbook_draw_depth_graph(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards, SWindowGimpStyle* window, short mode, uint16_t dataLength, uint16_t* depthdata, uint8_t * colordata, uint16_t * decostopdata) | |
112 { | |
113 SLogbookHeader logbookHeader; | |
114 SWindowGimpStyle wintemp = *window; | |
115 SWindowGimpStyle winsmal; | |
116 logbook_getHeader(StepBackwards, &logbookHeader); | |
117 int divetime = logbookHeader.diveTimeMinutes; | |
118 int maxDepth = logbookHeader.maxDepth/100; | |
119 | |
120 int16_t saveBottom = wintemp.bottom; | |
121 int16_t saveTop = 0 - wintemp.top; | |
122 | |
123 //*** Horisontal (depth) *************************************************** | |
124 | |
125 //--- calc depth lines and labels -- | |
126 int vscale = 0; | |
127 int vstep = 0; | |
128 | |
129 vstep = maxDepth / 5; | |
130 vscale = vstep * 5; | |
131 if(vscale < maxDepth) | |
132 { | |
133 vstep += 1; | |
134 vscale += 5; | |
135 } | |
136 /* | |
137 if(vscale < | |
138 for(int i=1; i <= 20; i++) | |
139 { | |
140 vscale = i * 25; | |
141 vstep = i * 5; | |
142 if( vscale > maxDepth) | |
143 break; | |
144 } | |
145 */ | |
146 //--- print depth labels --- | |
147 winsmal.left = wintemp.left - 48; | |
148 winsmal.top = wintemp.top - 3; | |
149 winsmal.right = wintemp.left -1; | |
150 winsmal.bottom = winsmal.top + 16; | |
151 | |
152 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,"[m]"); | |
153 winsmal.left = wintemp.left - 48; | |
154 char msg[3]; | |
155 float deltaline = ((float)(wintemp.bottom - wintemp.top))/5; | |
156 for(int i = 1; i<=5; i++) | |
157 { | |
158 | |
159 winsmal.top = wintemp.top + deltaline * i - 14; | |
160 winsmal.bottom = winsmal.top + 16; | |
161 winsmal.right = wintemp.left - 2; | |
162 snprintf(msg,5,"%i",i * vstep); | |
163 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,msg); | |
164 } | |
165 | |
166 //vertical (Time) ******************************************************************* | |
167 //--- calc time lines and labels -- | |
168 int timestep = 0; | |
169 int lines = 0; | |
170 for(int i=1; i <= 60; i++) | |
171 { | |
172 timestep = i * 5; | |
173 lines = divetime/timestep; | |
174 if(lines < 7) | |
175 { | |
176 break; | |
177 } | |
178 } | |
179 //*** print coordinate system grit *** | |
180 int winwidth = wintemp.right - wintemp.left; | |
181 float vdeltaline = ((float)(winwidth * timestep))/divetime; | |
182 GFX_draw_Grid( &tLOGbackground,wintemp, 0, vdeltaline, 5,0, CLUT_LogbookGrid); | |
183 | |
184 | |
185 //--- print time labels --- | |
186 winsmal.left = wintemp.left; | |
187 winsmal.top = wintemp.top - 40; | |
188 winsmal.right = winsmal.left + 60; | |
189 winsmal.bottom = winsmal.top + 16; | |
190 | |
191 | |
192 for(int i = 1; i<=lines; i++) | |
193 { | |
194 winsmal.left= wintemp.left + vdeltaline * i - 15; | |
195 winsmal.right = winsmal.left + 30; | |
196 snprintf(msg,5,"%3i",i * timestep); | |
197 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,msg); | |
198 } | |
199 winsmal.left = wintemp.left;// - 9; | |
200 winsmal.top = wintemp.top - 40; | |
201 winsmal.right = winsmal.left + 60; | |
202 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,"min");; | |
203 | |
204 //--- print depth graph --- | |
205 //adapt window | |
206 int winhight = wintemp.bottom - wintemp.top; | |
207 int newhight = (winhight * maxDepth)/vscale; | |
208 wintemp.bottom = wintemp.top + newhight; | |
209 //wintemp.fontcolor = LOGBOOK_GRAPH_DEPTH; | |
210 | |
211 int datamax = 0; | |
212 for(int i=0;i<dataLength;i++) | |
213 { | |
214 if(depthdata[i]>datamax) | |
215 datamax = depthdata[i]; | |
216 } | |
217 | |
218 if(decostopdata) | |
219 { | |
220 if(dataLength <= 1000) | |
221 { | |
222 uint8_t colortemp[1000]; | |
223 | |
224 for(int i = 0; i<dataLength; i++) | |
225 { | |
226 if(decostopdata[i] > depthdata[i]) | |
227 { | |
228 colortemp[i] = CLUT_WarningRed; | |
229 } | |
230 else | |
231 { | |
232 colortemp[i] = CLUT_NiceGreen; | |
233 } | |
234 } | |
235 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, NULL, colortemp); | |
236 } | |
237 else | |
238 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, CLUT_NiceGreen, NULL); | |
239 } | |
240 | |
241 switch(mode) | |
242 { | |
243 case 0: | |
244 GFX_graph_print(hgfx,&wintemp,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL); | |
245 break; | |
246 case 1: | |
247 GFX_graph_print(hgfx,&wintemp,saveBottom,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata); | |
248 break; | |
249 case 2: | |
250 if(*colordata) | |
251 GFX_graph_print(hgfx,&wintemp,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata); | |
252 else | |
253 GFX_graph_print(hgfx,&wintemp,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL); | |
254 } | |
255 | |
256 } | |
257 | |
258 | |
259 | |
260 /** | |
261 ****************************************************************************** | |
262 * @brief scaleAdapt | |
263 * @author heinrichs weikamp gmbh | |
264 * @version V0.0.1 | |
265 * @date 29-Nov-2016 | |
266 ****************************************************************************** | |
267 * | |
268 * @param ... | |
269 * @retval *OutputStepOfScale, *OutputMaxValueOnScale, *OutputTop, *OutputBottom | |
270 | |
271 * fit to multiples of 1�C (data format is 1/10�C) | |
272 */ | |
273 | |
274 void scaleAdapt( int InputTop, int InputBottom, | |
275 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom, | |
276 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale) | |
277 { | |
278 // uint16_t oldScale; | |
279 uint16_t newScale; | |
280 // uint16_t diff_newScale; | |
281 | |
282 // int16_t oldMaxOnScale; | |
283 int16_t newMaxOnScale; | |
284 // int16_t diff_newMaxOnScale; | |
285 _Bool negativeMaxValue = 0; | |
286 | |
287 // float oldRange; | |
288 float newRange; | |
289 | |
290 float sizeOfScreen; | |
291 // float InputTopValue; | |
292 // float InputBottomValue; | |
293 float screenToRangeRatio; | |
294 float diffOutMaxToMaxOnScale; | |
295 float diffOutMinToMaxOnScale; | |
296 int positonOutputMaxValue; | |
297 int positonOutputMinValue; | |
298 | |
299 | |
300 // scale | |
301 // oldScale = *OutputStepOfScale; | |
302 newScale = *OutputStepOfScale + 9; | |
303 newScale /= 10; | |
304 newScale *= 10; | |
305 // diff_newScale = newScale - *OutputStepOfScale; | |
306 // oldRange = 5 * oldScale; | |
307 newRange = 5 * newScale; | |
308 *OutputStepOfScale = newScale; | |
309 | |
310 // MaxValueOnScale | |
311 // oldMaxOnScale = *OutputMaxValueOnScale; | |
312 if(OutputMaxValueOnScale < 0) | |
313 { | |
314 negativeMaxValue = 1; | |
315 newMaxOnScale = 0 - *OutputMaxValueOnScale; | |
316 } | |
317 else | |
318 { | |
319 negativeMaxValue = 0; | |
320 newMaxOnScale = *OutputMaxValueOnScale; | |
321 } | |
322 newMaxOnScale += 9; | |
323 newMaxOnScale /= 10; | |
324 newMaxOnScale *= 10; | |
325 if(negativeMaxValue) | |
326 { | |
327 // diff_newMaxOnScale = newMaxOnScale + *OutputMaxValueOnScale; | |
328 *OutputMaxValueOnScale = 0 - newMaxOnScale; | |
329 } | |
330 else | |
331 { | |
332 // diff_newMaxOnScale = newMaxOnScale - *OutputMaxValueOnScale; | |
333 *OutputMaxValueOnScale = newMaxOnScale; | |
334 } | |
335 | |
336 | |
337 // new coordinates | |
338 sizeOfScreen = 1 + InputBottom - InputTop; | |
339 // InputTopValue = *OutputMaxValueOnScale; | |
340 // InputBottomValue = InputTopValue + (6 * *OutputStepOfScale); | |
341 | |
342 screenToRangeRatio = sizeOfScreen / newRange; | |
343 diffOutMaxToMaxOnScale = abs(*OutputMaxValueOnScale) - abs(*OutputMaxValue); | |
344 // diffOutMinToMax = abs(*OutputMinValue - *OutputMaxValue); | |
345 diffOutMinToMaxOnScale = abs(*OutputMaxValueOnScale - *OutputMinValue); | |
346 | |
347 positonOutputMaxValue = (int)(diffOutMaxToMaxOnScale * screenToRangeRatio); | |
348 positonOutputMaxValue += *OutputTop; | |
349 positonOutputMinValue = (int)(diffOutMinToMaxOnScale * screenToRangeRatio); | |
350 positonOutputMinValue += *OutputTop; | |
351 // positonOutputMinValue = (int)(diffOutMinToMax * screenToRangeRatio); | |
352 // positonOutputMinValue += positonOutputMaxValue; | |
353 *OutputTop = positonOutputMaxValue; | |
354 *OutputBottom = positonOutputMinValue; | |
355 } | |
356 | |
357 | |
358 /** | |
359 ****************************************************************************** | |
360 * @brief scaleHelper | |
361 * @author heinrichs weikamp gmbh | |
362 * @version V0.0.1 | |
363 * @date 13-Oct-2016 | |
364 ****************************************************************************** | |
365 * | |
366 * @param hgfx: | |
367 * @retval None | |
368 | |
369 * pixel 50 oben | |
370 * pixel 439 unten | |
371 * pixel 390 gesamt h�he | |
372 | |
373 * for temperature, input is �C * 10 | |
374 */ | |
375 | |
376 void scaleHelper( uint16_t InputDataLength, int16_t *InputDataArray, int InputTop, int InputBottom, | |
377 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom, | |
378 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale) | |
379 { | |
380 int32_t datamin = INT16_MAX; // 32 bit for delta calculation ( delta is unsigned -> value can be 2x INT16_MAX) | |
381 int32_t datamax = INT16_MIN; | |
382 uint16_t deltaMinMax = 1; | |
383 // uint16_t deltaMinMaxUsed = 1; | |
384 // uint16_t digits = 1; | |
385 // uint16_t scaler = 1; | |
386 uint32_t step = 1; | |
387 const int sizeOfScreen = InputBottom - InputTop; | |
388 float pixel2range = 1.0; | |
389 | |
390 // min, max, deltaMinMax, OutputMinValue, OutputMaxValue | |
391 for(uint16_t i = 0; i < InputDataLength; i++) | |
392 { | |
393 if(InputDataArray[i] > datamax) | |
394 datamax = InputDataArray[i]; | |
395 | |
396 if(InputDataArray[i] < datamin) | |
397 datamin = InputDataArray[i]; | |
398 } | |
399 | |
400 deltaMinMax = (uint16_t)(datamax - datamin); | |
401 | |
402 *OutputMinValue = (int16_t)datamin; | |
403 *OutputMaxValue = (int16_t)datamax; | |
404 | |
405 // step | |
406 step = deltaMinMax / 5; | |
407 while(deltaMinMax > (step * 5)) | |
408 { | |
409 step += 1; | |
410 } | |
411 pixel2range = ((float)sizeOfScreen) / (step * 5); | |
412 | |
413 *OutputStepOfScale = (uint16_t)step; | |
414 *OutputMaxValueOnScale = *OutputMaxValue; | |
415 *OutputTop = InputTop; | |
416 *OutputBottom = ((int)(pixel2range * deltaMinMax)) + *OutputTop; | |
417 } | |
418 | |
419 /** | |
420 ****************************************************************************** | |
421 * @brief show_logbook_logbook_show_log_page1 / | |
422 * @author Peter Ryser | |
423 * @version V0.0.1 | |
424 * @date 07-July-2014 | |
425 ****************************************************************************** | |
426 * | |
427 * @param hgfx: | |
428 * @retval None | |
429 */ | |
430 void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx,uint8_t StepBackwards) | |
431 { | |
432 SWindowGimpStyle wintemp; | |
433 SWindowGimpStyle winsmal; | |
434 wintemp.left = 50; | |
435 wintemp.right = 799 - wintemp.left; | |
436 wintemp.top = 50; | |
437 wintemp.bottom = 479 - 40; | |
438 | |
439 SLogbookHeader logbookHeader; | |
440 logbook_getHeader(StepBackwards ,&logbookHeader); | |
441 | |
442 uint16_t depthdata[1000] = { 0 }; | |
443 uint8_t gasdata[1000] = { 0 }; | |
444 int16_t tempdata[1000] = { 0 }; | |
445 | |
446 uint16_t dataLength = 0; | |
447 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
448 | |
449 //Print Date | |
450 uint8_t year = logbookHeader.dateYear; | |
451 uint8_t month = logbookHeader.dateMonth; | |
452 uint8_t day = logbookHeader.dateDay; | |
453 char text[40]; | |
454 snprintf(text, 20, "20%02i-%02i-%02i", year, month, day); | |
455 Gfx_write_label_var(hgfx, 30, 150,10, &FontT42,CLUT_GasSensor1,text); | |
456 | |
457 // Print logbook number with offset | |
458 if(settingsGetPointer()->logbookOffset) | |
459 { | |
460 int32_t logNumber; | |
461 logNumber = settingsGetPointer()->logbookOffset - StepBackwards; | |
462 if(logNumber < 0) | |
463 logNumber = 0; | |
464 else | |
465 if(logNumber > 9999) | |
466 logNumber = 9999; | |
467 | |
468 snprintf(text,20,"#%i",logNumber); | |
469 Gfx_write_label_var(hgfx, 300, 590,10, &FontT42,CLUT_GasSensor1,text); | |
470 } | |
471 | |
472 //Print time | |
473 uint8_t hour = logbookHeader.timeHour; | |
474 uint8_t minute = logbookHeader.timeMinute; | |
475 snprintf(text,20,"%02i:%02i",hour,minute); | |
476 Gfx_write_label_var(hgfx, 600, 749,10, &FontT42,CLUT_GasSensor1,text); | |
477 | |
478 //Print Dive Mode (OC/CCR/...) | |
479 switch(logbookHeader.diveMode) | |
480 { | |
481 case DIVEMODE_OC: | |
482 snprintf(text,20,"open circuit"); | |
483 break; | |
484 case DIVEMODE_CCR: | |
485 snprintf(text,20,"closed circuit"); | |
486 break; | |
487 case DIVEMODE_Gauge: | |
488 snprintf(text,20,"Gauge"); | |
489 break; | |
490 case DIVEMODE_Apnea: | |
491 snprintf(text,20,"Apnea"); | |
492 break; | |
493 } | |
494 Gfx_write_label_var(hgfx, 30, 250,60, &FontT42,CLUT_GasSensor4,text); | |
495 | |
496 // Decomodel | |
497 if(logbookHeader.diveMode <= DIVEMODE_CCR) | |
498 { | |
499 switch(logbookHeader.decoModel) | |
500 { | |
501 case GF_MODE: | |
502 snprintf(text,20,"\002GF%u/%u",logbookHeader.gfLow_or_Vpm_conservatism,logbookHeader.gfHigh); | |
503 break; | |
504 case VPM_MODE: | |
505 snprintf(text,20,"\002VPM +%u",logbookHeader.gfLow_or_Vpm_conservatism); | |
506 break; | |
507 } | |
508 Gfx_write_label_var(hgfx, 600, 729,60, &FontT42,CLUT_GasSensor1,text); | |
509 } | |
510 | |
511 //Write Dive Time | |
512 int minutes = logbookHeader.diveTimeMinutes; | |
513 int seconds = logbookHeader.diveTimeSeconds; | |
514 int hours = minutes/60; | |
515 minutes -= hours * 60; | |
516 snprintf(text,20,"%02i:%02i:%02i",hours,minutes,seconds); | |
517 Gfx_write_label_var(hgfx, 30, 250,360, &FontT42,CLUT_GasSensor1,text); | |
518 Gfx_write_label_var(hgfx, 200, 250,360, &FontT42,CLUT_GasSensor4,"s"); | |
519 | |
520 // Max Depth | |
521 int maxdepth =logbookHeader.maxDepth/100; | |
522 int maxdepth_dcm = logbookHeader.maxDepth/10 - maxdepth * 10; | |
523 int top = 150; | |
524 if(settingsGetPointer()->nonMetricalSystem) | |
525 { | |
526 float maxDepthFeet = 0; | |
527 maxDepthFeet = unit_depth_float(((float)logbookHeader.maxDepth)/100); | |
528 snprintf(text,20,"%.0f",maxDepthFeet); | |
529 } | |
530 else | |
531 { | |
532 snprintf(text,20,"%i.%i",maxdepth,maxdepth_dcm); | |
533 } | |
534 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text); | |
535 winsmal.left = 30; | |
536 winsmal.top = top -3; | |
537 winsmal.bottom = winsmal.top + FontT42.height; | |
538 winsmal.right = winsmal.left + 50; | |
539 if(maxdepth < 10) | |
540 { | |
541 winsmal.left = 137; | |
542 } | |
543 else if(maxdepth < 100) | |
544 { | |
545 winsmal.left = 151; | |
546 } | |
547 else | |
548 { | |
549 winsmal.left = 147; | |
550 } | |
551 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor4,"max"); | |
552 snprintf(text,3,"%c%c" | |
553 , unit_depth_char1() | |
554 , unit_depth_char2() | |
555 ); | |
556 Gfx_write_label_var(hgfx, winsmal.left - 37, 250,top, &FontT42,CLUT_GasSensor4,text); | |
557 | |
558 // Average Depth | |
559 int avrdepth =logbookHeader.averageDepth_mbar/100; | |
560 int avrdepth_dcm = logbookHeader.averageDepth_mbar/10 - avrdepth * 10; | |
561 top = 200; | |
562 if(settingsGetPointer()->nonMetricalSystem) | |
563 { | |
564 float avgDepthFeet = 0; | |
565 avgDepthFeet = unit_depth_float(((float)logbookHeader.averageDepth_mbar)/100); | |
566 snprintf(text,20,"%.0f",avgDepthFeet); | |
567 } | |
568 else | |
569 { | |
570 snprintf(text,20,"%i.%i",avrdepth,avrdepth_dcm); | |
571 } | |
572 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text); | |
573 winsmal.left = 30; | |
574 winsmal.top = top -3; | |
575 winsmal.bottom = winsmal.top + FontT42.height; | |
576 winsmal.right = winsmal.left + 50; | |
577 if(avrdepth < 10) | |
578 { | |
579 winsmal.left = 137 ; | |
580 } | |
581 else if(avrdepth < 100) | |
582 { | |
583 winsmal.left = 151; | |
584 } | |
585 else | |
586 { | |
587 winsmal.left = 147; | |
588 } | |
589 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor4,"avg"); | |
590 snprintf(text,3,"%c%c" | |
591 , unit_depth_char1() | |
592 , unit_depth_char2() | |
593 ); | |
594 Gfx_write_label_var(hgfx, winsmal.left - 37, 250,top, &FontT42,CLUT_GasSensor4,text); | |
595 // Temperature | |
596 top+= 50; | |
597 float temp_Temperature; | |
598 uint16_t start; | |
599 temp_Temperature = ((float)logbookHeader.minTemp)/10; | |
600 snprintf(text,20,"%.1f",unit_temperature_float(temp_Temperature)); | |
601 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text); | |
602 | |
603 if(settingsGetPointer()->nonMetricalSystem) | |
604 start = 121; | |
605 else if((logbookHeader.minTemp >= 0) && (logbookHeader.minTemp < 10)) | |
606 start = 100; | |
607 else if((logbookHeader.minTemp >= -10) && (logbookHeader.minTemp < 100)) | |
608 start = 114; | |
609 else | |
610 start = 121; | |
611 | |
612 text[0] = '\140'; | |
613 if(settingsGetPointer()->nonMetricalSystem) | |
614 text[1] = 'F'; | |
615 else | |
616 text[1] = 'C'; | |
617 text[2] = 0; | |
618 | |
619 Gfx_write_label_var(hgfx, start, 300,top, &FontT42,CLUT_GasSensor4,text); | |
620 | |
621 // CNS | |
622 snprintf(text,20,"CNS: %i %%",logbookHeader.maxCNS); | |
623 Gfx_write_label_var(hgfx, 30, 250,750, &FontT42,CLUT_GasSensor1,text); | |
624 | |
625 // Surface Pressure | |
626 // snprintf(text,20,"\001%i\016\016 mbar",logbookHeader.surfacePressure_mbar); | |
627 // Gfx_write_label_var(hgfx,300,500,750, &FontT42,CLUT_GasSensor1,text); | |
628 // snprintf(text,40,"%i\016\016 mbar\017 (%i\016\016 m\017)",logbookHeader.surfacePressure_mbar, unit_SeaLevelRelation_integer(logbookHeader.surfacePressure_mbar)); | |
102
4276d56eb37c
hPa instead of mbar, enabled Spanish language
heinrichsweikamp
parents:
38
diff
changeset
|
629 snprintf(text,40,"%i\016\016 hPa\017",logbookHeader.surfacePressure_mbar); |
38 | 630 Gfx_write_label_var(hgfx,320,600,750, &FontT42,CLUT_GasSensor1,text); |
631 | |
632 | |
633 //--- print coordinate system & depth graph with gaschanges --- | |
634 wintemp.left = 330; | |
635 wintemp.top = 160; | |
636 wintemp.bottom -= 40; | |
637 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL); | |
638 } | |
639 | |
640 | |
641 void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) | |
642 { | |
643 //*** Page2: Depth and Temperature **** | |
644 | |
645 SWindowGimpStyle wintemp; | |
646 SWindowGimpStyle winsmal; | |
647 wintemp.left = 50; | |
648 wintemp.right = 799 - wintemp.left; | |
649 wintemp.top = 50; | |
650 wintemp.bottom = 479 - 40; | |
651 | |
652 SLogbookHeader logbookHeader; | |
653 | |
654 logbook_getHeader(StepBackwards,&logbookHeader); | |
655 uint16_t dataLength = 0; | |
656 uint16_t depthdata[1000]; | |
657 uint8_t gasdata[1000]; | |
658 int16_t tempdata[1000]; | |
659 uint16_t decoDepthdata[1000]; | |
660 uint16_t *pDecoDepthData = 0; | |
661 | |
662 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, decoDepthdata); | |
663 | |
664 for(int i = 0; i<dataLength; i++) | |
665 { | |
666 if(decoDepthdata[i] >= 300) | |
667 { | |
668 pDecoDepthData = decoDepthdata; | |
669 break; | |
670 } | |
671 } | |
672 //--- print coordinate system & depth graph --- | |
673 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, pDecoDepthData); | |
674 | |
675 //*** Temperature ************************************************* | |
676 | |
677 //--- print temperature labels --- | |
678 // input maxtmpline, tmpstep, deltaline | |
679 | |
680 winsmal.left = wintemp.right +6; | |
681 winsmal.top = wintemp.top - 3; | |
682 winsmal.right = wintemp.right + 30; | |
683 winsmal.bottom = winsmal.top + 16; | |
684 | |
685 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,"[C]"); | |
686 | |
687 | |
688 int16_t minVal = 0; | |
689 int16_t maxVal = 0; | |
690 int newTop = 0; | |
691 int newBottom = 0; | |
692 uint16_t step = 0; | |
693 int16_t maxValTop = 0; | |
694 | |
695 scaleHelper(dataLength, tempdata, wintemp.top, wintemp.bottom, | |
696 &minVal, &maxVal, &newTop, &newBottom, | |
697 &step, &maxValTop); // newTop is wintemp.top | |
698 | |
699 scaleAdapt( wintemp.top, wintemp.bottom, | |
700 &minVal, &maxVal, &newTop, &newBottom, | |
701 &step, &maxValTop); | |
702 | |
703 // temperature in 1/10 �C | |
704 int deltaline = (1 + wintemp.bottom - wintemp.top)/5; | |
705 char msg[3]; | |
706 int tmp = maxValTop; | |
707 for(int i = 1; i<=5; i++) | |
708 { | |
709 tmp -= step; | |
710 //if(tmp < 0) | |
711 //break; | |
712 winsmal.top = wintemp.top + deltaline * i - 14; | |
713 winsmal.bottom = winsmal.top + 16; | |
714 if((tmp >= 0) && (tmp < 100)) | |
715 snprintf(msg,2,"%1i",tmp); | |
716 else | |
717 snprintf(msg,3,"%2i",tmp); | |
718 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,msg); | |
719 } | |
720 | |
721 | |
722 //--- print temperature graph --- | |
723 // input tempdata[i], maxtmpline, mintmpline, maxTmp, minTmp, deltaline, wintemp.top, dataLength, datamax, | |
724 | |
725 //adapt window | |
726 wintemp.bottom = newBottom; | |
727 wintemp.top = newTop; | |
728 GFX_graph_print(hgfx,&wintemp,0,1,maxVal,minVal, (uint16_t *)tempdata,dataLength,CLUT_LogbookTemperature, NULL); | |
729 } | |
730 | |
731 | |
732 void show_logbook_logbook_show_log_page2_original(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) | |
733 { | |
734 //*** Page2: Depth and Temperature **** | |
735 | |
736 SWindowGimpStyle wintemp; | |
737 SWindowGimpStyle winsmal; | |
738 wintemp.left = 50; | |
739 wintemp.right = 799 - wintemp.left; | |
740 wintemp.top = 50; | |
741 wintemp.bottom = 479 - 40; | |
742 | |
743 SLogbookHeader logbookHeader; | |
744 | |
745 logbook_getHeader(StepBackwards,&logbookHeader); | |
746 uint16_t dataLength = 0; | |
747 uint16_t depthdata[1000]; | |
748 uint8_t gasdata[1000]; | |
749 int16_t tempdata[1000]; | |
750 uint16_t decoDepthdata[1000]; | |
751 uint16_t *pDecoDepthData = 0; | |
752 | |
753 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, decoDepthdata); | |
754 | |
755 /* test | |
756 for(int i = 0; i<dataLength/2; i++) | |
757 decoDepthdata[i] = 300; | |
758 | |
759 for(int i = dataLength/2; i<dataLength; i++) | |
760 decoDepthdata[i] = 1200; | |
761 */ | |
762 for(int i = 0; i<dataLength; i++) | |
763 { | |
764 if(decoDepthdata[i] >= 300) | |
765 { | |
766 pDecoDepthData = decoDepthdata; | |
767 break; | |
768 } | |
769 } | |
770 //--- print coordinate system & depth graph --- | |
771 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, pDecoDepthData); | |
772 | |
773 //*** Temperature ************************************************* | |
774 | |
775 | |
776 int16_t datamax = -1000; // �C * 10 | |
777 int16_t datamin = +1000; | |
778 for(int i = 0; i < dataLength;i++) | |
779 { | |
780 if(tempdata[i]>datamax) | |
781 datamax = tempdata[i]; | |
782 if(tempdata[i]< datamin) | |
783 datamin = tempdata[i]; | |
784 } | |
785 float maxTmp = ((float)datamax) /10.f; | |
786 float minTmp = ((float)datamin) /10.f; | |
787 int deltaTmp = maxTmp - minTmp; | |
788 int tmpstep = 2; | |
789 | |
790 // 5 different scales: 1�C, 2�C, 4�C, 5�C, 10�C | |
791 // with 6 lines == 5 steps | |
792 if((deltaTmp) <=5) | |
793 { | |
794 tmpstep = 1; | |
795 } | |
796 else | |
797 if(deltaTmp <= (5*2)) | |
798 { | |
799 tmpstep = 2; | |
800 } | |
801 else | |
802 if(deltaTmp <= (5 * 4)) | |
803 { | |
804 tmpstep = 4; | |
805 } | |
806 else | |
807 if(deltaTmp <= (5 * 5)) | |
808 { | |
809 tmpstep = 5; | |
810 } | |
811 else | |
812 { | |
813 tmpstep = 10; | |
814 } | |
815 // int steps = deltaTmp/tmpstep; | |
816 | |
817 | |
818 // int steps = deltaTmp/5; | |
819 // int tmpstep = 5; | |
820 // if(steps > 4) | |
821 // tmpstep = 10; | |
822 | |
823 int maxtmpline = 0; | |
824 int mintmpline = 0; | |
825 if(minTmp < 0) | |
826 { | |
827 if(minTmp >= -5) | |
828 { | |
829 mintmpline = -5; | |
830 | |
831 } | |
832 else if(minTmp >= -10) | |
833 { | |
834 mintmpline = -10; | |
835 } | |
836 else | |
837 mintmpline = -15; | |
838 } | |
839 | |
840 if(maxTmp > 0) | |
841 { | |
842 while(maxtmpline < maxTmp) | |
843 maxtmpline += tmpstep; | |
844 } | |
845 | |
846 if(tmpstep < 5) | |
847 maxtmpline = MaxU32LOG(maxtmpline, 10); | |
848 else if(tmpstep == 5) | |
849 maxtmpline = MaxU32LOG(maxtmpline, 25); | |
850 else | |
851 maxtmpline = 50; | |
852 | |
853 maxtmpline += mintmpline; | |
854 | |
855 //--- print temperature labels --- | |
856 // input maxtmpline, tmpstep, deltaline | |
857 | |
858 winsmal.left = wintemp.right +6; | |
859 winsmal.top = wintemp.top - 3; | |
860 winsmal.right = wintemp.right + 30; | |
861 winsmal.bottom = winsmal.top + 16; | |
862 | |
863 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,"[C]"); | |
864 | |
865 int deltaline = (wintemp.bottom - wintemp.top)/5; | |
866 char msg[3]; | |
867 int tmp = maxtmpline; | |
868 for(int i = 1; i<=5; i++) | |
869 { | |
870 tmp -= tmpstep; | |
871 //if(tmp < 0) | |
872 //break; | |
873 winsmal.top = wintemp.top + deltaline * i - 14; | |
874 winsmal.bottom = winsmal.top + 16; | |
875 snprintf(msg,3,"%2i",tmp); | |
876 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,msg); | |
877 } | |
878 | |
879 | |
880 //--- print temperature graph --- | |
881 // input tempdata[i], maxtmpline, mintmpline, maxTmp, minTmp, deltaline, wintemp.top, dataLength, datamax, | |
882 | |
883 //adapt window | |
884 float ftmp =((maxtmpline - minTmp) * deltaline) /tmpstep + wintemp.top; | |
885 wintemp.bottom = ftmp; | |
886 if((ftmp - (int)ftmp) >= 0.5f) | |
887 wintemp.bottom++; | |
888 | |
889 ftmp = ((maxtmpline - maxTmp) * deltaline) /tmpstep + wintemp.top; | |
890 wintemp.top = ftmp; | |
891 if((ftmp - (int)ftmp) >= 0.5f) | |
892 wintemp.top++; | |
893 | |
894 if(wintemp.top <= wintemp.bottom) | |
895 { | |
896 for(int i = 0; i < dataLength;i++) | |
897 { | |
898 tempdata[i] -= mintmpline; | |
899 } | |
900 datamax -= mintmpline; | |
901 // hw 160518 | |
902 // es wird nur das Fenster (wintemp.top, wintemp.bottom) verwendet in dem Daten sind | |
903 // daher muss datamin angegeben werden | |
904 // der Gesamtbereich ist uninteressant | |
905 // Bsp Temperatur von 8�C bis 5�C | |
906 // Y-Achse ist 10�C (oben) bis 0�C (unten) | |
907 // aber wintemp.top ist 127 | |
908 // und wintemp.bottom ist 243 | |
909 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, (uint16_t *)tempdata,dataLength,CLUT_LogbookTemperature, NULL); | |
910 } | |
911 } | |
912 | |
913 | |
914 void build_logbook_test(uint8_t page, uint8_t StepBackwards) | |
915 { | |
916 uint32_t lastScreen,lastBackground; | |
917 | |
918 lastScreen = tLOGscreen.FBStartAdress; | |
919 lastBackground = tLOGbackground.FBStartAdress; | |
920 | |
921 tLOGscreen.FBStartAdress = getFrame(16); | |
922 tLOGscreen.ImageHeight = 480; | |
923 tLOGscreen.ImageWidth = 800; | |
924 tLOGscreen.LayerIndex = 1; | |
925 | |
926 tLOGbackground.FBStartAdress = getFrame(17); | |
927 tLOGbackground.ImageHeight = 480; | |
928 tLOGbackground.ImageWidth = 800; | |
929 tLOGbackground.LayerIndex = 0; | |
930 switch(page) | |
931 { | |
932 case 1: | |
933 show_logbook_logbook_show_log_page1(&tLOGscreen,StepBackwards); | |
934 break; | |
935 case 2: | |
936 show_logbook_logbook_show_log_page2(&tLOGscreen,StepBackwards); | |
937 break; | |
938 case 3: | |
939 show_logbook_logbook_show_log_page3(&tLOGscreen,StepBackwards); | |
940 break; | |
941 case 4: | |
942 show_logbook_logbook_show_log_page4(&tLOGscreen,StepBackwards); | |
943 break; | |
944 } | |
945 | |
946 releaseFrame(16,lastScreen); | |
947 releaseFrame(17,lastBackground); | |
948 } | |
949 | |
950 | |
951 void show_logbook_test(_Bool firstPage, uint8_t StepBackwards) | |
952 { | |
953 static uint8_t page = 1; | |
954 if(firstPage) | |
955 { | |
956 page = 1; | |
957 } | |
958 else | |
959 { | |
960 page++; | |
961 if(page > 4) | |
962 page = 1; | |
963 } | |
964 | |
965 build_logbook_test(page,StepBackwards); | |
966 // GFX_ResetLayer(TOP_LAYER); | |
967 // GFX_ResetLayer(BACKGRD_LAYER); | |
968 | |
969 set_globalState(StILOGSHOW); | |
970 GFX_SetFramesTopBottom(tLOGscreen.FBStartAdress, tLOGbackground.FBStartAdress,480); | |
971 } | |
972 | |
973 | |
974 void show_logbook_exit(void) | |
975 { | |
976 releaseFrame(16,tLOGscreen.FBStartAdress); | |
977 releaseFrame(17,tLOGbackground.FBStartAdress); | |
978 } | |
979 | |
980 | |
981 void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) | |
982 { | |
983 SWindowGimpStyle wintemp; | |
984 SWindowGimpStyle winsmal; | |
985 wintemp.left = 50; | |
986 wintemp.right = 799 - wintemp.left; | |
987 wintemp.top = 50; | |
988 wintemp.bottom = 479 - 40; | |
989 | |
990 SLogbookHeader logbookHeader; | |
991 | |
992 logbook_getHeader(StepBackwards, &logbookHeader); | |
993 uint16_t dataLength = 0; | |
994 uint16_t depthdata[1000]; | |
995 uint8_t gasdata[1000]; | |
996 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
997 | |
998 //--- print coordinate system & depth graph with gaschanges --- | |
999 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL); | |
1000 | |
1001 //--- print gas list --- | |
1002 winsmal.left = wintemp.right - 190; | |
1003 winsmal.right = winsmal.left + 150; | |
1004 | |
1005 char msg[15]; | |
1006 char gas_name[15]; | |
1007 int j = 0; | |
1008 for(int i = 4;i >= 0;i--) | |
1009 { | |
1010 if(logbookHeader.gasordil[i].note.ub.active > 0) | |
1011 { | |
1012 j++; | |
1013 winsmal.top = wintemp.bottom - 5 - j * 26 ; | |
1014 winsmal.bottom = winsmal.top + 21 ; | |
1015 uint8_t color = get_colour(i); | |
1016 | |
1017 print_gas_name(gas_name,15,logbookHeader.gasordil[i].oxygen_percentage,logbookHeader.gasordil[i].helium_percentage); | |
1018 snprintf(msg,15,"G%i: %s",i + 1, gas_name); | |
1019 //msg[10] = 0; | |
1020 write_label_(hgfx, winsmal,&FontT24,color,msg); | |
1021 } | |
1022 } | |
1023 | |
1024 //--- define buttons --- | |
1025 /*if(*ghost_char_logfile_oxydata) | |
1026 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page4, surf1_menu_logbook_show_log_next); | |
1027 else | |
1028 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next); | |
1029 */ | |
1030 } | |
1031 | |
1032 void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) | |
1033 { SWindowGimpStyle wintemp; | |
1034 SWindowGimpStyle winsmal; | |
1035 wintemp.left = 50; | |
1036 wintemp.right = 799 - wintemp.left; | |
1037 wintemp.top = 50; | |
1038 wintemp.bottom = 479 - 40; | |
1039 uint8_t color = 0; | |
1040 SLogbookHeader logbookHeader; | |
1041 | |
1042 logbook_getHeader(StepBackwards, &logbookHeader); | |
1043 uint16_t dataLength = 0; | |
1044 uint16_t depthdata[1000]; | |
1045 uint8_t gasdata[1000]; | |
1046 uint16_t ppO2data[1000]; | |
1047 uint16_t sensor2[1000]; | |
1048 uint16_t sensor3[1000]; | |
1049 uint16_t *setpoint = ppO2data; | |
1050 uint16_t *sensor1 = ppO2data; | |
1051 | |
1052 | |
1053 if(logbookHeader.diveMode != DIVEMODE_CCR) | |
1054 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, ppO2data, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
1055 else | |
1056 { | |
1057 if(logbookHeader.CCRmode == CCRMODE_FixedSetpoint) | |
1058 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, setpoint, NULL, NULL, NULL, NULL, NULL, NULL); | |
1059 else | |
1060 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, NULL, sensor1, sensor2, sensor3, NULL, NULL, NULL); | |
1061 } | |
1062 | |
1063 | |
1064 //--- print coordinate system & depth graph with bailout--- | |
1065 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, NULL); | |
1066 | |
1067 | |
1068 | |
1069 //*** Desciption at bottom of page *************************** | |
1070 winsmal.top = wintemp.bottom +2 ; | |
1071 winsmal.bottom = winsmal.top + 16; | |
1072 | |
1073 | |
1074 /*if(strcmp( (char*)ghost_char_logfile_text_oc_ccr,"ccr/bailout") == 0) | |
1075 { | |
1076 winsmal.left = wintemp.left + 2; | |
1077 winsmal.right = winsmal.left + 55; | |
1078 | |
1079 oled_write(OVERLAY, &winsmal,"CCR -",false,true); | |
1080 | |
1081 winsmal.left = winsmal.right; | |
1082 winsmal.right = winsmal.left + 90; | |
1083 //winsmal.fontcolor = oled_get_colour(15); | |
1084 oled_write(OVERLAY, &winsmal,"bailout",false,true); | |
1085 } | |
1086 else*/ | |
1087 { | |
1088 winsmal.left = wintemp.left + 2; | |
1089 winsmal.right = winsmal.left + 55; | |
1090 color = CLUT_GasSensor1;//LOGBOOK_GRAPH_DEPTH; | |
1091 | |
1092 write_label_(hgfx, winsmal,&FontT24,color,"depth"); | |
1093 | |
1094 } | |
1095 winsmal.left = 799 - 67;//wintemp.right -67; | |
1096 winsmal.right = winsmal.left;// + 45; | |
1097 | |
1098 color = CLUT_LogbookTemperature;//LOGBOOK_GRAPH_DEPTH; | |
1099 if(logbookHeader.diveMode != DIVEMODE_CCR) | |
1100 write_label_(hgfx, winsmal,&FontT24,color,"\002PP O2"); | |
1101 else | |
1102 if(logbookHeader.CCRmode != CCRMODE_Sensors) | |
1103 write_label_(hgfx, winsmal,&FontT24,color,"\002SETPOINT"); | |
1104 else | |
1105 write_label_(hgfx, winsmal,&FontT24,color,"\002SENSORS"); | |
1106 | |
1107 //*** PP O2 **************************************************** | |
1108 //calc lines and labels | |
1109 int datamax = 0; | |
1110 int datamin = 10000; | |
1111 for(int i=1;i<dataLength;i++) | |
1112 { | |
1113 if(ppO2data[i]>datamax) | |
1114 datamax = ppO2data[i]; | |
1115 if(ppO2data[i]<datamin) | |
1116 datamin = ppO2data[i]; | |
1117 } | |
1118 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors)) | |
1119 { | |
1120 for(int i=1;i<dataLength;i++) | |
1121 { | |
1122 if(sensor2[i]>datamax) | |
1123 datamax = sensor2[i]; | |
1124 if(sensor2[i]<datamin) | |
1125 datamin = sensor2[i]; | |
1126 if(sensor3[i]>datamax) | |
1127 datamax = sensor3[i]; | |
1128 if(sensor3[i]<datamin) | |
1129 datamin = sensor3[i]; | |
1130 } | |
1131 } | |
1132 float maxoxy = ((float)datamax)/100; | |
1133 float minoxy = ((float)datamin)/100; | |
1134 float oxystep = 0.5; | |
1135 float maxoxyline = 2.5; | |
1136 | |
1137 //--- print PP O2 labels ---- | |
1138 winsmal.left = wintemp.right + 2; | |
1139 winsmal.top = wintemp.top ; | |
1140 winsmal.right = wintemp.right + 30; | |
1141 winsmal.bottom = winsmal.top + 16; | |
1142 //winsmal.font = ft_tiny + ft_SLIM; | |
1143 color = CLUT_LogbookTemperature;// = LOGBOOK_GRAPH_TEMP; | |
1144 | |
1145 write_label_(hgfx, winsmal,&FontT24,color,"bar"); | |
1146 | |
1147 int deltaline = (wintemp.bottom - wintemp.top)/5; | |
1148 char msg[4]; | |
1149 float oxy = maxoxyline; | |
1150 for(int i = 1; i<=5; i++) | |
1151 { | |
1152 oxy -= oxystep; | |
1153 if(oxy < 0) | |
1154 break; | |
1155 winsmal.top = wintemp.top + deltaline * i - 8; | |
1156 winsmal.bottom = winsmal.top + 16; | |
1157 snprintf(msg,4,"%1.1f",oxy); | |
1158 write_label_(hgfx, winsmal,&FontT24,color,msg); | |
1159 //oled_write(OVERLAY, &winsmal,msg,false,true); | |
1160 } | |
1161 | |
1162 //--- print PP O2 graph --- | |
1163 //Adapt window | |
1164 float ftmp = ((maxoxyline - minoxy) * deltaline) /oxystep + wintemp.top; | |
1165 wintemp.bottom = ftmp; | |
1166 if((ftmp - (int)ftmp) >= 0.5f) | |
1167 wintemp.bottom++; | |
1168 | |
1169 ftmp = wintemp.top + ((maxoxyline - maxoxy) * deltaline) /oxystep; | |
1170 wintemp.top = ftmp; | |
1171 if((ftmp - (int)ftmp) >= 0.5f) | |
1172 wintemp.top++; | |
1173 wintemp.top = MaxU32LOG(wintemp.top ,0); | |
1174 if(wintemp.top < wintemp.bottom) | |
1175 { | |
1176 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors)) | |
1177 { | |
1178 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL); | |
1179 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor2,dataLength,CLUT_LogbookTemperature, NULL); | |
1180 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor3,dataLength,CLUT_LogbookTemperature, NULL); | |
1181 } | |
1182 else | |
1183 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL); | |
1184 } | |
1185 else | |
1186 { | |
1187 point_t startPoint, stopPoint; | |
1188 startPoint.x = wintemp.left; | |
1189 stopPoint.x = wintemp.right; | |
1190 stopPoint.y = startPoint.y = 479 - wintemp.top; | |
1191 GFX_draw_colorline(hgfx, startPoint, stopPoint, CLUT_LogbookTemperature); | |
1192 } | |
1193 | |
1194 //--- define buttons --- | |
1195 //button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next); | |
1196 } | |
1197 | |
1198 void print_gas_name(char* output,uint8_t length,uint8_t oxygen,uint8_t helium) | |
1199 { | |
1200 if(helium == 0) | |
1201 { | |
1202 if(oxygen == 21) | |
1203 snprintf(output, length, "Air"); | |
1204 else if(oxygen == 100) | |
1205 snprintf(output, length, "Oxy"); | |
1206 else | |
1207 snprintf(output, length, "NX%i",oxygen); | |
1208 } | |
1209 else | |
1210 { | |
1211 if((oxygen + helium) == 100) | |
1212 snprintf(output, length, "HX%i",oxygen); | |
1213 else | |
1214 snprintf(output, length, "TMX%i/%i", oxygen, helium); | |
1215 } | |
1216 | |
1217 } | |
1218 | |
1219 int16_t get_colour(int16_t color) | |
1220 { | |
1221 return CLUT_GasSensor1 + color; | |
1222 } |