Mercurial > public > ostc4
annotate Discovery/Src/show_logbook.c @ 655:980b4aa60a0e
Added count down timer for scrubber time:
The countdown is performed in case CCR mode and scrubber timer are active
author | Ideenmodellierer |
---|---|
date | Sun, 25 Apr 2021 20:42:56 +0200 |
parents | 269e57ac4e56 |
children | 1b995079c045 |
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; |
632 | 138 char msg[10]; |
38 | 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; |
632 | 146 snprintf(msg,10,"%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; | |
632 | 180 snprintf(msg,10,"%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; | |
653 | 777 int16_t tmp = 0; |
38 | 778 |
779 scaleHelper(dataLength, tempdata, wintemp.top, wintemp.bottom, | |
780 &minVal, &maxVal, &newTop, &newBottom, | |
781 &step, &maxValTop); // newTop is wintemp.top | |
782 | |
783 scaleAdapt( wintemp.top, wintemp.bottom, | |
784 &minVal, &maxVal, &newTop, &newBottom, | |
785 &step, &maxValTop); | |
786 | |
787 // temperature in 1/10 �C | |
788 int deltaline = (1 + wintemp.bottom - wintemp.top)/5; | |
632 | 789 char msg[15]; |
653 | 790 |
791 /* temperature is provided in centi scaling => convert */ | |
792 maxValTop /= 10; | |
793 step /= 10; | |
794 | |
795 tmp = maxValTop; | |
38 | 796 for(int i = 1; i<=5; i++) |
797 { | |
798 tmp -= step; | |
799 winsmal.top = wintemp.top + deltaline * i - 14; | |
800 winsmal.bottom = winsmal.top + 16; | |
653 | 801 snprintf(msg,15,"%2i",unit_temperature_integer(tmp)); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
802 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_LogbookTemperature,msg); |
38 | 803 } |
804 | |
805 | |
806 //--- print temperature graph --- | |
807 // input tempdata[i], maxtmpline, mintmpline, maxTmp, minTmp, deltaline, wintemp.top, dataLength, datamax, | |
808 | |
809 //adapt window | |
810 wintemp.bottom = newBottom; | |
811 wintemp.top = newTop; | |
812 GFX_graph_print(hgfx,&wintemp,0,1,maxVal,minVal, (uint16_t *)tempdata,dataLength,CLUT_LogbookTemperature, NULL); | |
813 } | |
814 | |
815 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
816 static void build_logbook_test(uint8_t page, uint8_t StepBackwards) |
38 | 817 { |
818 uint32_t lastScreen,lastBackground; | |
819 | |
820 lastScreen = tLOGscreen.FBStartAdress; | |
821 lastBackground = tLOGbackground.FBStartAdress; | |
822 | |
823 tLOGscreen.FBStartAdress = getFrame(16); | |
824 tLOGscreen.ImageHeight = 480; | |
825 tLOGscreen.ImageWidth = 800; | |
826 tLOGscreen.LayerIndex = 1; | |
827 | |
828 tLOGbackground.FBStartAdress = getFrame(17); | |
829 tLOGbackground.ImageHeight = 480; | |
830 tLOGbackground.ImageWidth = 800; | |
831 tLOGbackground.LayerIndex = 0; | |
832 switch(page) | |
833 { | |
834 case 1: | |
835 show_logbook_logbook_show_log_page1(&tLOGscreen,StepBackwards); | |
836 break; | |
837 case 2: | |
838 show_logbook_logbook_show_log_page2(&tLOGscreen,StepBackwards); | |
839 break; | |
840 case 3: | |
841 show_logbook_logbook_show_log_page3(&tLOGscreen,StepBackwards); | |
842 break; | |
843 case 4: | |
844 show_logbook_logbook_show_log_page4(&tLOGscreen,StepBackwards); | |
845 break; | |
846 } | |
847 | |
848 releaseFrame(16,lastScreen); | |
849 releaseFrame(17,lastBackground); | |
850 } | |
851 | |
852 | |
853 void show_logbook_test(_Bool firstPage, uint8_t StepBackwards) | |
854 { | |
855 if(firstPage) | |
856 { | |
596
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
857 active_log_page = 1; |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
858 active_log_offset = StepBackwards; |
38 | 859 } |
860 else | |
861 { | |
596
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
862 active_log_page++; |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
863 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
|
864 { |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
865 active_log_page = 1; |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
866 } |
38 | 867 } |
868 | |
596
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
869 build_logbook_test(active_log_page,StepBackwards); |
38 | 870 // GFX_ResetLayer(TOP_LAYER); |
871 // GFX_ResetLayer(BACKGRD_LAYER); | |
872 | |
873 set_globalState(StILOGSHOW); | |
874 GFX_SetFramesTopBottom(tLOGscreen.FBStartAdress, tLOGbackground.FBStartAdress,480); | |
875 } | |
876 | |
877 | |
878 void show_logbook_exit(void) | |
879 { | |
880 releaseFrame(16,tLOGscreen.FBStartAdress); | |
881 releaseFrame(17,tLOGbackground.FBStartAdress); | |
882 } | |
883 | |
884 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
885 static void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) |
38 | 886 { |
887 SWindowGimpStyle wintemp; | |
888 SWindowGimpStyle winsmal; | |
889 wintemp.left = 50; | |
890 wintemp.right = 799 - wintemp.left; | |
891 wintemp.top = 50; | |
892 wintemp.bottom = 479 - 40; | |
893 | |
894 SLogbookHeader logbookHeader; | |
895 | |
896 logbook_getHeader(StepBackwards, &logbookHeader); | |
897 uint16_t dataLength = 0; | |
898 uint16_t depthdata[1000]; | |
899 uint8_t gasdata[1000]; | |
610 | 900 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
38 | 901 |
902 //--- print coordinate system & depth graph with gaschanges --- | |
903 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL); | |
904 | |
905 //--- print gas list --- | |
906 winsmal.left = wintemp.right - 190; | |
907 winsmal.right = winsmal.left + 150; | |
908 | |
909 char msg[15]; | |
910 char gas_name[15]; | |
911 int j = 0; | |
912 for(int i = 4;i >= 0;i--) | |
913 { | |
914 if(logbookHeader.gasordil[i].note.ub.active > 0) | |
915 { | |
916 j++; | |
917 winsmal.top = wintemp.bottom - 5 - j * 26 ; | |
918 winsmal.bottom = winsmal.top + 21 ; | |
919 uint8_t color = get_colour(i); | |
920 | |
921 print_gas_name(gas_name,15,logbookHeader.gasordil[i].oxygen_percentage,logbookHeader.gasordil[i].helium_percentage); | |
922 snprintf(msg,15,"G%i: %s",i + 1, gas_name); | |
923 //msg[10] = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
924 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,msg); |
38 | 925 } |
926 } | |
927 | |
928 //--- define buttons --- | |
929 /*if(*ghost_char_logfile_oxydata) | |
930 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page4, surf1_menu_logbook_show_log_next); | |
931 else | |
932 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next); | |
933 */ | |
934 } | |
935 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
936 static void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards) |
38 | 937 { SWindowGimpStyle wintemp; |
938 SWindowGimpStyle winsmal; | |
939 wintemp.left = 50; | |
940 wintemp.right = 799 - wintemp.left; | |
941 wintemp.top = 50; | |
942 wintemp.bottom = 479 - 40; | |
943 uint8_t color = 0; | |
944 SLogbookHeader logbookHeader; | |
945 | |
946 logbook_getHeader(StepBackwards, &logbookHeader); | |
947 uint16_t dataLength = 0; | |
948 uint16_t depthdata[1000]; | |
949 uint8_t gasdata[1000]; | |
950 uint16_t ppO2data[1000]; | |
951 uint16_t sensor2[1000]; | |
952 uint16_t sensor3[1000]; | |
953 uint16_t *setpoint = ppO2data; | |
954 uint16_t *sensor1 = ppO2data; | |
955 | |
956 | |
957 if(logbookHeader.diveMode != DIVEMODE_CCR) | |
610 | 958 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, ppO2data, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
38 | 959 else |
960 { | |
961 if(logbookHeader.CCRmode == CCRMODE_FixedSetpoint) | |
610 | 962 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, setpoint, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
38 | 963 else |
610 | 964 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, NULL, sensor1, sensor2, sensor3, NULL, NULL, NULL, NULL, NULL); |
38 | 965 } |
966 | |
967 | |
968 //--- print coordinate system & depth graph with bailout--- | |
969 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, NULL); | |
970 | |
971 | |
972 | |
973 //*** Desciption at bottom of page *************************** | |
974 winsmal.top = wintemp.bottom +2 ; | |
975 winsmal.bottom = winsmal.top + 16; | |
976 | |
977 | |
978 /*if(strcmp( (char*)ghost_char_logfile_text_oc_ccr,"ccr/bailout") == 0) | |
979 { | |
980 winsmal.left = wintemp.left + 2; | |
981 winsmal.right = winsmal.left + 55; | |
982 | |
983 oled_write(OVERLAY, &winsmal,"CCR -",false,true); | |
984 | |
985 winsmal.left = winsmal.right; | |
986 winsmal.right = winsmal.left + 90; | |
987 //winsmal.fontcolor = oled_get_colour(15); | |
988 oled_write(OVERLAY, &winsmal,"bailout",false,true); | |
989 } | |
990 else*/ | |
991 { | |
992 winsmal.left = wintemp.left + 2; | |
993 winsmal.right = winsmal.left + 55; | |
994 color = CLUT_GasSensor1;//LOGBOOK_GRAPH_DEPTH; | |
995 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
996 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"depth"); |
38 | 997 |
998 } | |
999 winsmal.left = 799 - 67;//wintemp.right -67; | |
1000 winsmal.right = winsmal.left;// + 45; | |
1001 | |
1002 color = CLUT_LogbookTemperature;//LOGBOOK_GRAPH_DEPTH; | |
1003 if(logbookHeader.diveMode != DIVEMODE_CCR) | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1004 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002PP O2"); |
38 | 1005 else |
1006 if(logbookHeader.CCRmode != CCRMODE_Sensors) | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1007 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002SETPOINT"); |
38 | 1008 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1009 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002SENSORS"); |
38 | 1010 |
1011 //*** PP O2 **************************************************** | |
1012 //calc lines and labels | |
1013 int datamax = 0; | |
1014 int datamin = 10000; | |
1015 for(int i=1;i<dataLength;i++) | |
1016 { | |
1017 if(ppO2data[i]>datamax) | |
1018 datamax = ppO2data[i]; | |
1019 if(ppO2data[i]<datamin) | |
1020 datamin = ppO2data[i]; | |
1021 } | |
1022 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors)) | |
1023 { | |
1024 for(int i=1;i<dataLength;i++) | |
1025 { | |
1026 if(sensor2[i]>datamax) | |
1027 datamax = sensor2[i]; | |
1028 if(sensor2[i]<datamin) | |
1029 datamin = sensor2[i]; | |
1030 if(sensor3[i]>datamax) | |
1031 datamax = sensor3[i]; | |
1032 if(sensor3[i]<datamin) | |
1033 datamin = sensor3[i]; | |
1034 } | |
1035 } | |
1036 float maxoxy = ((float)datamax)/100; | |
1037 float minoxy = ((float)datamin)/100; | |
1038 float oxystep = 0.5; | |
1039 float maxoxyline = 2.5; | |
1040 | |
1041 //--- print PP O2 labels ---- | |
1042 winsmal.left = wintemp.right + 2; | |
1043 winsmal.top = wintemp.top ; | |
1044 winsmal.right = wintemp.right + 30; | |
1045 winsmal.bottom = winsmal.top + 16; | |
1046 //winsmal.font = ft_tiny + ft_SLIM; | |
1047 color = CLUT_LogbookTemperature;// = LOGBOOK_GRAPH_TEMP; | |
1048 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1049 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"bar"); |
38 | 1050 |
1051 int deltaline = (wintemp.bottom - wintemp.top)/5; | |
1052 char msg[4]; | |
1053 float oxy = maxoxyline; | |
1054 for(int i = 1; i<=5; i++) | |
1055 { | |
1056 oxy -= oxystep; | |
1057 if(oxy < 0) | |
1058 break; | |
1059 winsmal.top = wintemp.top + deltaline * i - 8; | |
1060 winsmal.bottom = winsmal.top + 16; | |
1061 snprintf(msg,4,"%1.1f",oxy); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1062 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,msg); |
38 | 1063 //oled_write(OVERLAY, &winsmal,msg,false,true); |
1064 } | |
1065 | |
1066 //--- print PP O2 graph --- | |
1067 //Adapt window | |
1068 float ftmp = ((maxoxyline - minoxy) * deltaline) /oxystep + wintemp.top; | |
1069 wintemp.bottom = ftmp; | |
1070 if((ftmp - (int)ftmp) >= 0.5f) | |
1071 wintemp.bottom++; | |
1072 | |
1073 ftmp = wintemp.top + ((maxoxyline - maxoxy) * deltaline) /oxystep; | |
1074 wintemp.top = ftmp; | |
1075 if((ftmp - (int)ftmp) >= 0.5f) | |
1076 wintemp.top++; | |
1077 wintemp.top = MaxU32LOG(wintemp.top ,0); | |
1078 if(wintemp.top < wintemp.bottom) | |
1079 { | |
1080 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors)) | |
1081 { | |
1082 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL); | |
1083 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor2,dataLength,CLUT_LogbookTemperature, NULL); | |
1084 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor3,dataLength,CLUT_LogbookTemperature, NULL); | |
1085 } | |
1086 else | |
1087 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL); | |
1088 } | |
1089 else | |
1090 { | |
1091 point_t startPoint, stopPoint; | |
1092 startPoint.x = wintemp.left; | |
1093 stopPoint.x = wintemp.right; | |
1094 stopPoint.y = startPoint.y = 479 - wintemp.top; | |
1095 GFX_draw_colorline(hgfx, startPoint, stopPoint, CLUT_LogbookTemperature); | |
1096 } | |
1097 | |
1098 //--- define buttons --- | |
1099 //button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next); | |
1100 } | |
1101 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
1102 static void print_gas_name(char* output,uint8_t length,uint8_t oxygen,uint8_t helium) |
38 | 1103 { |
1104 if(helium == 0) | |
1105 { | |
1106 if(oxygen == 21) | |
1107 snprintf(output, length, "Air"); | |
1108 else if(oxygen == 100) | |
1109 snprintf(output, length, "Oxy"); | |
1110 else | |
1111 snprintf(output, length, "NX%i",oxygen); | |
1112 } | |
1113 else | |
1114 { | |
1115 if((oxygen + helium) == 100) | |
1116 snprintf(output, length, "HX%i",oxygen); | |
1117 else | |
1118 snprintf(output, length, "TMX%i/%i", oxygen, helium); | |
1119 } | |
1120 | |
1121 } | |
1122 | |
186
f11f0bf6ef2d
cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
1123 static int16_t get_colour(int16_t color) |
38 | 1124 { |
1125 return CLUT_GasSensor1 + color; | |
1126 } | |
596
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1127 |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1128 uint8_t getActiveLogPage() |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1129 { |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1130 return active_log_page; |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1131 } |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1132 |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1133 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
|
1134 { |
16e369eae6e5
Added functionality to select a dive to be shown in the T3 profile view:
Ideenmodellierer
parents:
583
diff
changeset
|
1135 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
|
1136 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
|
1137 } |