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