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