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