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