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