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