Mercurial > public > ostc4
annotate Discovery/Src/show_logbook.c @ 534:39684aa19f28
Added tag 1.5.5 release for changeset 02e7e11fdbe8
author | heinrichsweikamp |
---|---|
date | Sun, 04 Oct 2020 15:50:43 +0200 |
parents | eea282e733e8 |
children | 1c95f811967c |
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" | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
36 #include "configuration.h" |
38 | 37 |
38 #include <stdint.h> | |
39 #include <stdio.h> | |
40 #include <stdlib.h> // for abs() | |
41 | |
484 | 42 #define LOG_BORDER_OFFSET (50u) /* text offset from left / right display to text start/end */ |
43 | |
38 | 44 /* Private variables ---------------------------------------------------------*/ |
45 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
46 static GFX_DrawCfgScreen tLOGscreen; |
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
47 static GFX_DrawCfgScreen tLOGbackground; |
38 | 48 |
49 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
50 static void print_gas_name(char* output,uint8_t lengh,uint8_t oxygen,uint8_t helium); |
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
51 static int16_t get_colour(int16_t color); |
38 | 52 |
53 /* Overview */ | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
54 static void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); |
38 | 55 /* Temperature */ |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
56 static void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); |
38 | 57 /* Gas List */ |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
58 static void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); |
38 | 59 /* ppO2 */ |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
60 static void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards); |
38 | 61 |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
62 static inline uint32_t MaxU32LOG(uint32_t a, uint32_t b) |
38 | 63 { |
64 return((a>b)?a:b); | |
65 } | |
66 | |
67 /** | |
68 ****************************************************************************** | |
69 * @brief GFX write label. / print coordinate system & depth graph | |
70 * @author Peter Ryser | |
71 * @version V0.0.1 | |
72 * @date 07-July-2014 | |
73 ****************************************************************************** | |
74 * | |
75 * @param hgfx: | |
76 * @param window: WindowGimpStyle | |
77 * @param mode: different modes depending witch page uses the function | |
78 * @param dataLength: | |
79 * @param depthdata: | |
80 * @param colordata: 1 | |
81 * @retval None | |
82 */ | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
83 static 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) |
38 | 84 { |
85 SLogbookHeader logbookHeader; | |
86 SWindowGimpStyle wintemp = *window; | |
87 SWindowGimpStyle winsmal; | |
88 logbook_getHeader(StepBackwards, &logbookHeader); | |
89 int divetime = logbookHeader.diveTimeMinutes; | |
90 int maxDepth = logbookHeader.maxDepth/100; | |
91 | |
92 int16_t saveBottom = wintemp.bottom; | |
93 int16_t saveTop = 0 - wintemp.top; | |
94 | |
95 //*** Horisontal (depth) *************************************************** | |
96 | |
97 //--- calc depth lines and labels -- | |
98 int vscale = 0; | |
99 int vstep = 0; | |
100 | |
101 vstep = maxDepth / 5; | |
102 vscale = vstep * 5; | |
103 if(vscale < maxDepth) | |
104 { | |
105 vstep += 1; | |
106 vscale += 5; | |
107 } | |
108 /* | |
109 if(vscale < | |
110 for(int i=1; i <= 20; i++) | |
111 { | |
112 vscale = i * 25; | |
113 vstep = i * 5; | |
114 if( vscale > maxDepth) | |
115 break; | |
116 } | |
117 */ | |
118 //--- print depth labels --- | |
119 winsmal.left = wintemp.left - 48; | |
120 winsmal.top = wintemp.top - 3; | |
121 winsmal.right = wintemp.left -1; | |
122 winsmal.bottom = winsmal.top + 16; | |
123 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
124 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
|
125 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
126 // winsmal.left = wintemp.left - 48; |
38 | 127 char msg[3]; |
128 float deltaline = ((float)(wintemp.bottom - wintemp.top))/5; | |
129 for(int i = 1; i<=5; i++) | |
130 { | |
131 winsmal.top = wintemp.top + deltaline * i - 14; | |
132 winsmal.bottom = winsmal.top + 16; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
133 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
134 // winsmal.right = wintemp.left - 2; |
38 | 135 snprintf(msg,5,"%i",i * vstep); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
136 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor1,msg); |
38 | 137 } |
138 | |
139 //vertical (Time) ******************************************************************* | |
140 //--- calc time lines and labels -- | |
141 int timestep = 0; | |
142 int lines = 0; | |
143 for(int i=1; i <= 60; i++) | |
144 { | |
145 timestep = i * 5; | |
146 lines = divetime/timestep; | |
147 if(lines < 7) | |
148 { | |
149 break; | |
150 } | |
151 } | |
152 //*** print coordinate system grit *** | |
153 int winwidth = wintemp.right - wintemp.left; | |
154 float vdeltaline = ((float)(winwidth * timestep))/divetime; | |
155 GFX_draw_Grid( &tLOGbackground,wintemp, 0, vdeltaline, 5,0, CLUT_LogbookGrid); | |
156 | |
157 | |
158 //--- print time labels --- | |
159 winsmal.left = wintemp.left; | |
160 winsmal.top = wintemp.top - 40; | |
161 winsmal.right = winsmal.left + 60; | |
162 winsmal.bottom = winsmal.top + 16; | |
163 | |
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,"min"); |
38 | 165 for(int i = 1; i<=lines; i++) |
166 { | |
167 winsmal.left= wintemp.left + vdeltaline * i - 15; | |
168 winsmal.right = winsmal.left + 30; | |
169 snprintf(msg,5,"%3i",i * timestep); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
170 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor1,msg); |
38 | 171 } |
172 winsmal.left = wintemp.left;// - 9; | |
173 winsmal.top = wintemp.top - 40; | |
174 winsmal.right = winsmal.left + 60; | |
175 | |
176 //--- print depth graph --- | |
177 //adapt window | |
178 int winhight = wintemp.bottom - wintemp.top; | |
179 int newhight = (winhight * maxDepth)/vscale; | |
180 wintemp.bottom = wintemp.top + newhight; | |
181 //wintemp.fontcolor = LOGBOOK_GRAPH_DEPTH; | |
182 | |
183 int datamax = 0; | |
184 for(int i=0;i<dataLength;i++) | |
185 { | |
186 if(depthdata[i]>datamax) | |
187 datamax = depthdata[i]; | |
188 } | |
189 | |
190 if(decostopdata) | |
191 { | |
192 if(dataLength <= 1000) | |
193 { | |
194 uint8_t colortemp[1000]; | |
195 | |
196 for(int i = 0; i<dataLength; i++) | |
197 { | |
198 if(decostopdata[i] > depthdata[i]) | |
199 { | |
200 colortemp[i] = CLUT_WarningRed; | |
201 } | |
202 else | |
203 { | |
204 colortemp[i] = CLUT_NiceGreen; | |
205 } | |
206 } | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
150
diff
changeset
|
207 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, 0, colortemp); |
38 | 208 } |
209 else | |
210 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, CLUT_NiceGreen, NULL); | |
211 } | |
212 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
213 if(settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
214 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
215 winsmal.right = 800 - wintemp.left; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
216 winsmal.left = 800 - wintemp.right; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
217 winsmal.bottom = wintemp.bottom; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
218 winsmal.top = wintemp.top; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
219 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
220 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
221 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
222 winsmal.right = wintemp.right; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
223 winsmal.left = wintemp.left; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
224 winsmal.bottom = wintemp.bottom; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
225 winsmal.top = wintemp.top; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
226 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
227 |
38 | 228 switch(mode) |
229 { | |
230 case 0: | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
231 GFX_graph_print(hgfx,&winsmal,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL); |
38 | 232 break; |
233 case 1: | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
234 GFX_graph_print(hgfx,&winsmal,saveBottom,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata); |
38 | 235 break; |
236 case 2: | |
237 if(*colordata) | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
238 GFX_graph_print(hgfx,&winsmal,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata); |
38 | 239 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
240 GFX_graph_print(hgfx,&winsmal,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL); |
38 | 241 } |
242 } | |
243 | |
244 | |
245 | |
246 /** | |
247 ****************************************************************************** | |
248 * @brief scaleAdapt | |
249 * @author heinrichs weikamp gmbh | |
250 * @version V0.0.1 | |
251 * @date 29-Nov-2016 | |
252 ****************************************************************************** | |
253 * | |
254 * @param ... | |
255 * @retval *OutputStepOfScale, *OutputMaxValueOnScale, *OutputTop, *OutputBottom | |
256 | |
257 * fit to multiples of 1�C (data format is 1/10�C) | |
258 */ | |
259 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
260 static void scaleAdapt( int InputTop, int InputBottom, |
38 | 261 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom, |
262 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale) | |
263 { | |
264 // uint16_t oldScale; | |
265 uint16_t newScale; | |
266 // uint16_t diff_newScale; | |
267 | |
268 // int16_t oldMaxOnScale; | |
269 int16_t newMaxOnScale; | |
270 // int16_t diff_newMaxOnScale; | |
271 _Bool negativeMaxValue = 0; | |
272 | |
273 // float oldRange; | |
274 float newRange; | |
275 | |
276 float sizeOfScreen; | |
277 // float InputTopValue; | |
278 // float InputBottomValue; | |
279 float screenToRangeRatio; | |
280 float diffOutMaxToMaxOnScale; | |
281 float diffOutMinToMaxOnScale; | |
282 int positonOutputMaxValue; | |
283 int positonOutputMinValue; | |
284 | |
285 | |
286 // scale | |
287 // oldScale = *OutputStepOfScale; | |
288 newScale = *OutputStepOfScale + 9; | |
289 newScale /= 10; | |
290 newScale *= 10; | |
291 // diff_newScale = newScale - *OutputStepOfScale; | |
292 // oldRange = 5 * oldScale; | |
293 newRange = 5 * newScale; | |
294 *OutputStepOfScale = newScale; | |
295 | |
296 // MaxValueOnScale | |
297 // oldMaxOnScale = *OutputMaxValueOnScale; | |
298 if(OutputMaxValueOnScale < 0) | |
299 { | |
300 negativeMaxValue = 1; | |
301 newMaxOnScale = 0 - *OutputMaxValueOnScale; | |
302 } | |
303 else | |
304 { | |
305 negativeMaxValue = 0; | |
306 newMaxOnScale = *OutputMaxValueOnScale; | |
307 } | |
308 newMaxOnScale += 9; | |
309 newMaxOnScale /= 10; | |
310 newMaxOnScale *= 10; | |
311 if(negativeMaxValue) | |
312 { | |
313 // diff_newMaxOnScale = newMaxOnScale + *OutputMaxValueOnScale; | |
314 *OutputMaxValueOnScale = 0 - newMaxOnScale; | |
315 } | |
316 else | |
317 { | |
318 // diff_newMaxOnScale = newMaxOnScale - *OutputMaxValueOnScale; | |
319 *OutputMaxValueOnScale = newMaxOnScale; | |
320 } | |
321 | |
322 | |
323 // new coordinates | |
324 sizeOfScreen = 1 + InputBottom - InputTop; | |
325 // InputTopValue = *OutputMaxValueOnScale; | |
326 // InputBottomValue = InputTopValue + (6 * *OutputStepOfScale); | |
327 | |
328 screenToRangeRatio = sizeOfScreen / newRange; | |
329 diffOutMaxToMaxOnScale = abs(*OutputMaxValueOnScale) - abs(*OutputMaxValue); | |
330 // diffOutMinToMax = abs(*OutputMinValue - *OutputMaxValue); | |
331 diffOutMinToMaxOnScale = abs(*OutputMaxValueOnScale - *OutputMinValue); | |
332 | |
333 positonOutputMaxValue = (int)(diffOutMaxToMaxOnScale * screenToRangeRatio); | |
334 positonOutputMaxValue += *OutputTop; | |
335 positonOutputMinValue = (int)(diffOutMinToMaxOnScale * screenToRangeRatio); | |
336 positonOutputMinValue += *OutputTop; | |
337 // positonOutputMinValue = (int)(diffOutMinToMax * screenToRangeRatio); | |
338 // positonOutputMinValue += positonOutputMaxValue; | |
339 *OutputTop = positonOutputMaxValue; | |
340 *OutputBottom = positonOutputMinValue; | |
341 } | |
342 | |
343 | |
344 /** | |
345 ****************************************************************************** | |
346 * @brief scaleHelper | |
347 * @author heinrichs weikamp gmbh | |
348 * @version V0.0.1 | |
349 * @date 13-Oct-2016 | |
350 ****************************************************************************** | |
351 * | |
352 * @param hgfx: | |
353 * @retval None | |
354 | |
355 * pixel 50 oben | |
356 * pixel 439 unten | |
357 * pixel 390 gesamt h�he | |
358 | |
359 * for temperature, input is �C * 10 | |
360 */ | |
361 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
362 static void scaleHelper( uint16_t InputDataLength, int16_t *InputDataArray, int InputTop, int InputBottom, |
38 | 363 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom, |
364 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale) | |
365 { | |
366 int32_t datamin = INT16_MAX; // 32 bit for delta calculation ( delta is unsigned -> value can be 2x INT16_MAX) | |
367 int32_t datamax = INT16_MIN; | |
368 uint16_t deltaMinMax = 1; | |
369 // uint16_t deltaMinMaxUsed = 1; | |
370 // uint16_t digits = 1; | |
371 // uint16_t scaler = 1; | |
372 uint32_t step = 1; | |
373 const int sizeOfScreen = InputBottom - InputTop; | |
374 float pixel2range = 1.0; | |
375 | |
376 // min, max, deltaMinMax, OutputMinValue, OutputMaxValue | |
377 for(uint16_t i = 0; i < InputDataLength; i++) | |
378 { | |
379 if(InputDataArray[i] > datamax) | |
380 datamax = InputDataArray[i]; | |
381 | |
382 if(InputDataArray[i] < datamin) | |
383 datamin = InputDataArray[i]; | |
384 } | |
385 | |
386 deltaMinMax = (uint16_t)(datamax - datamin); | |
387 | |
388 *OutputMinValue = (int16_t)datamin; | |
389 *OutputMaxValue = (int16_t)datamax; | |
390 | |
391 // step | |
392 step = deltaMinMax / 5; | |
393 while(deltaMinMax > (step * 5)) | |
394 { | |
395 step += 1; | |
396 } | |
397 pixel2range = ((float)sizeOfScreen) / (step * 5); | |
398 | |
399 *OutputStepOfScale = (uint16_t)step; | |
400 *OutputMaxValueOnScale = *OutputMaxValue; | |
401 *OutputTop = InputTop; | |
402 *OutputBottom = ((int)(pixel2range * deltaMinMax)) + *OutputTop; | |
403 } | |
404 | |
405 /** | |
406 ****************************************************************************** | |
407 * @brief show_logbook_logbook_show_log_page1 / | |
408 * @author Peter Ryser | |
409 * @version V0.0.1 | |
410 * @date 07-July-2014 | |
411 ****************************************************************************** | |
412 * | |
413 * @param hgfx: | |
414 * @retval None | |
415 */ | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
416 static void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx,uint8_t StepBackwards) |
38 | 417 { |
418 SWindowGimpStyle wintemp; | |
419 SWindowGimpStyle winsmal; | |
484 | 420 wintemp.left = LOG_BORDER_OFFSET; |
38 | 421 wintemp.right = 799 - wintemp.left; |
484 | 422 wintemp.top = LOG_BORDER_OFFSET; |
38 | 423 wintemp.bottom = 479 - 40; |
424 | |
425 SLogbookHeader logbookHeader; | |
426 logbook_getHeader(StepBackwards ,&logbookHeader); | |
427 | |
428 uint16_t depthdata[1000] = { 0 }; | |
429 uint8_t gasdata[1000] = { 0 }; | |
430 int16_t tempdata[1000] = { 0 }; | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
431 uint16_t tankdata[1000] = { 0 }; |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
432 |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
433 #ifdef ENABLE_BOTTLE_SENSOR |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
434 uint16_t bottlePressureStart = 0; |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
435 uint16_t bottlePressureEnd = 0; |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
436 uint16_t loop = 0; |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
437 #endif |
38 | 438 |
439 uint16_t dataLength = 0; | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
440 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tankdata); |
38 | 441 |
442 //Print Date | |
443 uint8_t year = logbookHeader.dateYear; | |
444 uint8_t month = logbookHeader.dateMonth; | |
445 uint8_t day = logbookHeader.dateDay; | |
446 char text[40]; | |
447 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
|
448 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
449 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
|
450 |
38 | 451 |
452 // Print logbook number with offset | |
453 if(settingsGetPointer()->logbookOffset) | |
454 { | |
455 int32_t logNumber; | |
456 logNumber = settingsGetPointer()->logbookOffset - StepBackwards; | |
457 if(logNumber < 0) | |
458 logNumber = 0; | |
459 else | |
460 if(logNumber > 9999) | |
461 logNumber = 9999; | |
462 | |
457 | 463 snprintf(text,20,"#%ld",logNumber); |
38 | 464 Gfx_write_label_var(hgfx, 300, 590,10, &FontT42,CLUT_GasSensor1,text); |
465 } | |
466 | |
467 //Print time | |
468 uint8_t hour = logbookHeader.timeHour; | |
469 uint8_t minute = logbookHeader.timeMinute; | |
484 | 470 snprintf(text,20,"\002%02i:%02i",hour,minute); |
471 Gfx_write_label_var(hgfx, 600, wintemp.right,10, &FontT42,CLUT_GasSensor1,text); | |
38 | 472 |
473 //Print Dive Mode (OC/CCR/...) | |
474 switch(logbookHeader.diveMode) | |
475 { | |
476 case DIVEMODE_OC: | |
477 snprintf(text,20,"open circuit"); | |
478 break; | |
479 case DIVEMODE_CCR: | |
480 snprintf(text,20,"closed circuit"); | |
481 break; | |
482 case DIVEMODE_Gauge: | |
483 snprintf(text,20,"Gauge"); | |
484 break; | |
485 case DIVEMODE_Apnea: | |
486 snprintf(text,20,"Apnea"); | |
487 break; | |
488 } | |
489 Gfx_write_label_var(hgfx, 30, 250,60, &FontT42,CLUT_GasSensor4,text); | |
490 | |
491 // Decomodel | |
492 if(logbookHeader.diveMode <= DIVEMODE_CCR) | |
493 { | |
494 switch(logbookHeader.decoModel) | |
495 { | |
496 case GF_MODE: | |
497 snprintf(text,20,"\002GF%u/%u",logbookHeader.gfLow_or_Vpm_conservatism,logbookHeader.gfHigh); | |
484 | 498 break; |
38 | 499 case VPM_MODE: |
500 snprintf(text,20,"\002VPM +%u",logbookHeader.gfLow_or_Vpm_conservatism); | |
484 | 501 break; |
502 default: | |
503 snprintf(text,20," "); /* no information to be displayed */ | |
504 break; | |
38 | 505 } |
484 | 506 Gfx_write_label_var(hgfx, 500, wintemp.right,60, &FontT42,CLUT_GasSensor1,text); |
38 | 507 } |
508 | |
509 //Write Dive Time | |
510 int minutes = logbookHeader.diveTimeMinutes; | |
511 int seconds = logbookHeader.diveTimeSeconds; | |
512 int hours = minutes/60; | |
513 minutes -= hours * 60; | |
514 snprintf(text,20,"%02i:%02i:%02i",hours,minutes,seconds); | |
515 Gfx_write_label_var(hgfx, 30, 250,360, &FontT42,CLUT_GasSensor1,text); | |
516 Gfx_write_label_var(hgfx, 200, 250,360, &FontT42,CLUT_GasSensor4,"s"); | |
517 | |
518 // Max Depth | |
519 int maxdepth =logbookHeader.maxDepth/100; | |
520 int maxdepth_dcm = logbookHeader.maxDepth/10 - maxdepth * 10; | |
521 int top = 150; | |
522 if(settingsGetPointer()->nonMetricalSystem) | |
523 { | |
524 float maxDepthFeet = 0; | |
525 maxDepthFeet = unit_depth_float(((float)logbookHeader.maxDepth)/100); | |
526 snprintf(text,20,"%.0f",maxDepthFeet); | |
527 } | |
528 else | |
529 { | |
530 snprintf(text,20,"%i.%i",maxdepth,maxdepth_dcm); | |
531 } | |
532 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text); | |
533 winsmal.left = 30; | |
534 winsmal.top = top -3; | |
535 winsmal.bottom = winsmal.top + FontT42.height; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
536 |
38 | 537 if(maxdepth < 10) |
538 { | |
539 winsmal.left = 137; | |
540 } | |
541 else if(maxdepth < 100) | |
542 { | |
543 winsmal.left = 151; | |
544 } | |
545 else | |
546 { | |
547 winsmal.left = 147; | |
548 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
549 winsmal.right = winsmal.left + 50; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
550 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
551 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,top, &FontT24,CLUT_GasSensor4,"max"); |
38 | 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); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
573 |
38 | 574 winsmal.left = 30; |
575 winsmal.top = top -3; | |
576 winsmal.bottom = winsmal.top + FontT42.height; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
577 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
578 /* put avg behind previous string */ |
38 | 579 if(avrdepth < 10) |
580 { | |
581 winsmal.left = 137 ; | |
582 } | |
583 else if(avrdepth < 100) | |
584 { | |
585 winsmal.left = 151; | |
586 } | |
587 else | |
588 { | |
589 winsmal.left = 147; | |
590 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
591 winsmal.right = winsmal.left + 50; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
592 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
593 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor4,"avg"); |
38 | 594 snprintf(text,3,"%c%c" |
595 , unit_depth_char1() | |
596 , unit_depth_char2() | |
597 ); | |
598 Gfx_write_label_var(hgfx, winsmal.left - 37, 250,top, &FontT42,CLUT_GasSensor4,text); | |
599 // Temperature | |
600 top+= 50; | |
601 float temp_Temperature; | |
602 uint16_t start; | |
603 temp_Temperature = ((float)logbookHeader.minTemp)/10; | |
604 snprintf(text,20,"%.1f",unit_temperature_float(temp_Temperature)); | |
605 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text); | |
606 | |
607 if(settingsGetPointer()->nonMetricalSystem) | |
608 start = 121; | |
609 else if((logbookHeader.minTemp >= 0) && (logbookHeader.minTemp < 10)) | |
610 start = 100; | |
611 else if((logbookHeader.minTemp >= -10) && (logbookHeader.minTemp < 100)) | |
612 start = 114; | |
613 else | |
614 start = 121; | |
615 | |
616 text[0] = '\140'; | |
617 if(settingsGetPointer()->nonMetricalSystem) | |
618 text[1] = 'F'; | |
619 else | |
620 text[1] = 'C'; | |
621 text[2] = 0; | |
622 | |
623 Gfx_write_label_var(hgfx, start, 300,top, &FontT42,CLUT_GasSensor4,text); | |
624 | |
625 // CNS | |
626 snprintf(text,20,"CNS: %i %%",logbookHeader.maxCNS); | |
150
097d7146b779
Place CNS and pressure within the screen (avoid clipping)
Ideenmodellierer
parents:
115
diff
changeset
|
627 Gfx_write_label_var(hgfx, 30, 250,440, &FontT42,CLUT_GasSensor1,text); |
38 | 628 |
629 // Surface Pressure | |
630 // snprintf(text,20,"\001%i\016\016 mbar",logbookHeader.surfacePressure_mbar); | |
631 // Gfx_write_label_var(hgfx,300,500,750, &FontT42,CLUT_GasSensor1,text); | |
632 // 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
|
633 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
|
634 Gfx_write_label_var(hgfx,320,600,440, &FontT42,CLUT_GasSensor1,text); |
38 | 635 |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
636 /* Show tank info */ |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
637 #ifdef ENABLE_BOTTLE_SENSOR |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
638 for(loop = 0; loop < dataLength; loop++) |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
639 { |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
640 if((bottlePressureStart == 0) && (tankdata[loop] != 0)) /* find first pressure value */ |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
641 { |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
642 bottlePressureStart = tankdata[loop]; |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
643 } |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
644 if((tankdata[loop] != 0)) /* store last pressure value */ |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
645 { |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
646 bottlePressureEnd = tankdata[loop]; |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
647 } |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
648 } |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
649 if(bottlePressureStart != 0) |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
650 { |
484 | 651 snprintf(text,40,"\002%i | %i\016\016 Bar\017",bottlePressureStart,bottlePressureEnd); |
652 Gfx_write_label_var(hgfx,450,wintemp.right,440, &FontT42,CLUT_GasSensor1,text); | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
653 } |
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
654 #endif |
38 | 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 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
664 static void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) |
38 | 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 | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
685 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, decoDepthdata, NULL); |
38 | 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 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
754 static void build_logbook_test(uint8_t page, uint8_t StepBackwards) |
38 | 755 { |
756 uint32_t lastScreen,lastBackground; | |
757 | |
758 lastScreen = tLOGscreen.FBStartAdress; | |
759 lastBackground = tLOGbackground.FBStartAdress; | |
760 | |
761 tLOGscreen.FBStartAdress = getFrame(16); | |
762 tLOGscreen.ImageHeight = 480; | |
763 tLOGscreen.ImageWidth = 800; | |
764 tLOGscreen.LayerIndex = 1; | |
765 | |
766 tLOGbackground.FBStartAdress = getFrame(17); | |
767 tLOGbackground.ImageHeight = 480; | |
768 tLOGbackground.ImageWidth = 800; | |
769 tLOGbackground.LayerIndex = 0; | |
770 switch(page) | |
771 { | |
772 case 1: | |
773 show_logbook_logbook_show_log_page1(&tLOGscreen,StepBackwards); | |
774 break; | |
775 case 2: | |
776 show_logbook_logbook_show_log_page2(&tLOGscreen,StepBackwards); | |
777 break; | |
778 case 3: | |
779 show_logbook_logbook_show_log_page3(&tLOGscreen,StepBackwards); | |
780 break; | |
781 case 4: | |
782 show_logbook_logbook_show_log_page4(&tLOGscreen,StepBackwards); | |
783 break; | |
784 } | |
785 | |
786 releaseFrame(16,lastScreen); | |
787 releaseFrame(17,lastBackground); | |
788 } | |
789 | |
790 | |
791 void show_logbook_test(_Bool firstPage, uint8_t StepBackwards) | |
792 { | |
793 static uint8_t page = 1; | |
794 if(firstPage) | |
795 { | |
796 page = 1; | |
797 } | |
798 else | |
799 { | |
800 page++; | |
801 if(page > 4) | |
802 page = 1; | |
803 } | |
804 | |
805 build_logbook_test(page,StepBackwards); | |
806 // GFX_ResetLayer(TOP_LAYER); | |
807 // GFX_ResetLayer(BACKGRD_LAYER); | |
808 | |
809 set_globalState(StILOGSHOW); | |
810 GFX_SetFramesTopBottom(tLOGscreen.FBStartAdress, tLOGbackground.FBStartAdress,480); | |
811 } | |
812 | |
813 | |
814 void show_logbook_exit(void) | |
815 { | |
816 releaseFrame(16,tLOGscreen.FBStartAdress); | |
817 releaseFrame(17,tLOGbackground.FBStartAdress); | |
818 } | |
819 | |
820 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
821 static void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) |
38 | 822 { |
823 SWindowGimpStyle wintemp; | |
824 SWindowGimpStyle winsmal; | |
825 wintemp.left = 50; | |
826 wintemp.right = 799 - wintemp.left; | |
827 wintemp.top = 50; | |
828 wintemp.bottom = 479 - 40; | |
829 | |
830 SLogbookHeader logbookHeader; | |
831 | |
832 logbook_getHeader(StepBackwards, &logbookHeader); | |
833 uint16_t dataLength = 0; | |
834 uint16_t depthdata[1000]; | |
835 uint8_t gasdata[1000]; | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
836 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
38 | 837 |
838 //--- print coordinate system & depth graph with gaschanges --- | |
839 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL); | |
840 | |
841 //--- print gas list --- | |
842 winsmal.left = wintemp.right - 190; | |
843 winsmal.right = winsmal.left + 150; | |
844 | |
845 char msg[15]; | |
846 char gas_name[15]; | |
847 int j = 0; | |
848 for(int i = 4;i >= 0;i--) | |
849 { | |
850 if(logbookHeader.gasordil[i].note.ub.active > 0) | |
851 { | |
852 j++; | |
853 winsmal.top = wintemp.bottom - 5 - j * 26 ; | |
854 winsmal.bottom = winsmal.top + 21 ; | |
855 uint8_t color = get_colour(i); | |
856 | |
857 print_gas_name(gas_name,15,logbookHeader.gasordil[i].oxygen_percentage,logbookHeader.gasordil[i].helium_percentage); | |
858 snprintf(msg,15,"G%i: %s",i + 1, gas_name); | |
859 //msg[10] = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
860 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,msg); |
38 | 861 } |
862 } | |
863 | |
864 //--- define buttons --- | |
865 /*if(*ghost_char_logfile_oxydata) | |
866 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page4, surf1_menu_logbook_show_log_next); | |
867 else | |
868 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next); | |
869 */ | |
870 } | |
871 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
872 static void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) |
38 | 873 { SWindowGimpStyle wintemp; |
874 SWindowGimpStyle winsmal; | |
875 wintemp.left = 50; | |
876 wintemp.right = 799 - wintemp.left; | |
877 wintemp.top = 50; | |
878 wintemp.bottom = 479 - 40; | |
879 uint8_t color = 0; | |
880 SLogbookHeader logbookHeader; | |
881 | |
882 logbook_getHeader(StepBackwards, &logbookHeader); | |
883 uint16_t dataLength = 0; | |
884 uint16_t depthdata[1000]; | |
885 uint8_t gasdata[1000]; | |
886 uint16_t ppO2data[1000]; | |
887 uint16_t sensor2[1000]; | |
888 uint16_t sensor3[1000]; | |
889 uint16_t *setpoint = ppO2data; | |
890 uint16_t *sensor1 = ppO2data; | |
891 | |
892 | |
893 if(logbookHeader.diveMode != DIVEMODE_CCR) | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
894 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, ppO2data, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
38 | 895 else |
896 { | |
897 if(logbookHeader.CCRmode == CCRMODE_FixedSetpoint) | |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
898 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, setpoint, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
38 | 899 else |
454
5a633dece17a
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
186
diff
changeset
|
900 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, NULL, sensor1, sensor2, sensor3, NULL, NULL, NULL, NULL); |
38 | 901 } |
902 | |
903 | |
904 //--- print coordinate system & depth graph with bailout--- | |
905 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, NULL); | |
906 | |
907 | |
908 | |
909 //*** Desciption at bottom of page *************************** | |
910 winsmal.top = wintemp.bottom +2 ; | |
911 winsmal.bottom = winsmal.top + 16; | |
912 | |
913 | |
914 /*if(strcmp( (char*)ghost_char_logfile_text_oc_ccr,"ccr/bailout") == 0) | |
915 { | |
916 winsmal.left = wintemp.left + 2; | |
917 winsmal.right = winsmal.left + 55; | |
918 | |
919 oled_write(OVERLAY, &winsmal,"CCR -",false,true); | |
920 | |
921 winsmal.left = winsmal.right; | |
922 winsmal.right = winsmal.left + 90; | |
923 //winsmal.fontcolor = oled_get_colour(15); | |
924 oled_write(OVERLAY, &winsmal,"bailout",false,true); | |
925 } | |
926 else*/ | |
927 { | |
928 winsmal.left = wintemp.left + 2; | |
929 winsmal.right = winsmal.left + 55; | |
930 color = CLUT_GasSensor1;//LOGBOOK_GRAPH_DEPTH; | |
931 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
932 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"depth"); |
38 | 933 |
934 } | |
935 winsmal.left = 799 - 67;//wintemp.right -67; | |
936 winsmal.right = winsmal.left;// + 45; | |
937 | |
938 color = CLUT_LogbookTemperature;//LOGBOOK_GRAPH_DEPTH; | |
939 if(logbookHeader.diveMode != DIVEMODE_CCR) | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
940 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002PP O2"); |
38 | 941 else |
942 if(logbookHeader.CCRmode != CCRMODE_Sensors) | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
943 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002SETPOINT"); |
38 | 944 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
945 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002SENSORS"); |
38 | 946 |
947 //*** PP O2 **************************************************** | |
948 //calc lines and labels | |
949 int datamax = 0; | |
950 int datamin = 10000; | |
951 for(int i=1;i<dataLength;i++) | |
952 { | |
953 if(ppO2data[i]>datamax) | |
954 datamax = ppO2data[i]; | |
955 if(ppO2data[i]<datamin) | |
956 datamin = ppO2data[i]; | |
957 } | |
958 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors)) | |
959 { | |
960 for(int i=1;i<dataLength;i++) | |
961 { | |
962 if(sensor2[i]>datamax) | |
963 datamax = sensor2[i]; | |
964 if(sensor2[i]<datamin) | |
965 datamin = sensor2[i]; | |
966 if(sensor3[i]>datamax) | |
967 datamax = sensor3[i]; | |
968 if(sensor3[i]<datamin) | |
969 datamin = sensor3[i]; | |
970 } | |
971 } | |
972 float maxoxy = ((float)datamax)/100; | |
973 float minoxy = ((float)datamin)/100; | |
974 float oxystep = 0.5; | |
975 float maxoxyline = 2.5; | |
976 | |
977 //--- print PP O2 labels ---- | |
978 winsmal.left = wintemp.right + 2; | |
979 winsmal.top = wintemp.top ; | |
980 winsmal.right = wintemp.right + 30; | |
981 winsmal.bottom = winsmal.top + 16; | |
982 //winsmal.font = ft_tiny + ft_SLIM; | |
983 color = CLUT_LogbookTemperature;// = LOGBOOK_GRAPH_TEMP; | |
984 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
985 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"bar"); |
38 | 986 |
987 int deltaline = (wintemp.bottom - wintemp.top)/5; | |
988 char msg[4]; | |
989 float oxy = maxoxyline; | |
990 for(int i = 1; i<=5; i++) | |
991 { | |
992 oxy -= oxystep; | |
993 if(oxy < 0) | |
994 break; | |
995 winsmal.top = wintemp.top + deltaline * i - 8; | |
996 winsmal.bottom = winsmal.top + 16; | |
997 snprintf(msg,4,"%1.1f",oxy); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
998 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,msg); |
38 | 999 //oled_write(OVERLAY, &winsmal,msg,false,true); |
1000 } | |
1001 | |
1002 //--- print PP O2 graph --- | |
1003 //Adapt window | |
1004 float ftmp = ((maxoxyline - minoxy) * deltaline) /oxystep + wintemp.top; | |
1005 wintemp.bottom = ftmp; | |
1006 if((ftmp - (int)ftmp) >= 0.5f) | |
1007 wintemp.bottom++; | |
1008 | |
1009 ftmp = wintemp.top + ((maxoxyline - maxoxy) * deltaline) /oxystep; | |
1010 wintemp.top = ftmp; | |
1011 if((ftmp - (int)ftmp) >= 0.5f) | |
1012 wintemp.top++; | |
1013 wintemp.top = MaxU32LOG(wintemp.top ,0); | |
1014 if(wintemp.top < wintemp.bottom) | |
1015 { | |
1016 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors)) | |
1017 { | |
1018 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL); | |
1019 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor2,dataLength,CLUT_LogbookTemperature, NULL); | |
1020 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor3,dataLength,CLUT_LogbookTemperature, NULL); | |
1021 } | |
1022 else | |
1023 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL); | |
1024 } | |
1025 else | |
1026 { | |
1027 point_t startPoint, stopPoint; | |
1028 startPoint.x = wintemp.left; | |
1029 stopPoint.x = wintemp.right; | |
1030 stopPoint.y = startPoint.y = 479 - wintemp.top; | |
1031 GFX_draw_colorline(hgfx, startPoint, stopPoint, CLUT_LogbookTemperature); | |
1032 } | |
1033 | |
1034 //--- define buttons --- | |
1035 //button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next); | |
1036 } | |
1037 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
1038 static void print_gas_name(char* output,uint8_t length,uint8_t oxygen,uint8_t helium) |
38 | 1039 { |
1040 if(helium == 0) | |
1041 { | |
1042 if(oxygen == 21) | |
1043 snprintf(output, length, "Air"); | |
1044 else if(oxygen == 100) | |
1045 snprintf(output, length, "Oxy"); | |
1046 else | |
1047 snprintf(output, length, "NX%i",oxygen); | |
1048 } | |
1049 else | |
1050 { | |
1051 if((oxygen + helium) == 100) | |
1052 snprintf(output, length, "HX%i",oxygen); | |
1053 else | |
1054 snprintf(output, length, "TMX%i/%i", oxygen, helium); | |
1055 } | |
1056 | |
1057 } | |
1058 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
1059 static int16_t get_colour(int16_t color) |
38 | 1060 { |
1061 return CLUT_GasSensor1 + color; | |
1062 } |