38
+ − 1 ///////////////////////////////////////////////////////////////////////////////
+ − 2 /// -*- coding: UTF-8 -*-
+ − 3 ///
+ − 4 /// \file Discovery/Src/t3.c
+ − 5 /// \brief Main Template file for dive mode special scree t3
+ − 6 /// \author Heinrichs Weikamp gmbh
+ − 7 /// \date 10-Nov-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 /* Includes ------------------------------------------------------------------*/
+ − 30 #include "t3.h"
+ − 31
+ − 32 #include "data_exchange_main.h"
+ − 33 #include "decom.h"
+ − 34 #include "gfx_fonts.h"
+ − 35 #include "math.h"
+ − 36 #include "tHome.h"
+ − 37 #include "timer.h"
+ − 38 #include "unit.h"
+ − 39
237
+ − 40 //* Imported function prototypes ---------------------------------------------*/
38
+ − 41 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium);
+ − 42
+ − 43 /* Exported variables --------------------------------------------------------*/
+ − 44
+ − 45 const uint16_t BigFontSeperationLeftRight = 399;
+ − 46 const uint16_t BigFontSeperationTopBottom = 240;
+ − 47
+ − 48 /* Private variables ---------------------------------------------------------*/
+ − 49 GFX_DrawCfgScreen t3screen;
+ − 50 GFX_DrawCfgWindow t3l1;
+ − 51 GFX_DrawCfgWindow t3r1;
+ − 52 GFX_DrawCfgWindow t3c1;
+ − 53 GFX_DrawCfgWindow t3c2;
+ − 54
+ − 55 uint8_t t3_selection_customview = 0;
+ − 56
+ − 57 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/
+ − 58
+ − 59 /* Private types -------------------------------------------------------------*/
+ − 60 #define TEXTSIZE 16
384
+ − 61 #define NUMBER_OF_VIEWS 7 /* number of views defined in the array below */
38
+ − 62
+ − 63 const uint8_t t3_customviewsStandard[] =
+ − 64 {
+ − 65 CVIEW_T3_Decostop,
+ − 66 CVIEW_sensors,
+ − 67 CVIEW_Compass,
+ − 68 CVIEW_T3_MaxDepth,
+ − 69 CVIEW_T3_StopWatch,
+ − 70 CVIEW_T3_TTS,
+ − 71 CVIEW_T3_ppO2andGas,
+ − 72 CVIEW_T3_END
+ − 73 };
+ − 74
+ − 75
+ − 76 const uint8_t *t3_customviews = t3_customviewsStandard;
+ − 77
+ − 78 /* Private function prototypes -----------------------------------------------*/
+ − 79 void t3_refresh_divemode(void);
+ − 80
+ − 81 uint8_t t3_test_customview_warnings(void);
+ − 82 void t3_refresh_customview(float depth);
+ − 83 void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, uint16_t ActualHeading, uint16_t UserSetHeading);
+ − 84
+ − 85 /* Exported functions --------------------------------------------------------*/
+ − 86
+ − 87 void t3_init(void)
+ − 88 {
110
+ − 89 SSettings* pSettings;
+ − 90 pSettings = settingsGetPointer();
+ − 91
38
+ − 92 t3_selection_customview = t3_customviews[0];
+ − 93
+ − 94 t3screen.FBStartAdress = 0;
+ − 95 t3screen.ImageHeight = 480;
+ − 96 t3screen.ImageWidth = 800;
+ − 97 t3screen.LayerIndex = 1;
+ − 98
+ − 99 t3l1.Image = &t3screen;
+ − 100 t3l1.WindowNumberOfTextLines = 2;
+ − 101 t3l1.WindowLineSpacing = 19; // Abstand von Y0
+ − 102 t3l1.WindowTab = 100;
110
+ − 103
+ − 104 if(!pSettings->FlipDisplay)
+ − 105 {
+ − 106 t3l1.WindowX0 = 0;
+ − 107 t3l1.WindowX1 = BigFontSeperationLeftRight - 5;
+ − 108 t3l1.WindowY0 = BigFontSeperationTopBottom + 5;
+ − 109 t3l1.WindowY1 = 479;
+ − 110 }
+ − 111 else
+ − 112 {
+ − 113 t3l1.WindowX0 = 800 - BigFontSeperationLeftRight + 5;
+ − 114 t3l1.WindowX1 = 799;
+ − 115 t3l1.WindowY0 = 0;
+ − 116 t3l1.WindowY1 = 479 - BigFontSeperationTopBottom + 5 ;
+ − 117 }
38
+ − 118
+ − 119 t3r1.Image = &t3screen;
+ − 120 t3r1.WindowNumberOfTextLines = t3l1.WindowNumberOfTextLines;
+ − 121 t3r1.WindowLineSpacing = t3l1.WindowLineSpacing;
+ − 122 t3r1.WindowTab = t3l1.WindowTab;
110
+ − 123 if(!pSettings->FlipDisplay)
+ − 124 {
+ − 125 t3r1.WindowX0 = BigFontSeperationLeftRight + 5;
+ − 126 t3r1.WindowX1 = 799;
+ − 127 }
+ − 128 else
+ − 129 {
+ − 130 t3r1.WindowX0 = 0;
+ − 131 t3r1.WindowX1 = BigFontSeperationLeftRight - 5;
+ − 132 }
+ − 133
38
+ − 134 t3r1.WindowY0 = t3l1.WindowY0;
+ − 135 t3r1.WindowY1 = t3l1.WindowY1;
+ − 136
+ − 137 t3c1.Image = &t3screen;
+ − 138 t3c1.WindowNumberOfTextLines = 2;
+ − 139 t3c1.WindowLineSpacing = t3l1.WindowLineSpacing;
+ − 140 t3c1.WindowX0 = 0;
+ − 141 t3c1.WindowX1 = 799;
110
+ − 142 if(!pSettings->FlipDisplay)
+ − 143 {
+ − 144 t3c1.WindowY0 = 0;
+ − 145 t3c1.WindowY1 = BigFontSeperationTopBottom - 5;
+ − 146 }
+ − 147 else
+ − 148 {
+ − 149 t3c1.WindowY0 = 480 - BigFontSeperationTopBottom + 5;
+ − 150 t3c1.WindowY1 = 479;
+ − 151 }
38
+ − 152
+ − 153 t3c2.Image = &t3screen;
+ − 154 t3c2.WindowNumberOfTextLines = 3;
+ − 155 t3c2.WindowLineSpacing = 58;
+ − 156 t3c2.WindowX0 = 370;
+ − 157 t3c2.WindowX1 = 799;
110
+ − 158 t3c2.WindowY0 = t3c1.WindowY0;
+ − 159 t3c2.WindowY1 = t3c1.WindowY1;
38
+ − 160 t3c2.WindowTab = 600;
+ − 161 }
+ − 162
+ − 163
+ − 164 void t3_refresh(void)
+ − 165 {
+ − 166 SStateList status;
+ − 167 get_globalStateList(&status);
+ − 168
+ − 169 if(stateUsed->mode != MODE_DIVE)
+ − 170 {
+ − 171 settingsGetPointer()->design = 7;
+ − 172 return;
+ − 173 }
+ − 174
+ − 175 if(status.base != BaseHome)
+ − 176 return;
+ − 177
+ − 178 t3screen.FBStartAdress = getFrame(24);
+ − 179 t3_refresh_divemode();
166
+ − 180 GFX_SetFramesTopBottom(t3screen.FBStartAdress, 0,480);
38
+ − 181 releaseAllFramesExcept(24,t3screen.FBStartAdress);
+ − 182 }
+ − 183
+ − 184
+ − 185 /* Private functions ---------------------------------------------------------*/
+ − 186
+ − 187 float t3_basics_lines_depth_and_divetime(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode)
+ − 188 {
+ − 189 char text[512];
+ − 190 uint8_t color;
+ − 191 uint8_t depthChangeRate;
+ − 192 uint8_t depthChangeAscent;
+ − 193 point_t start, stop, startZeroLine;
+ − 194
110
+ − 195 SSettings* pSettings;
+ − 196 pSettings = settingsGetPointer();
+ − 197
38
+ − 198 start.x = 0;
+ − 199 stop.x = 799;
+ − 200 stop.y = start.y = BigFontSeperationTopBottom;
+ − 201 GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
+ − 202
+ − 203 start.y = BigFontSeperationTopBottom;
+ − 204 stop.y = 479;
110
+ − 205
38
+ − 206 stop.x = start.x = BigFontSeperationLeftRight;
+ − 207 GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
+ − 208
+ − 209 /* depth */
174
+ − 210 float depth = unit_depth_float(stateUsed->lifeData.depth_meter);
38
+ − 211
+ − 212 if(depth <= 0.3f)
+ − 213 depth = 0;
+ − 214
+ − 215 if(settingsGetPointer()->nonMetricalSystem)
+ − 216 snprintf(text,TEXTSIZE,"\032\f[feet]");
+ − 217 else
+ − 218 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth);
+ − 219 GFX_write_string(&FontT42,tXl1,text,0);
+ − 220
+ − 221 if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 )))
+ − 222 || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10)))
+ − 223 )
+ − 224 {
+ − 225 snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min "
+ − 226 , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min)
+ − 227 , unit_depth_char1()
+ − 228 , unit_depth_char2()
+ − 229 );
+ − 230 GFX_write_string(&FontT42,tXl1,text,0);
+ − 231 }
+ − 232
+ − 233 if( depth < 100)
+ − 234 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth);
+ − 235 else
+ − 236 snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth);
+ − 237
+ − 238 t3_basics_colorscheme_mod(text);
+ − 239 GFX_write_string(&FontT105,tXl1,text,1);
+ − 240
+ − 241
+ − 242 /* ascentrate graph */
+ − 243 if(mode == DIVEMODE_Apnea)
+ − 244 {
+ − 245 /* ascentrate graph - apnea mode */
+ − 246 if(stateUsed->lifeData.ascent_rate_meter_per_min > 0)
+ − 247 {
+ − 248 depthChangeAscent = 1;
+ − 249 if(stateUsed->lifeData.ascent_rate_meter_per_min < 200)
+ − 250 depthChangeRate = (uint8_t)stateUsed->lifeData.ascent_rate_meter_per_min;
+ − 251 else
+ − 252 depthChangeRate = 200;
+ − 253 }
+ − 254 else
+ − 255 {
+ − 256 depthChangeAscent = 0;
+ − 257 if(stateUsed->lifeData.ascent_rate_meter_per_min > -200)
+ − 258 depthChangeRate = (uint8_t)(0 - stateUsed->lifeData.ascent_rate_meter_per_min);
+ − 259 else
+ − 260 depthChangeRate = 200;
+ − 261 }
413
+ − 262
+ − 263 if(!pSettings->FlipDisplay)
+ − 264 {
+ − 265 start.y = tXl1->WindowY0 - 1;
+ − 266 }
+ − 267 else
+ − 268 {
+ − 269 start.y = tXl1->WindowY1 + 1;
+ − 270 }
386
+ − 271 startZeroLine.y = start.y;
38
+ − 272 for(int i = 0; i<5;i++)
+ − 273 {
+ − 274 start.y += 40;
+ − 275 stop.y = start.y;
413
+ − 276 if(!pSettings->FlipDisplay)
+ − 277 {
+ − 278 start.x = tXl1->WindowX1 - 1;
+ − 279 }
+ − 280 else
+ − 281 {
+ − 282 start.x = tXr1->WindowX1 - 1;
+ − 283 }
38
+ − 284 stop.x = start.x - 17;
+ − 285
+ − 286 if(depthChangeRate <= 6)
+ − 287 {
+ − 288 if(i == 2)
+ − 289 {
+ − 290 startZeroLine.y = start.y;
+ − 291 stop.x = start.x - 34;
+ − 292 }
+ − 293 }
+ − 294 else
+ − 295 {
+ − 296 if(((i == 1) && depthChangeAscent) || ((i == 3) && !depthChangeAscent))
+ − 297 {
+ − 298 startZeroLine.y = start.y;
+ − 299 stop.x = start.x - 34;
+ − 300 }
+ − 301 }
+ − 302 GFX_draw_line(tXscreen, start, stop, 0);
+ − 303 }
+ − 304 // new thick bar design Sept. 2015
+ − 305 if((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4))
+ − 306 {
+ − 307 start.y = startZeroLine.y;
+ − 308 if(depthChangeAscent)
+ − 309 {
+ − 310 color = CLUT_EverythingOkayGreen;
+ − 311 start.y += 7; // starte etwas weiter oben
+ − 312 stop.y = start.y + (uint16_t)(depthChangeRate * 4) - 9; // - x; // wegen der Liniendicke
+ − 313 if(stop.y > 475)
+ − 314 stop.y = 475;
+ − 315 }
+ − 316 else
+ − 317 {
+ − 318 color = CLUT_Font023;
+ − 319 start.y -= 7;
+ − 320 stop.y = start.y - (uint16_t)(depthChangeRate * 4) + 9;
+ − 321 if(stop.y <= tXl1->WindowY0)
+ − 322 stop.y = tXl1->WindowY0 + 1;
+ − 323 }
413
+ − 324 if(!pSettings->FlipDisplay)
+ − 325 {
+ − 326 start.x = tXl1->WindowX1 - 3 - 5;
+ − 327 }
+ − 328 else
+ − 329 {
+ − 330 start.x = tXr1->WindowX1 - 3 - 5;
+ − 331 }
+ − 332
+ − 333 stop.x = start.x;
38
+ − 334 GFX_draw_thick_line(12,tXscreen, start, stop, color);
+ − 335 }
+ − 336 }
+ − 337 else
+ − 338 {
+ − 339 /* ascentrate graph -standard mode */
+ − 340 if(stateUsed->lifeData.ascent_rate_meter_per_min > 0)
+ − 341 {
110
+ − 342 if(!pSettings->FlipDisplay)
+ − 343 {
+ − 344 start.y = tXl1->WindowY0 - 1;
+ − 345 }
+ − 346 else
+ − 347 {
+ − 348 start.y = tXl1->WindowY1 + 1;
+ − 349 }
+ − 350
38
+ − 351 for(int i = 0; i<4;i++)
+ − 352 {
+ − 353 start.y += 5*8;
+ − 354 stop.y = start.y;
110
+ − 355 if(!pSettings->FlipDisplay)
+ − 356 {
+ − 357 start.x = tXl1->WindowX1 - 1;
+ − 358 }
+ − 359 else
+ − 360 {
+ − 361 start.x = tXr1->WindowX1 - 1;
+ − 362 }
38
+ − 363 stop.x = start.x - 17;
+ − 364 GFX_draw_line(tXscreen, start, stop, 0);
+ − 365 }
+ − 366 // new thick bar design Sept. 2015
110
+ − 367 if(!pSettings->FlipDisplay)
+ − 368 {
+ − 369 start.x = tXl1->WindowX1 - 3 - 5;
+ − 370 }
+ − 371 else
+ − 372 {
+ − 373 start.x = tXr1->WindowX1 - 3 - 5;
+ − 374 }
+ − 375
38
+ − 376 stop.x = start.x;
110
+ − 377 if(!pSettings->FlipDisplay)
+ − 378 {
+ − 379 start.y = tXl1->WindowY0 - 1;
+ − 380 }
+ − 381 else
+ − 382 {
+ − 383 start.y = tXl1->WindowY1 + 1;
+ − 384 }
+ − 385
38
+ − 386 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8);
+ − 387 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9
+ − 388 if(stop.y >= 470)
+ − 389 stop.y = 470;
+ − 390 start.y += 7; // starte etwas weiter oben
+ − 391 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10)
+ − 392 color = CLUT_EverythingOkayGreen;
+ − 393 else
+ − 394 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15)
+ − 395 color = CLUT_WarningYellow;
+ − 396 else
+ − 397 color = CLUT_WarningRed;
+ − 398
+ − 399 GFX_draw_thick_line(12,tXscreen, start, stop, color);
+ − 400 }
+ − 401 }
+ − 402
+ − 403 // divetime
+ − 404 if(mode == DIVEMODE_Apnea)
+ − 405 {
+ − 406 if(stateUsed->lifeData.counterSecondsShallowDepth)
+ − 407 {
+ − 408 SDivetime SurfaceBreakTime = {0,0,0,0};
+ − 409
+ − 410 SurfaceBreakTime.Total = stateUsed->lifeData.counterSecondsShallowDepth;
+ − 411 SurfaceBreakTime.Minutes = SurfaceBreakTime.Total / 60;
+ − 412 SurfaceBreakTime.Seconds = SurfaceBreakTime.Total - (SurfaceBreakTime.Minutes * 60);
+ − 413
+ − 414 snprintf(text,TEXTSIZE,"\032\f\002%c%c", TXT_2BYTE,TXT2BYTE_ApneaSurface);
+ − 415 GFX_write_string(&FontT42,tXr1,text,0);
+ − 416
+ − 417 snprintf(text,TEXTSIZE,"\020\003\016\002%u:%02u",SurfaceBreakTime.Minutes, SurfaceBreakTime.Seconds);
+ − 418 }
+ − 419 else
+ − 420 {
+ − 421 SDivetime Divetime = {0,0,0, 0};
+ − 422
+ − 423 Divetime.Total = stateUsed->lifeData.dive_time_seconds;
+ − 424 Divetime.Minutes = Divetime.Total / 60;
+ − 425 Divetime.Seconds = Divetime.Total - ( Divetime.Minutes * 60 );
+ − 426
+ − 427 snprintf(text,TEXTSIZE,"\032\f\002%c",TXT_Divetime);
+ − 428 GFX_write_string(&FontT42,tXr1,text,0);
+ − 429
+ − 430 if(Divetime.Minutes < 100)
+ − 431 snprintf(text,TEXTSIZE,"\020\003\016\002%u:%02u",Divetime.Minutes, Divetime.Seconds);
+ − 432 else
+ − 433 snprintf(text,TEXTSIZE,"\020\003\016\002%u'",Divetime.Minutes);
+ − 434 }
+ − 435 }
+ − 436 else
+ − 437 {
+ − 438 SDivetime Divetime = {0,0,0, 0};
+ − 439
+ − 440 Divetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time;
+ − 441 Divetime.Minutes = Divetime.Total / 60;
+ − 442 Divetime.Seconds = Divetime.Total - ( Divetime.Minutes * 60 );
+ − 443
+ − 444 snprintf(text,TEXTSIZE,"\032\f\002%c",TXT_Divetime);
+ − 445 GFX_write_string(&FontT42,tXr1,text,0);
+ − 446
+ − 447 if(Divetime.Minutes < 100)
+ − 448 snprintf(text,TEXTSIZE,"\020\003\016\002%u:%02u",Divetime.Minutes, Divetime.Seconds);
+ − 449 else
+ − 450 snprintf(text,TEXTSIZE,"\020\003\016\002%u'",Divetime.Minutes);
+ − 451 }
+ − 452 t3_basics_colorscheme_mod(text);
+ − 453 GFX_write_string(&FontT105,tXr1,text,1);
+ − 454
+ − 455 return depth;
+ − 456 }
+ − 457
+ − 458
+ − 459 void t3_refresh_divemode(void)
+ − 460 {
+ − 461 uint8_t customview_warnings = 0;
+ − 462 float depth_meter = 0.0;
+ − 463
+ − 464 // everything like lines, depth, ascent graph and divetime
+ − 465 depth_meter = t3_basics_lines_depth_and_divetime(&t3screen, &t3l1, &t3r1, 0); // 0 could be stateUsed->diveSettings.diveMode for CCR specials
+ − 466
+ − 467 // customview
+ − 468 if(stateUsed->warnings.numWarnings)
+ − 469 customview_warnings = t3_test_customview_warnings();
+ − 470
+ − 471 if(customview_warnings && warning_count_high_time)
+ − 472 t3_basics_show_customview_warnings(&t3c1);
+ − 473 else
+ − 474 t3_refresh_customview(depth_meter);
+ − 475
+ − 476 if(stateUsed->warnings.lowBattery)
+ − 477 t3_basics_battery_low_customview_extra(&t3c1);
+ − 478 }
+ − 479
+ − 480
+ − 481 void t3_basics_battery_low_customview_extra(GFX_DrawCfgWindow* tXc1)
+ − 482 {
+ − 483 char TextC1[256];
+ − 484
+ − 485 TextC1[0] = '\002';
+ − 486 TextC1[1] = '\f';
+ − 487 TextC1[2] = '\025';
+ − 488 TextC1[3] = '3';
+ − 489 TextC1[4] = '1';
+ − 490 TextC1[5] = '1';
+ − 491 TextC1[6] = '1';
+ − 492 TextC1[7] = '1';
+ − 493 TextC1[8] = '1';
+ − 494 TextC1[9] = '1';
+ − 495 TextC1[10] = '1';
+ − 496 TextC1[11] = '1';
+ − 497 TextC1[12] = '1';
+ − 498 TextC1[13] = '1';
+ − 499 TextC1[14] = '0';
+ − 500 TextC1[15] = 0;
+ − 501
+ − 502 if(!warning_count_high_time)
+ − 503 TextC1[4] = '2';
+ − 504
+ − 505 GFX_write_string(&Batt24,tXc1,TextC1,0);
+ − 506 }
+ − 507
+ − 508
+ − 509
+ − 510 void t3_refresh_customview(float depth)
+ − 511 {
386
+ − 512 #if 0
38
+ − 513 if((t3_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
+ − 514 t3_change_customview();
386
+ − 515 #endif
272
+ − 516 t3_basics_refresh_customview(depth, t3_selection_customview, &t3screen, &t3c1, &t3c2, stateUsedWrite->diveSettings.diveMode);
38
+ − 517 }
+ − 518
+ − 519
+ − 520 void t3_basics_refresh_apnoeRight(float depth, uint8_t tX_selection_customview, GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXc1, GFX_DrawCfgWindow* tXc2, uint8_t mode)
+ − 521 {
+ − 522 char text[512];
+ − 523 uint16_t textpointer = 0;
+ − 524
+ − 525 // CVIEW_T3_Temperature
+ − 526 float temperature;
413
+ − 527 SSettings* pSettings;
+ − 528 pSettings = settingsGetPointer();
38
+ − 529
+ − 530 SDivetime TotalDivetime = {0,0,0,0};
+ − 531 SDivetime LastDivetime = {0,0,0,0};
+ − 532
+ − 533 uint16_t tempWinX0;
413
+ − 534 uint16_t tempWinX1;
38
+ − 535 uint16_t tempWinY0;
413
+ − 536 uint16_t tempWinY1;
38
+ − 537
+ − 538 tempWinX0 = tXc1->WindowX0;
413
+ − 539 tempWinX1 = tXc1->WindowX1;
38
+ − 540 tempWinY0 = tXc1->WindowY0;
413
+ − 541 tempWinY1 = tXc1->WindowY1;
38
+ − 542
+ − 543 tXc1->WindowX0 = 440; // rechte Seite
+ − 544
+ − 545 switch(tX_selection_customview)
+ − 546 {
+ − 547 case CVIEW_T3_Temperature:
+ − 548 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature);
+ − 549 GFX_write_string(&FontT42,tXc1,text,0);
+ − 550
189
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
diff
changeset
+ − 551 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
38
+ − 552 textpointer = snprintf(text,TEXTSIZE,"\020\003\016%01.0f\016\016\140",temperature); // "\016\016%01.1f `" + C or F
+ − 553 if(settingsGetPointer()->nonMetricalSystem == 0)
+ − 554 text[textpointer++] = 'C';
+ − 555 else
+ − 556 text[textpointer++] = 'F';
+ − 557 text[textpointer++] = 0;
+ − 558 t3_basics_colorscheme_mod(text);
+ − 559 GFX_write_string(&FontT105,tXc1,text,1);
+ − 560 break;
+ − 561
+ − 562 case CVIEW_T3_ApnoeSurfaceInfo:
+ − 563 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime);
+ − 564 GFX_write_string(&FontT42,tXc1,text,0);
+ − 565
+ − 566 TotalDivetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time;
+ − 567 TotalDivetime.Minutes = TotalDivetime.Total / 60;
+ − 568 TotalDivetime.Seconds = TotalDivetime.Total - ( TotalDivetime.Minutes * 60 );
+ − 569
+ − 570 LastDivetime.Total = stateUsed->lifeData.apnea_last_dive_time_seconds;
+ − 571 LastDivetime.Minutes = LastDivetime.Total / 60;
+ − 572 LastDivetime.Seconds = LastDivetime.Total - ( LastDivetime.Minutes * 60 );
+ − 573
413
+ − 574 // tXc1->WindowY0 = 100; // obere Zeile
+ − 575 if(!pSettings->FlipDisplay)
+ − 576 {
+ − 577 tXc1->WindowY0 = 100;
+ − 578 }
+ − 579 else
+ − 580 {
+ − 581 tXc1->WindowY1 -= 100; /* jump to upper of two lines */
+ − 582 }
38
+ − 583
+ − 584 snprintf(text,TEXTSIZE,"\020\016%u:%02u",LastDivetime.Minutes, LastDivetime.Seconds);
+ − 585 t3_basics_colorscheme_mod(text);
+ − 586 GFX_write_string(&FontT105,tXc1,text,0);
+ − 587
413
+ − 588 if(pSettings->FlipDisplay)
+ − 589 {
+ − 590 tXc1->WindowX0 = 0;
+ − 591
+ − 592 }
38
+ − 593 snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaLast);
+ − 594 GFX_write_string(&FontT42,tXc1,text,0);
+ − 595
413
+ − 596 if(!pSettings->FlipDisplay)
+ − 597 {
+ − 598 tXc1->WindowY0 = tempWinY0;
+ − 599 }
+ − 600 else
+ − 601 {
+ − 602 tXc1->WindowX1 = tempWinX1;
+ − 603 tXc1->WindowY1 = tempWinY1; /* jump to upper of two lines */
+ − 604 }
38
+ − 605
+ − 606 snprintf(text,TEXTSIZE,"\020\016%u:%02u",TotalDivetime.Minutes, TotalDivetime.Seconds);
+ − 607 t3_basics_colorscheme_mod(text);
+ − 608 GFX_write_string(&FontT105,tXc1,text,0);
+ − 609
+ − 610 snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaTotal);
413
+ − 611 if(pSettings->FlipDisplay)
+ − 612 {
+ − 613 tXc1->WindowX0 = 0;
+ − 614
+ − 615 }
38
+ − 616 GFX_write_string(&FontT42,tXc1,text,0);
+ − 617 break;
+ − 618 }
+ − 619
+ − 620 tXc1->WindowX0 = tempWinX0;
413
+ − 621 tXc1->WindowX1 = tempWinX1;
38
+ − 622 tXc1->WindowY0 = tempWinY0;
+ − 623
+ − 624 }
+ − 625
+ − 626
+ − 627 void t3_basics_refresh_customview(float depth, uint8_t tX_selection_customview, GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXc1, GFX_DrawCfgWindow* tXc2, uint8_t mode)
+ − 628 {
+ − 629 char text[512];
+ − 630 uint16_t textpointer = 0;
+ − 631
110
+ − 632 SSettings* pSettings;
+ − 633 pSettings = settingsGetPointer();
+ − 634
38
+ − 635 // CVIEW_T3_Decostop and CVIEW_T3_TTS
+ − 636 const SDecoinfo * pDecoinfo;
+ − 637 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE)
+ − 638 pDecoinfo = &stateUsed->decolistBuehlmann;
+ − 639 else
+ − 640 pDecoinfo = &stateUsed->decolistVPM;
+ − 641
+ − 642 // CVIEW_T3_Decostop
+ − 643 uint16_t nextstopLengthSeconds = 0;
+ − 644 uint8_t nextstopDepthMeter = 0;
+ − 645 SDivetime SafetyStopTime = {0,0,0,0};
+ − 646
+ − 647 // CVIEW_T3_ppO2andGas
+ − 648 uint8_t oxygen_percentage = 0;
+ − 649
+ − 650 // CVIEW_T3_Temperature
+ − 651 float temperature;
+ − 652
+ − 653 // CVIEW_T3_GasList
+ − 654 float fPpO2limitHigh, fPpO2limitLow, fPpO2ofGasAtThisDepth;
+ − 655 const SGasLine * pGasLine;
+ − 656 uint8_t oxygen, helium;
+ − 657 uint8_t lineNumber;
+ − 658
+ − 659 // CVIEW_T3_StopWatch
+ − 660 SDivetime Stopwatch = {0,0,0,0};
+ − 661 float fAverageDepth, fAverageDepthAbsolute;
+ − 662
+ − 663 uint16_t tempWinX0;
110
+ − 664 uint16_t tempWinX1;
38
+ − 665 uint16_t tempWinY0;
110
+ − 666 uint16_t tempWinY1;
38
+ − 667 uint16_t tempWinC2X0;
413
+ − 668 uint16_t tempWinC2Y0;
+ − 669 uint16_t tempWinC2X1;
+ − 670 uint16_t tempWinC2Y1;
38
+ − 671 uint16_t tempWinC2Tab;
+ − 672
+ − 673 tempWinX0 = tXc1->WindowX0;
+ − 674 tempWinY0 = tXc1->WindowY0;
413
+ − 675
38
+ − 676 tempWinC2X0 = tXc2->WindowX0;
413
+ − 677 tempWinC2Y0 = tXc2->WindowY0;
+ − 678 tempWinC2X1 = tXc2->WindowX1;
+ − 679 tempWinC2Y1 = tXc2->WindowY1;
38
+ − 680 tempWinC2Tab = tXc2->WindowTab;
+ − 681
+ − 682 switch(tX_selection_customview)
+ − 683 {
+ − 684 case CVIEW_T3_ApnoeSurfaceInfo:
+ − 685 snprintf(text,TEXTSIZE,"\032\f%c",TXT_MaxDepth);
+ − 686
413
+ − 687 if(!pSettings->FlipDisplay)
+ − 688 {
+ − 689 GFX_write_string(&FontT42,tXc1,text,0);
+ − 690 tXc1->WindowY0 = 100;
+ − 691 }
+ − 692 else
+ − 693 {
+ − 694 GFX_write_string(&FontT42,tXc2,text,0);
+ − 695 tXc2->WindowY1 -= 100; /* jump to upper of two lines */
+ − 696 }
38
+ − 697
+ − 698 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_last_max_depth_meter));
+ − 699 t3_basics_colorscheme_mod(text);
413
+ − 700
+ − 701 if(!pSettings->FlipDisplay)
+ − 702 {
+ − 703 GFX_write_string(&FontT105,tXc1,text,0);
+ − 704 tXc1->WindowY0 = tempWinY0;
+ − 705 }
+ − 706 else
+ − 707 {
+ − 708 GFX_write_string(&FontT105,tXc2,text,0);
+ − 709 tXc2->WindowY1 = tempWinC2Y1; /* jump to upper of two lines */
+ − 710 }
38
+ − 711
+ − 712
+ − 713 snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_total_max_depth_meter));
+ − 714 t3_basics_colorscheme_mod(text);
413
+ − 715 if(!pSettings->FlipDisplay)
+ − 716 {
+ − 717 GFX_write_string(&FontT105,tXc1,text,0);
+ − 718 }
+ − 719 else
+ − 720 {
+ − 721 GFX_write_string(&FontT105,tXc2,text,0);
+ − 722 }
38
+ − 723 break;
+ − 724
+ − 725 case CVIEW_T3_StopWatch:
110
+ − 726
+ − 727 tempWinX0 = tXc1->WindowX0;
+ − 728 tempWinY0 = tXc1->WindowY0;
+ − 729 tempWinX1 = tXc1->WindowX1;
+ − 730 tempWinY1 = tXc1->WindowY1;
+ − 731
38
+ − 732 Stopwatch.Total = timer_Stopwatch_GetTime();
+ − 733 Stopwatch.Minutes = Stopwatch.Total / 60;
+ − 734 Stopwatch.Seconds = Stopwatch.Total - ( Stopwatch.Minutes * 60 );
+ − 735 fAverageDepth = timer_Stopwatch_GetAvarageDepth_Meter();
+ − 736 fAverageDepthAbsolute = stateUsed->lifeData.average_depth_meter;
+ − 737
+ − 738 snprintf(text,TEXTSIZE,"\032\f%c",TXT_AvgDepth);
+ − 739 GFX_write_string(&FontT42,tXc1,text,0);
+ − 740 snprintf(text,TEXTSIZE,"\030\003\016%01.1f",unit_depth_float(fAverageDepthAbsolute));
+ − 741 GFX_write_string(&FontT105,tXc1,text,0);
+ − 742
110
+ − 743
+ − 744
+ − 745 if(!pSettings->FlipDisplay)
+ − 746 {
+ − 747 tXc1->WindowX0 = 480;
+ − 748 }
+ − 749 else
+ − 750 {
+ − 751 tXc1->WindowX1 = 320;
+ − 752 tXc1->WindowY0 = t3c1.WindowY0; /* select customer window */
+ − 753 }
38
+ − 754 // snprintf(text,TEXTSIZE,"\032\f%c%c - %c",TXT_2BYTE, TXT2BYTE_Clock, TXT_AvgDepth);
110
+ − 755
38
+ − 756 snprintf(text,TEXTSIZE,"\032\f%c", TXT_Stopwatch);
+ − 757 GFX_write_string(&FontT42,tXc1,text,0);
+ − 758 snprintf(text,TEXTSIZE,"\030\016%01.1f",unit_depth_float(fAverageDepth));
+ − 759 GFX_write_string(&FontT105,tXc1,text,0);
110
+ − 760 if(!pSettings->FlipDisplay)
+ − 761 {
+ − 762 tXc1->WindowY0 = 100;
+ − 763 }
+ − 764 else
+ − 765 {
+ − 766 tXc1->WindowY1 -= 100; /* jump to upper of two lines */
+ − 767 }
+ − 768
38
+ − 769 snprintf(text,TEXTSIZE,"\030%u:\016\016%02u",Stopwatch.Minutes, Stopwatch.Seconds);
+ − 770 GFX_write_string(&FontT105,tXc1,text,0);
110
+ − 771
38
+ − 772 tXc1->WindowX0 = tempWinX0;
+ − 773 tXc1->WindowY0 = tempWinY0;
110
+ − 774 tXc1->WindowX1 = tempWinX1;
+ − 775 tXc1->WindowY1 = tempWinY1;
38
+ − 776 break;
+ − 777
+ − 778 case CVIEW_T3_GasList:
+ − 779 snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE, TXT2BYTE_Gaslist);
+ − 780 GFX_write_string(&FontT42,tXc1,text,0);
+ − 781
+ − 782 textpointer = 0;
+ − 783 tempWinC2X0 = tXc2->WindowX0;
+ − 784 tempWinC2Tab = tXc2->WindowTab;
+ − 785 tXc2->WindowX0 = 0;
+ − 786 tXc2->WindowTab = 800/2;
+ − 787
413
+ − 788 if(pSettings->FlipDisplay)
+ − 789 {
+ − 790 tXc2->WindowY1 = 0;
+ − 791 }
+ − 792
38
+ − 793 pGasLine = settingsGetPointer()->gas;
+ − 794 if(actualLeftMaxDepth(stateUsed))
+ − 795 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_deco) / 100;
+ − 796 else
+ − 797 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_std) / 100;
+ − 798 fPpO2limitLow = (float)(settingsGetPointer()->ppO2_min) / 100;
+ − 799 for(int gasId=1;gasId<=NUM_GASES;gasId++)
+ − 800 {
+ − 801 textpointer = 0;
+ − 802 lineNumber = gasId;
+ − 803 if(gasId > 3)
+ − 804 {
+ − 805 text[textpointer++] = '\t';
+ − 806 lineNumber = gasId - 3;
+ − 807 }
+ − 808 fPpO2ofGasAtThisDepth = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * pGasLine[gasId].oxygen_percentage / 100;
+ − 809 if(pGasLine[gasId].note.ub.active == 0)
+ − 810 strcpy(&text[textpointer++],"\021");
+ − 811 else if((fPpO2ofGasAtThisDepth > fPpO2limitHigh) || (fPpO2ofGasAtThisDepth < fPpO2limitLow))
+ − 812 strcpy(&text[textpointer++],"\025");
+ − 813 else
+ − 814 strcpy(&text[textpointer++],"\030");
+ − 815
+ − 816 text[textpointer++] = ' ';
+ − 817 oxygen = pGasLine[gasId].oxygen_percentage;
+ − 818 helium = pGasLine[gasId].helium_percentage;
+ − 819 textpointer += write_gas(&text[textpointer], oxygen, helium);
+ − 820 GFX_write_string(&FontT42, tXc2, text, lineNumber);
+ − 821 }
+ − 822 break;
+ − 823
+ − 824 case CVIEW_T3_Temperature:
+ − 825 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Temperature);
+ − 826 GFX_write_string(&FontT42,tXc1,text,0);
189
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
diff
changeset
+ − 827
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
diff
changeset
+ − 828 temperature = unit_temperature_float(stateUsed->lifeData.temperature_celsius);
38
+ − 829 textpointer = snprintf(text,TEXTSIZE,"\030\003\016%01.1f \140",temperature); // "\016\016%01.1f `" + C or F
+ − 830 if(settingsGetPointer()->nonMetricalSystem == 0)
+ − 831 text[textpointer++] = 'C';
+ − 832 else
+ − 833 text[textpointer++] = 'F';
+ − 834 text[textpointer++] = 0;
+ − 835 GFX_write_string(&FontT105,tXc1,text,0);
+ − 836 break;
+ − 837
+ − 838 case CVIEW_Compass:
+ − 839 snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE, TXT2BYTE_Compass);
+ − 840 GFX_write_string(&FontT42,tXc1,text,0);
+ − 841 snprintf(text,100,"\030\003%03i`",(uint16_t)stateUsed->lifeData.compass_heading);
+ − 842 GFX_write_string(&FontT105,tXc1,text,0);
+ − 843 t3_basics_compass(tXscreen, (uint16_t)stateUsed->lifeData.compass_heading, stateUsed->diveSettings.compassHeading);
+ − 844 break;
+ − 845
+ − 846 case CVIEW_T3_Decostop:
+ − 847 default:
+ − 848 // decostop
+ − 849 if(pDecoinfo->output_time_to_surface_seconds)
+ − 850 {
+ − 851 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds);
+ − 852 }
+ − 853 else
+ − 854 {
+ − 855 nextstopDepthMeter = 0;
+ − 856 nextstopLengthSeconds = 0;
+ − 857 }
+ − 858
+ − 859 SafetyStopTime.Total = timer_Safetystop_GetCountDown();
+ − 860 SafetyStopTime.Minutes = SafetyStopTime.Total / 60;
+ − 861 SafetyStopTime.Seconds = SafetyStopTime.Total - (SafetyStopTime.Minutes * 60);
+ − 862
+ − 863 if(nextstopDepthMeter)
+ − 864 {
+ − 865 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Decostop);
+ − 866 GFX_write_string(&FontT42,tXc1,text,0);
+ − 867
+ − 868 textpointer = 0;
+ − 869 snprintf(&text[textpointer],TEXTSIZE,"\020\003%u%c%c %u'"
+ − 870 , unit_depth_integer(nextstopDepthMeter)
+ − 871 , unit_depth_char1_T105()
+ − 872 , unit_depth_char2_T105()
+ − 873 , (nextstopLengthSeconds+59)/60);
+ − 874 // old without feet hw 170703 snprintf(&text[textpointer],TEXTSIZE,"\020\003%um %u'",nextstopDepthMeter,(nextstopLengthSeconds+59)/60);
+ − 875 t3_basics_colorscheme_mod(text);
+ − 876 GFX_write_string(&FontT105,tXc1,text,1);
+ − 877 }
+ − 878 else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit()))
+ − 879 {
+ − 880 textpointer = 0;
+ − 881 snprintf(&text[textpointer],TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2);
+ − 882 GFX_write_string(&FontT42,tXc1,text,0);
+ − 883
+ − 884 textpointer = 0;
+ − 885 snprintf(&text[textpointer],TEXTSIZE,"\020\003\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds);
+ − 886 t3_basics_colorscheme_mod(text);
+ − 887 GFX_write_string(&FontT105,tXc1,text,1);
+ − 888 }
237
+ − 889 else if(pDecoinfo->output_ndl_seconds) // NDL
38
+ − 890 {
+ − 891 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Nullzeit);
+ − 892 GFX_write_string(&FontT42,tXc1,text,0);
+ − 893 if(pDecoinfo->output_ndl_seconds < 1000 * 60)
+ − 894 snprintf(text,TEXTSIZE,"\020\003%i'",pDecoinfo->output_ndl_seconds/60);
+ − 895 else
+ − 896 snprintf(text,TEXTSIZE,"\020\003%ih",pDecoinfo->output_ndl_seconds/3600);
+ − 897 t3_basics_colorscheme_mod(text);
+ − 898 GFX_write_string(&FontT105,tXc1,text,1);
+ − 899 }
+ − 900 break;
+ − 901
+ − 902 case CVIEW_sensors:
+ − 903 snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_O2monitor);
+ − 904 GFX_write_string(&FontT42,tXc1,text,0);
+ − 905
+ − 906 for(int i=0;i<3;i++)
+ − 907 {
+ − 908 textpointer = 0;
+ − 909 text[textpointer++] = '\030';
+ − 910 if(i==1)
+ − 911 text[textpointer++] = '\001';
+ − 912 else if(i==2)
+ − 913 text[textpointer++] = '\002';
+ − 914 if(stateUsed->diveSettings.ppo2sensors_deactivated & (1<<i))
+ − 915 {
+ − 916 text[textpointer++] = '\031';
+ − 917 text[textpointer++] = ' ';
+ − 918 text[textpointer++] = '-';
+ − 919 text[textpointer++] = ' ';
+ − 920 }
+ − 921 else
+ − 922 {
+ − 923 if(stateUsed->warnings.sensorOutOfBounds[i])
+ − 924 text[textpointer++] = '\025';
+ − 925 textpointer += snprintf(&text[textpointer],TEXTSIZE,"%.1f",stateUsed->lifeData.ppO2Sensor_bar[i]);
+ − 926 }
+ − 927 GFX_write_string(&FontT144,tXc1,text,1);
+ − 928 }
+ − 929 break;
+ − 930
+ − 931 case CVIEW_T3_MaxDepth:
+ − 932 snprintf(text,TEXTSIZE,"\032\f%c",TXT_MaxDepth);
413
+ − 933 if(pSettings->FlipDisplay)
+ − 934 {
+ − 935 if(mode == DIVEMODE_Apnea)
+ − 936 {
+ − 937 GFX_write_string(&FontT42,tXc2,text,0);
+ − 938 }
+ − 939 else
+ − 940 {
+ − 941 GFX_write_string(&FontT42,tXc1,text,0);
+ − 942 }
+ − 943 }
+ − 944 else
+ − 945 {
+ − 946 GFX_write_string(&FontT42,tXc1,text,0);
+ − 947 }
38
+ − 948 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
+ − 949 t3_basics_colorscheme_mod(text);
413
+ − 950 if(pSettings->FlipDisplay)
+ − 951 {
+ − 952 if(mode == DIVEMODE_Apnea)
+ − 953 {
+ − 954 GFX_write_string(&FontT105,tXc2,text,0);
+ − 955 }
+ − 956 else
+ − 957 {
+ − 958 GFX_write_string(&FontT105,tXc1,text,0);
+ − 959 }
+ − 960 }
+ − 961 else
+ − 962 {
+ − 963 GFX_write_string(&FontT105,tXc1,text,1);
+ − 964 }
38
+ − 965 break;
+ − 966
+ − 967 case CVIEW_T3_TTS:
+ − 968 snprintf(text,TEXTSIZE,"\032\f%c",TXT_TTS);
+ − 969 GFX_write_string(&FontT42,tXc1,text,0);
+ − 970 if(pDecoinfo->output_time_to_surface_seconds)
+ − 971 {
+ − 972 if(pDecoinfo->output_time_to_surface_seconds < 1000 * 60)
214
+ − 973 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
38
+ − 974 else
214
+ − 975 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
38
+ − 976 t3_basics_colorscheme_mod(text);
+ − 977 GFX_write_string(&FontT105,tXc1,text,1);
+ − 978 }
+ − 979 break;
+ − 980
+ − 981 case CVIEW_T3_ppO2andGas:
+ − 982 snprintf(text,TEXTSIZE,"\032\f%c",TXT_ppO2);
+ − 983 GFX_write_string(&FontT42,tXc1,text,0);
+ − 984 snprintf(text,TEXTSIZE,"\020\003%01.2f",stateUsed->lifeData.ppO2);
+ − 985 t3_basics_colorscheme_mod(text);
+ − 986 GFX_write_string(&FontT105,tXc1,text,1);
+ − 987
+ − 988 textpointer = 0;
+ − 989 text[textpointer++] = '\020';
+ − 990 text[textpointer++] = '\003';
+ − 991 oxygen_percentage = 100;
+ − 992 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage;
+ − 993 oxygen_percentage -= stateUsed->lifeData.actualGas.helium_percentage;
+ − 994 text[textpointer++] = '\002';
+ − 995 tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[textpointer]);
+ − 996 //textpointer = snprintf(&text[textpointer],TEXTSIZE,"\020\002%02u/%02u",oxygen_percentage, stateUsed->lifeData.actualGas.helium_percentage);
+ − 997 t3_basics_colorscheme_mod(text);
+ − 998 GFX_write_string(&FontT48,tXc1,text,1);
+ − 999 break;
+ − 1000 }
+ − 1001 tXc1->WindowX0 = tempWinX0;
+ − 1002 tXc1->WindowY0 = tempWinY0;
413
+ − 1003
38
+ − 1004 tXc2->WindowX0 = tempWinC2X0;
413
+ − 1005 tXc2->WindowY0 = tempWinC2Y0;
+ − 1006 tXc2->WindowX1 = tempWinC2X1;
+ − 1007 tXc2->WindowY1 = tempWinC2Y1;
38
+ − 1008 tXc2->WindowTab = tempWinC2Tab;
+ − 1009 }
+ − 1010
+ − 1011
+ − 1012 uint8_t t3_test_customview_warnings(void)
+ − 1013 {
+ − 1014 uint8_t count = 0;
+ − 1015
+ − 1016 count = 0;
+ − 1017 count += stateUsed->warnings.decoMissed;
+ − 1018 count += stateUsed->warnings.ppO2Low;
+ − 1019 count += stateUsed->warnings.ppO2High;
+ − 1020 //count += stateUsed->warnings.lowBattery;
+ − 1021 count += stateUsed->warnings.sensorLinkLost;
+ − 1022 count += stateUsed->warnings.fallback;
+ − 1023
+ − 1024 return count;
+ − 1025 }
+ − 1026
+ − 1027 //void t3_show_customview_warnings(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode)
+ − 1028 void t3_basics_show_customview_warnings(GFX_DrawCfgWindow* tXc1)
+ − 1029 {
+ − 1030 char text[256], textMain[256];
+ − 1031 uint8_t textpointer, textpointerMain, lineFree, more;
+ − 1032
+ − 1033 snprintf(text,TEXTSIZE,"\025\f%c",TXT_Warning);
+ − 1034 GFX_write_string(&FontT42,&t3c1,text,0);
+ − 1035
+ − 1036 lineFree = 1;
+ − 1037 more = 0;
+ − 1038
+ − 1039 textpointerMain = 0;
+ − 1040 textMain[textpointerMain++] = '\025';
+ − 1041 textMain[textpointerMain++] = '\003';
+ − 1042
+ − 1043 textpointer = 0;
+ − 1044
+ − 1045 text[textpointer++] = '\021';
+ − 1046 text[textpointer++] = TXT_2BYTE;
+ − 1047 text[textpointer++] = TXT2BYTE_WarnDecoMissed;
+ − 1048 if(stateUsed->warnings.decoMissed)
+ − 1049 {
+ − 1050 text[textpointer - 3] = '\025';
+ − 1051 if(lineFree)
+ − 1052 {
+ − 1053 textMain[textpointerMain++] = TXT_2BYTE;
+ − 1054 textMain[textpointerMain++] = text[textpointer - 1];
+ − 1055 textMain[textpointerMain] = 0;
+ − 1056 lineFree--;
+ − 1057 }
+ − 1058 else
+ − 1059 {
+ − 1060 more++;
+ − 1061 }
+ − 1062 }
+ − 1063
+ − 1064 text[textpointer++] = '\t';
+ − 1065 text[textpointer++] = '\021';
+ − 1066 text[textpointer++] = TXT_2BYTE;
+ − 1067 text[textpointer++] = TXT2BYTE_WarnPPO2Low;
+ − 1068 if(stateUsed->warnings.ppO2Low)
+ − 1069 {
+ − 1070 text[textpointer - 3] = '\025';
+ − 1071 if(lineFree)
+ − 1072 {
+ − 1073 textMain[textpointerMain++] = TXT_2BYTE;
+ − 1074 textMain[textpointerMain++] = text[textpointer - 1];
+ − 1075 textMain[textpointerMain] = 0;
+ − 1076 lineFree--;
+ − 1077 }
+ − 1078 else
+ − 1079 {
+ − 1080 more++;
+ − 1081 }
+ − 1082 }
+ − 1083
+ − 1084 text[textpointer++] = '\n';
+ − 1085 text[textpointer++] = '\r';
+ − 1086 text[textpointer++] = '\021';
+ − 1087 text[textpointer++] = TXT_2BYTE;
+ − 1088 text[textpointer++] = TXT2BYTE_WarnPPO2High;
+ − 1089 if(stateUsed->warnings.ppO2High)
+ − 1090 {
+ − 1091 text[textpointer - 3] = '\025';
+ − 1092 if(lineFree)
+ − 1093 {
+ − 1094 textMain[textpointerMain++] = TXT_2BYTE;
+ − 1095 textMain[textpointerMain++] = text[textpointer - 1];
+ − 1096 textMain[textpointerMain] = 0;
+ − 1097 lineFree--;
+ − 1098 }
+ − 1099 else
+ − 1100 {
+ − 1101 more++;
+ − 1102 }
+ − 1103 }
+ − 1104
+ − 1105 text[textpointer++] = '\t';
+ − 1106 text[textpointer++] = '\021';
+ − 1107 text[textpointer++] = TXT_2BYTE;
+ − 1108 text[textpointer++] = TXT2BYTE_WarnFallback;
+ − 1109 if(stateUsed->warnings.fallback)
+ − 1110 {
+ − 1111 text[textpointer - 3] = '\025';
+ − 1112 if(lineFree)
+ − 1113 {
+ − 1114 textMain[textpointerMain++] = TXT_2BYTE;
+ − 1115 textMain[textpointerMain++] = text[textpointer - 1];
+ − 1116 textMain[textpointerMain] = 0;
+ − 1117 lineFree--;
+ − 1118 }
+ − 1119 else
+ − 1120 {
+ − 1121 more++;
+ − 1122 }
+ − 1123 }
+ − 1124
+ − 1125 text[textpointer++] = '\n';
+ − 1126 text[textpointer++] = '\r';
+ − 1127 text[textpointer++] = '\021';
+ − 1128 text[textpointer++] = TXT_2BYTE;
+ − 1129 text[textpointer++] = TXT2BYTE_WarnSensorLinkLost;
+ − 1130 if(stateUsed->warnings.sensorLinkLost)
+ − 1131 {
+ − 1132 text[textpointer - 3] = '\025';
+ − 1133 if(lineFree)
+ − 1134 {
+ − 1135 textMain[textpointerMain++] = TXT_2BYTE;
+ − 1136 textMain[textpointerMain++] = text[textpointer - 1];
+ − 1137 textMain[textpointerMain] = 0;
+ − 1138 lineFree--;
+ − 1139 }
+ − 1140 else
+ − 1141 {
+ − 1142 more++;
+ − 1143 }
+ − 1144 }
+ − 1145
+ − 1146 /*
+ − 1147 text[textpointer++] = '\t';
+ − 1148 text[textpointer++] = '\021';
+ − 1149 text[textpointer++] = TXT_2BYTE;
+ − 1150 text[textpointer++] = TXT2BYTE_WarnBatteryLow;
+ − 1151 if(stateUsed->warnings.lowBattery)
+ − 1152 {
+ − 1153 text[textpointer - 3] = '\025';
+ − 1154 if(lineFree)
+ − 1155 {
+ − 1156 textMain[textpointerMain++] = TXT_2BYTE;
+ − 1157 textMain[textpointerMain++] = text[textpointer - 1];
+ − 1158 textMain[textpointerMain] = 0;
+ − 1159 lineFree--;
+ − 1160 }
+ − 1161 else
+ − 1162 {
+ − 1163 more++;
+ − 1164 }
+ − 1165 }
+ − 1166 */
+ − 1167 text[textpointer] = 0;
+ − 1168 /*
+ − 1169 if(more)
+ − 1170 {
+ − 1171 text[textpointer++] = '\002';
+ − 1172 text[textpointer++] = '+';
+ − 1173 if(more < 10)
+ − 1174 text[textpointer++] = '0' + more;
+ − 1175 else
+ − 1176 text[textpointer++] = 'X';
+ − 1177 text[textpointer] = 0;
+ − 1178 }
+ − 1179 */
+ − 1180 GFX_write_string(&FontT48,&t3c1,textMain,1);
+ − 1181 if(more)
+ − 1182 {
+ − 1183 GFX_write_string(&FontT48,&t3c2,text,1);
+ − 1184 }
+ − 1185 }
+ − 1186
+ − 1187
386
+ − 1188 void t3_change_customview(uint8_t action)
38
+ − 1189 {
386
+ − 1190 t3_basics_change_customview(&t3_selection_customview, t3_customviews, action);
38
+ − 1191 }
+ − 1192
+ − 1193
386
+ − 1194 void t3_basics_change_customview(uint8_t *tX_selection_customview, const uint8_t *tX_customviews, uint8_t action)
38
+ − 1195 {
+ − 1196 const SDecoinfo * pDecoinfo;
+ − 1197 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE)
+ − 1198 pDecoinfo = &stateUsed->decolistBuehlmann;
+ − 1199 else
+ − 1200 pDecoinfo = &stateUsed->decolistVPM;
+ − 1201
386
+ − 1202 uint8_t *pViews;
38
+ − 1203 pViews = tX_customviews;
+ − 1204
386
+ − 1205 uint8_t *pStartView,*pCurView, *pLastView;
+ − 1206 uint8_t iterate = 0; /* set to 1 if a view has to be skipped */
38
+ − 1207
386
+ − 1208 pStartView = pViews;
+ − 1209 /* set pointer to currently selected view and count number of entries */
+ − 1210 while((*pViews != CVIEW_T3_END))
+ − 1211 {
+ − 1212 if (*pViews == *tX_selection_customview)
+ − 1213 {
+ − 1214 pCurView = pViews;
+ − 1215 }
+ − 1216 pViews++;
+ − 1217 }
+ − 1218 pLastView = pViews;
+ − 1219 pViews = pCurView;
+ − 1220
+ − 1221 do
+ − 1222 {
+ − 1223 iterate = 0;
+ − 1224 if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS))
+ − 1225 {
+ − 1226 if(*pViews != CVIEW_T3_END)
+ − 1227 pViews++;
38
+ − 1228
386
+ − 1229 if(*pViews == CVIEW_T3_END)
+ − 1230 {
+ − 1231 pViews = pStartView;
+ − 1232 }
+ − 1233 }
+ − 1234 else
+ − 1235 {
+ − 1236 if(pViews == pStartView)
+ − 1237 {
+ − 1238 pViews = pLastView - 1;
+ − 1239 }
+ − 1240 else
+ − 1241 {
+ − 1242 pViews--;
+ − 1243 }
+ − 1244 }
+ − 1245 if((*pViews == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
+ − 1246 {
+ − 1247 iterate = 1;
+ − 1248 }
+ − 1249 if((*pViews == CVIEW_T3_TTS) && !pDecoinfo->output_time_to_surface_seconds)
+ − 1250 {
+ − 1251 iterate = 1;
+ − 1252 }
+ − 1253 }while (iterate == 1);
38
+ − 1254
386
+ − 1255 *tX_selection_customview = *pViews;
38
+ − 1256 }
+ − 1257
+ − 1258
+ − 1259 void t3_basics_colorscheme_mod(char *text)
+ − 1260 {
+ − 1261 if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard())
+ − 1262 {
+ − 1263 text[0] = '\027';
+ − 1264 }
+ − 1265 }
+ − 1266
+ − 1267
+ − 1268 point_t t3_compass_circle(uint8_t id, uint16_t degree)
+ − 1269 {
+ − 1270 float fCos, fSin;
+ − 1271 const float piMult = ((2 * 3.14159) / 360);
+ − 1272 // const int radius[4] = {95,105,115,60};
+ − 1273 const int radius[4] = {85,95,105,90};
+ − 1274 const point_t offset = {.x = 600, .y = 116};
+ − 1275
+ − 1276 static point_t r[4][360] = { 0 };
+ − 1277
+ − 1278 if(r[0][0].y == 0)
+ − 1279 {
+ − 1280 for(int i=0;i<360;i++)
+ − 1281 {
+ − 1282 fCos = cos(i * piMult);
+ − 1283 fSin = sin(i * piMult);
+ − 1284 for(int j=0;j<4;j++)
+ − 1285 {
+ − 1286 r[j][i].x = offset.x + (int)(fSin * radius[j]);
+ − 1287 r[j][i].y = offset.y + (int)(fCos * radius[j]);
+ − 1288 }
+ − 1289 }
+ − 1290 }
+ − 1291 if(id > 3) id = 0;
+ − 1292 if(degree > 359) degree = 0;
+ − 1293 return r[id][degree];
+ − 1294 }
+ − 1295
+ − 1296
+ − 1297 void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, uint16_t ActualHeading, uint16_t UserSetHeading)
+ − 1298 {
+ − 1299 uint16_t LineHeading;
+ − 1300 point_t center;
+ − 1301 static int32_t LastHeading = 0;
+ − 1302 int32_t newHeading = 0;
+ − 1303 int32_t diff = 0;
+ − 1304 int32_t diff2 = 0;
+ − 1305
+ − 1306 int32_t diffAbs = 0;
+ − 1307 int32_t diffAbs2 = 0;
+ − 1308
+ − 1309 newHeading = ActualHeading;
+ − 1310
+ − 1311 diff = newHeading - LastHeading;
+ − 1312
+ − 1313 if(newHeading < LastHeading)
+ − 1314 diff2 = newHeading + 360 - LastHeading;
+ − 1315 else
+ − 1316 diff2 = newHeading - 360 - LastHeading;
+ − 1317
+ − 1318 diffAbs = diff;
+ − 1319 if(diffAbs < 0)
+ − 1320 diffAbs *= -1;
+ − 1321
+ − 1322 diffAbs2 = diff2;
+ − 1323 if(diffAbs2 < 0)
+ − 1324 diffAbs2 *= -1;
+ − 1325
+ − 1326 if(diffAbs <= diffAbs2)
+ − 1327 newHeading = LastHeading + (diff / 2);
+ − 1328 else
+ − 1329 newHeading = LastHeading + (diff2 / 2);
+ − 1330
+ − 1331 if(newHeading < 0)
+ − 1332 newHeading += 360;
+ − 1333 else
+ − 1334 if(newHeading >= 360)
+ − 1335 newHeading -= 360;
+ − 1336
+ − 1337 LastHeading = newHeading;
+ − 1338 ActualHeading = newHeading;
+ − 1339
+ − 1340 if (ActualHeading < 90)
+ − 1341 ActualHeading += 360;
+ − 1342
+ − 1343 while(ActualHeading > 359) ActualHeading -= 360;
+ − 1344
+ − 1345 LineHeading = 360 - ActualHeading;
+ − 1346 GFX_draw_thick_line(9,tXscreen, t3_compass_circle(0,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font030); // North
+ − 1347 LineHeading += 90;
+ − 1348 if(LineHeading > 359) LineHeading -= 360;
+ − 1349 GFX_draw_thick_line(9,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031); // Maintick
+ − 1350 LineHeading += 90;
+ − 1351 if(LineHeading > 359) LineHeading -= 360;
+ − 1352 GFX_draw_thick_line(9,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1353 LineHeading += 90;
+ − 1354 if(LineHeading > 359) LineHeading -= 360;
+ − 1355 GFX_draw_thick_line(9,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1356
+ − 1357 LineHeading = 360 - ActualHeading;
+ − 1358 LineHeading += 45;
+ − 1359 if(LineHeading > 359) LineHeading -= 360;
+ − 1360 GFX_draw_thick_line(5,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031); // Subtick
+ − 1361 LineHeading += 90;
+ − 1362 if(LineHeading > 359) LineHeading -= 360;
+ − 1363 GFX_draw_thick_line(5,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1364 LineHeading += 90;
+ − 1365 if(LineHeading > 359) LineHeading -= 360;
+ − 1366 GFX_draw_thick_line(5,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1367 LineHeading += 90;
+ − 1368 if(LineHeading > 359) LineHeading -= 360;
+ − 1369 GFX_draw_thick_line(5,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1370
+ − 1371 LineHeading = 360 - ActualHeading;
+ − 1372 LineHeading += 22;
+ − 1373 if(LineHeading > 359) LineHeading -= 360;
+ − 1374 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031); // Subtick
+ − 1375 LineHeading += 45;
+ − 1376 if(LineHeading > 359) LineHeading -= 360;
+ − 1377 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1378 LineHeading += 45;
+ − 1379 if(LineHeading > 359) LineHeading -= 360;
+ − 1380 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1381 LineHeading += 45;
+ − 1382 if(LineHeading > 359) LineHeading -= 360;
+ − 1383 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1384 LineHeading += 45;
+ − 1385 if(LineHeading > 359) LineHeading -= 360;
+ − 1386 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031); // Subtick
+ − 1387 LineHeading += 45;
+ − 1388 if(LineHeading > 359) LineHeading -= 360;
+ − 1389 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1390 LineHeading += 45;
+ − 1391 if(LineHeading > 359) LineHeading -= 360;
+ − 1392 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1393 LineHeading += 45;
+ − 1394 if(LineHeading > 359) LineHeading -= 360;
+ − 1395 GFX_draw_thick_line(3,tXscreen, t3_compass_circle(1,LineHeading), t3_compass_circle(2,LineHeading), CLUT_Font031);
+ − 1396
+ − 1397 if(UserSetHeading)
+ − 1398 {
+ − 1399 LineHeading = UserSetHeading + 360 - ActualHeading;
+ − 1400 if(LineHeading > 359) LineHeading -= 360;
+ − 1401 GFX_draw_thick_line(9,tXscreen, t3_compass_circle(3,LineHeading), t3_compass_circle(2,LineHeading), CLUT_CompassUserHeadingTick);
+ − 1402
+ − 1403 // R�ckpeilung, User Back Heading
+ − 1404 LineHeading = UserSetHeading + 360 + 180 - ActualHeading;
+ − 1405 if(LineHeading > 359) LineHeading -= 360;
+ − 1406 if(LineHeading > 359) LineHeading -= 360;
+ − 1407 GFX_draw_thick_line(9,tXscreen, t3_compass_circle(3,LineHeading), t3_compass_circle(2,LineHeading), CLUT_CompassUserBackHeadingTick);
+ − 1408 }
+ − 1409
+ − 1410 center.x = 600;
+ − 1411 center.y = 116;
+ − 1412 GFX_draw_circle(tXscreen, center, 106, CLUT_Font030);
+ − 1413 GFX_draw_circle(tXscreen, center, 107, CLUT_Font030);
+ − 1414 GFX_draw_circle(tXscreen, center, 108, CLUT_Font030);
+ − 1415 }
384
+ − 1416
+ − 1417 uint8_t t3_GetEnabled_customviews()
+ − 1418 {
+ − 1419 int8_t i;
+ − 1420 uint8_t enabledViewCnt = 0;
+ − 1421 uint32_t cv_config = settingsGetPointer()->cv_configuration;
+ − 1422
+ − 1423 i=0;
+ − 1424 do
+ − 1425 {
+ − 1426 if(cv_changelist[i] == CVIEW_sensors) /* at the moment specific big font view may not be selected. Only sensor setting is taken from t7 configuration */
+ − 1427 {
+ − 1428 if(!CHECK_BIT_THOME(cv_config, cv_changelist[i]))
+ − 1429 {
+ − 1430 enabledViewCnt = NUMBER_OF_VIEWS - 1; /* sensor shall not be displayed */
+ − 1431 }
+ − 1432 else
+ − 1433 {
+ − 1434 enabledViewCnt = NUMBER_OF_VIEWS; /* enable all possible views */
+ − 1435 }
+ − 1436 break;
+ − 1437 }
+ − 1438 i++;
+ − 1439 } while(cv_changelist[i] != CVIEW_END);
+ − 1440 if ((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0))
+ − 1441 {
+ − 1442 enabledViewCnt = NUMBER_OF_VIEWS - 1; /* sensor shall not be displayed */
+ − 1443 }
+ − 1444
+ − 1445 return enabledViewCnt;
+ − 1446 }
+ − 1447
+ − 1448