Mercurial > public > ostc4
comparison Discovery/Src/t3.c @ 945:aad1a6b9aaec Evo_2_23
Added slow exit graph to t3 view:
In the first implementation slow exit was only available in T7 view. To enable it in T3 view the common parts have been extracted into a separate function which is shared between T7 and T3. Only the drawing specific parts remain in the T7 / T3 files.
| author | Ideenmodellierer |
|---|---|
| date | Thu, 19 Dec 2024 22:16:36 +0100 |
| parents | 4d98fb2a178e |
| children | e9c37071933b |
comparison
equal
deleted
inserted
replaced
| 944:44599695df41 | 945:aad1a6b9aaec |
|---|---|
| 83 | 83 |
| 84 uint8_t t3_test_customview_warnings(void); | 84 uint8_t t3_test_customview_warnings(void); |
| 85 void t3_refresh_customview(float depth); | 85 void t3_refresh_customview(float depth); |
| 86 void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, point_t center, uint16_t ActualHeading, uint16_t UserSetHeading); | 86 void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, point_t center, uint16_t ActualHeading, uint16_t UserSetHeading); |
| 87 uint8_t t3_EvaluateAFCondition(uint8_t T3CView); | 87 uint8_t t3_EvaluateAFCondition(uint8_t T3CView); |
| 88 uint8_t t3_drawSlowExitGraph(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1); /* this function is only called if diver is below last last stop depth */ | |
| 88 | 89 |
| 89 /* Exported functions --------------------------------------------------------*/ | 90 /* Exported functions --------------------------------------------------------*/ |
| 90 | 91 |
| 91 void t3_init(void) | 92 void t3_init(void) |
| 92 { | 93 { |
| 388 | 389 |
| 389 float t3_basics_lines_depth_and_divetime(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode) | 390 float t3_basics_lines_depth_and_divetime(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1, uint8_t mode) |
| 390 { | 391 { |
| 391 char text[256]; | 392 char text[256]; |
| 392 uint8_t textPointer; | 393 uint8_t textPointer; |
| 393 uint8_t color; | 394 uint8_t color = 0; |
| 394 uint8_t depthChangeRate; | 395 uint8_t depthChangeRate; |
| 395 uint8_t depthChangeAscent; | 396 uint8_t depthChangeAscent; |
| 396 point_t start, stop, startZeroLine; | 397 point_t start, stop, startZeroLine; |
| 397 SDivetime Divetime = {0,0,0,0}; | 398 SDivetime Divetime = {0,0,0,0}; |
| 399 uint16_t nextstopLengthSeconds = 0; | |
| 400 uint8_t nextstopDepthMeter = 0; | |
| 398 | 401 |
| 399 SSettings* pSettings; | 402 SSettings* pSettings; |
| 400 pSettings = settingsGetPointer(); | 403 pSettings = settingsGetPointer(); |
| 404 | |
| 405 const SDecoinfo * pDecoinfo = getDecoInfo(); | |
| 406 if(pDecoinfo->output_time_to_surface_seconds) | |
| 407 { | |
| 408 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); | |
| 409 } | |
| 410 else | |
| 411 { | |
| 412 nextstopDepthMeter = 0; | |
| 413 nextstopLengthSeconds = 0; | |
| 414 } | |
| 401 | 415 |
| 402 start.x = 0; | 416 start.x = 0; |
| 403 stop.x = 799; | 417 stop.x = 799; |
| 404 stop.y = start.y = BigFontSeperationTopBottom; | 418 stop.y = start.y = BigFontSeperationTopBottom; |
| 405 if((viewInFocus()) && (!viewDetectionSuspended())) | 419 if((viewInFocus()) && (!viewDetectionSuspended())) |
| 421 } | 435 } |
| 422 else | 436 else |
| 423 { | 437 { |
| 424 GFX_draw_line(tXscreen, start, stop, CLUT_Font020); | 438 GFX_draw_line(tXscreen, start, stop, CLUT_Font020); |
| 425 } | 439 } |
| 426 | |
| 427 /* depth */ | |
| 428 color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); | |
| 429 float depth = unit_depth_float(stateUsed->lifeData.depth_meter); | |
| 430 | |
| 431 if(depth <= 0.3f) | |
| 432 depth = 0; | |
| 433 | |
| 434 if(settingsGetPointer()->nonMetricalSystem) | |
| 435 snprintf(text,TEXTSIZE,"\032\f[feet]"); | |
| 436 else | |
| 437 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); | |
| 438 GFX_write_string(&FontT42,tXl1,text,0); | |
| 439 | |
| 440 if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 ))) | |
| 441 || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))) | |
| 442 ) | |
| 443 { | |
| 444 snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min " | |
| 445 , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min) | |
| 446 , unit_depth_char1() | |
| 447 , unit_depth_char2() | |
| 448 ); | |
| 449 GFX_write_string(&FontT42,tXl1,text,0); | |
| 450 } | |
| 451 | |
| 452 if( depth < 100) | |
| 453 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth); | |
| 454 else | |
| 455 snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); | |
| 456 | |
| 457 Gfx_colorsscheme_mod(text,color); | |
| 458 GFX_write_string(&FontT105,tXl1,text,1); | |
| 459 | |
| 460 | 440 |
| 461 /* ascentrate graph */ | 441 /* ascentrate graph */ |
| 462 if(mode == DIVEMODE_Apnea) | 442 if(mode == DIVEMODE_Apnea) |
| 463 { | 443 { |
| 464 /* ascentrate graph - apnea mode */ | 444 /* ascentrate graph - apnea mode */ |
| 553 GFX_draw_thick_line(12,tXscreen, start, stop, color); | 533 GFX_draw_thick_line(12,tXscreen, start, stop, color); |
| 554 } | 534 } |
| 555 } | 535 } |
| 556 else | 536 else |
| 557 { | 537 { |
| 558 /* ascentrate graph -standard mode */ | 538 if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter)) |
| 559 if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) | 539 { |
| 560 { | 540 color = t3_drawSlowExitGraph(tXscreen, tXl1, tXr1); |
| 561 if(!pSettings->FlipDisplay) | 541 } |
| 562 { | 542 else |
| 563 start.y = tXl1->WindowY0 - 1; | 543 { |
| 564 } | 544 if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) /* ascentrate graph -standard mode */ |
| 565 else | 545 { |
| 566 { | 546 if(!pSettings->FlipDisplay) |
| 567 start.y = tXl1->WindowY1 + 1; | 547 { |
| 568 } | 548 start.y = tXl1->WindowY0 - 1; |
| 569 | 549 } |
| 570 for(int i = 0; i<4;i++) | 550 else |
| 571 { | 551 { |
| 572 start.y += 5*8; | 552 start.y = tXl1->WindowY1 + 1; |
| 573 stop.y = start.y; | 553 } |
| 574 if(!pSettings->FlipDisplay) | 554 |
| 575 { | 555 for(int i = 0; i<4;i++) |
| 576 start.x = tXl1->WindowX1 - 1; | 556 { |
| 577 } | 557 start.y += 5*8; |
| 578 else | 558 stop.y = start.y; |
| 579 { | 559 if(!pSettings->FlipDisplay) |
| 580 start.x = tXr1->WindowX1 - 1; | 560 { |
| 581 } | 561 start.x = tXl1->WindowX1 - 1; |
| 582 stop.x = start.x - 17; | 562 } |
| 583 GFX_draw_line(tXscreen, start, stop, 0); | 563 else |
| 584 } | 564 { |
| 585 // new thick bar design Sept. 2015 | 565 start.x = tXr1->WindowX1 + 3; |
| 586 if(!pSettings->FlipDisplay) | 566 } |
| 587 { | 567 stop.x = start.x - 17; |
| 588 start.x = tXl1->WindowX1 - 3 - 5; | 568 GFX_draw_line(tXscreen, start, stop, 0); |
| 589 } | 569 } |
| 590 else | 570 // new thick bar design Sept. 2015 |
| 591 { | 571 if(!pSettings->FlipDisplay) |
| 592 start.x = tXr1->WindowX1 - 3 - 5; | 572 { |
| 593 } | 573 start.x = tXl1->WindowX1 - 3 - 5; |
| 594 | 574 } |
| 595 stop.x = start.x; | 575 else |
| 596 if(!pSettings->FlipDisplay) | 576 { |
| 597 { | 577 start.x = tXr1->WindowX1 - 3 - 5; |
| 598 start.y = tXl1->WindowY0 - 1; | 578 } |
| 599 } | 579 |
| 600 else | 580 stop.x = start.x; |
| 601 { | 581 if(!pSettings->FlipDisplay) |
| 602 start.y = tXl1->WindowY1 + 1; | 582 { |
| 603 } | 583 start.y = tXl1->WindowY0 - 1; |
| 604 | 584 } |
| 605 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8); | 585 else |
| 606 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 | 586 { |
| 607 if(stop.y >= 470) | 587 start.y = tXl1->WindowY1 + 1; |
| 608 stop.y = 470; | 588 } |
| 609 start.y += 7; // starte etwas weiter oben | 589 |
| 610 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) | 590 stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8); |
| 611 color = CLUT_EverythingOkayGreen; | 591 stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 |
| 612 else | 592 if(stop.y >= 470) |
| 613 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) | 593 stop.y = 470; |
| 614 color = CLUT_WarningYellow; | 594 start.y += 7; // starte etwas weiter oben |
| 615 else | 595 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) |
| 616 color = CLUT_WarningRed; | 596 color = CLUT_EverythingOkayGreen; |
| 617 | 597 else |
| 618 GFX_draw_thick_line(12,tXscreen, start, stop, color); | 598 if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) |
| 619 } | 599 color = CLUT_WarningYellow; |
| 620 } | 600 else |
| 601 color = CLUT_WarningRed; | |
| 602 | |
| 603 GFX_draw_thick_line(12,tXscreen, start, stop, color); | |
| 604 } | |
| 605 color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); | |
| 606 } | |
| 607 } | |
| 608 /* depth */ | |
| 609 float depth = unit_depth_float(stateUsed->lifeData.depth_meter); | |
| 610 | |
| 611 if(depth <= 0.3f) | |
| 612 depth = 0; | |
| 613 | |
| 614 if(settingsGetPointer()->nonMetricalSystem) | |
| 615 snprintf(text,TEXTSIZE,"\032\f[feet]"); | |
| 616 else | |
| 617 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); | |
| 618 GFX_write_string(&FontT42,tXl1,text,0); | |
| 619 | |
| 620 if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 ))) | |
| 621 || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))) | |
| 622 ) | |
| 623 { | |
| 624 snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min " | |
| 625 , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min) | |
| 626 , unit_depth_char1() | |
| 627 , unit_depth_char2() | |
| 628 ); | |
| 629 GFX_write_string(&FontT42,tXl1,text,0); | |
| 630 } | |
| 631 | |
| 632 if( depth < 100) | |
| 633 snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth); | |
| 634 else | |
| 635 snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); | |
| 636 | |
| 637 Gfx_colorsscheme_mod(text,color); | |
| 638 GFX_write_string(&FontT105,tXl1,text,1); | |
| 639 | |
| 621 | 640 |
| 622 // divetime | 641 // divetime |
| 623 if(mode == DIVEMODE_Apnea) | 642 if(mode == DIVEMODE_Apnea) |
| 624 { | 643 { |
| 625 if(stateUsed->lifeData.counterSecondsShallowDepth) | 644 if(stateUsed->lifeData.counterSecondsShallowDepth) |
| 2123 break; | 2142 break; |
| 2124 } | 2143 } |
| 2125 } | 2144 } |
| 2126 } | 2145 } |
| 2127 } | 2146 } |
| 2147 | |
| 2148 #define ASCENT_GRAPH_YPIXEL 220 | |
| 2149 uint8_t t3_drawSlowExitGraph(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1) /* this function is only called if diver is below last last stop depth */ | |
| 2150 { | |
| 2151 static uint16_t countDownSec = 0; | |
| 2152 uint8_t drawingMeterStep; | |
| 2153 static float exitDepthMeter = 0.0; | |
| 2154 | |
| 2155 | |
| 2156 uint8_t index = 0; | |
| 2157 uint8_t color = 0; | |
| 2158 point_t start, stop; | |
| 2159 | |
| 2160 SSettings* pSettings; | |
| 2161 pSettings = settingsGetPointer(); | |
| 2162 | |
| 2163 | |
| 2164 if(calculateSlowExit(&countDownSec, &exitDepthMeter, &color)) /* graph to be drawn? */ | |
| 2165 { | |
| 2166 if(!pSettings->FlipDisplay) | |
| 2167 { | |
| 2168 start.y = tXl1->WindowY0 - 1; | |
| 2169 } | |
| 2170 else | |
| 2171 { | |
| 2172 start.y = tXl1->WindowY1 + 1; | |
| 2173 } | |
| 2174 | |
| 2175 drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */ | |
| 2176 | |
| 2177 for(index = 0; index < pSettings->last_stop_depth_meter; index++) /* draw meter indicators */ | |
| 2178 { | |
| 2179 start.y += drawingMeterStep; | |
| 2180 stop.y = start.y; | |
| 2181 if(!pSettings->FlipDisplay) | |
| 2182 { | |
| 2183 start.x = tXl1->WindowX1 - 1; | |
| 2184 } | |
| 2185 else | |
| 2186 { | |
| 2187 start.x = tXr1->WindowX1 + 3; | |
| 2188 } | |
| 2189 stop.x = start.x - 43; | |
| 2190 GFX_draw_line(tXscreen, start, stop, 0); | |
| 2191 } | |
| 2192 | |
| 2193 /* draw cntdown bar */ | |
| 2194 | |
| 2195 if(!pSettings->FlipDisplay) | |
| 2196 { | |
| 2197 start.x -= 20; | |
| 2198 start.y = tXl1->WindowY0 + ASCENT_GRAPH_YPIXEL + 2; | |
| 2199 } | |
| 2200 else | |
| 2201 { | |
| 2202 start.x -= 25; | |
| 2203 start.y = tXl1->WindowY1 + ASCENT_GRAPH_YPIXEL + 5; | |
| 2204 } | |
| 2205 stop.x = start.x; | |
| 2206 stop.y = start.y - countDownSec * (ASCENT_GRAPH_YPIXEL / (float)(pSettings->slowExitTime * 60.0)); | |
| 2207 if(stop.y >= 470) stop.y = 470; | |
| 2208 if(!pSettings->FlipDisplay) | |
| 2209 { | |
| 2210 stop.y += 5; | |
| 2211 } | |
| 2212 GFX_draw_thick_line(15,tXscreen, start, stop, 3); | |
| 2213 /* mark diver depth */ | |
| 2214 if(!pSettings->FlipDisplay) | |
| 2215 { | |
| 2216 start.x = tXl1->WindowX1 - 32; | |
| 2217 stop.x = start.x + 24; | |
| 2218 } | |
| 2219 else | |
| 2220 { | |
| 2221 start.x = tXr1->WindowX1 - 33; | |
| 2222 stop.x = start.x + 24; | |
| 2223 } | |
| 2224 | |
| 2225 | |
| 2226 start.y = start.y - (stateUsed->lifeData.depth_meter * (ASCENT_GRAPH_YPIXEL) / pSettings->last_stop_depth_meter); | |
| 2227 stop.y = start.y; | |
| 2228 GFX_draw_thick_line(10,tXscreen, start, stop, 9); | |
| 2229 } | |
| 2230 return color; | |
| 2231 } |
