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