Mercurial > public > ostc4
changeset 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 | 44599695df41 |
children | 80ae8ea7f0a0 |
files | Common/Inc/data_central.h Discovery/Src/data_central.c Discovery/Src/t3.c Discovery/Src/t7.c |
diffstat | 4 files changed, 338 insertions(+), 214 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/data_central.h Thu Dec 19 18:58:18 2024 +0100 +++ b/Common/Inc/data_central.h Thu Dec 19 22:16:36 2024 +0100 @@ -180,6 +180,14 @@ uint8_t signalQual[4]; /* signal quality indicator for x sats */ } SGnssInfo; +typedef enum +{ + SE_INIT = 0, + SE_REINIT, + SE_ACTIVE, + SE_END +} SSlowExitState; + /* struct SLifeData * contains data all actual data (pressure, stuturation, etc. as received from second ship @@ -570,5 +578,6 @@ void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year); void getStringOfFormat_DDMMYY(char* pString, uint8_t strLen); +uint8_t calculateSlowExit(uint16_t* pCountDownSec, float* pExitDepthMeter, uint8_t* pColor); #endif // DATA_CENTRAL_H
--- a/Discovery/Src/data_central.c Thu Dec 19 18:58:18 2024 +0100 +++ b/Discovery/Src/data_central.c Thu Dec 19 22:16:36 2024 +0100 @@ -1007,4 +1007,91 @@ } } +uint8_t calculateSlowExit(uint16_t* pCountDownSec, float* pExitDepthMeter, uint8_t* pColor) /* this function is only called if diver is below last last stop depth */ +{ + static SSlowExitState slowExitState = SE_END; + static uint16_t countDownSec = 0; + static float exitDepthMeter = 0.0; + static uint32_t exitSecTick = 0; + static uint32_t lastSecTick = 0; + static uint8_t color = 0; + static uint8_t drawingActive = 0; + SSettings* pSettings; + pSettings = settingsGetPointer(); + + if((stateUsed->lifeData.max_depth_meter < pSettings->last_stop_depth_meter) /* start of dive => reinit timer */ + || (slowExitState == SE_REINIT)) + { + if(slowExitState != SE_INIT) + { + countDownSec = pSettings->slowExitTime * 60; + slowExitState = SE_INIT; + exitDepthMeter = pSettings->last_stop_depth_meter; + color = 0; + drawingActive = 0; + } + } + else + { + if(slowExitState != SE_END) + { + if((slowExitState == SE_INIT) && (stateUsed->lifeData.dive_time_seconds > 900)) /* min 15min divetime */ + { + slowExitState = SE_ACTIVE; + exitSecTick = HAL_GetTick(); + lastSecTick = exitSecTick; + } + else if(slowExitState == SE_ACTIVE) + { + if(time_elapsed_ms(lastSecTick, HAL_GetTick()) > 60000) /* restart timer if diver go below exit zone */ + { + slowExitState = SE_REINIT; + } + else if(time_elapsed_ms(exitSecTick, HAL_GetTick()) > 1000) + { + exitSecTick = HAL_GetTick(); + lastSecTick = exitSecTick; + /* select depth digit color */ + if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) < 0.5 ) + { + color = CLUT_NiceGreen; + } + else if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) <= 1.5) + { + color = CLUT_WarningYellow; + } + else if(stateUsed->lifeData.depth_meter - exitDepthMeter < -1.5 ) + { + color = CLUT_WarningRed; + } + else + { + color = 0; + } + + if((fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) <= 1.6 ) /* only decrease counter if diver is close to target depth */ + || (color == CLUT_WarningRed)) /* or if diver is far ahead */ + { + countDownSec--; + if(countDownSec == 0) + { + slowExitState = SE_END; + color = 0; + exitDepthMeter = 0; + } + else + { + exitDepthMeter -= (pSettings->last_stop_depth_meter / (float)(pSettings->slowExitTime * 60)); + } + } + drawingActive = 1; + } + } + } + } + *pCountDownSec = countDownSec; + *pExitDepthMeter = exitDepthMeter; + *pColor = color; + return drawingActive; +}
--- a/Discovery/Src/t3.c Thu Dec 19 18:58:18 2024 +0100 +++ b/Discovery/Src/t3.c Thu Dec 19 22:16:36 2024 +0100 @@ -85,6 +85,7 @@ void t3_refresh_customview(float depth); void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, point_t center, uint16_t ActualHeading, uint16_t UserSetHeading); uint8_t t3_EvaluateAFCondition(uint8_t T3CView); +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 */ /* Exported functions --------------------------------------------------------*/ @@ -390,15 +391,28 @@ { char text[256]; uint8_t textPointer; - uint8_t color; + uint8_t color = 0; uint8_t depthChangeRate; uint8_t depthChangeAscent; point_t start, stop, startZeroLine; SDivetime Divetime = {0,0,0,0}; + uint16_t nextstopLengthSeconds = 0; + uint8_t nextstopDepthMeter = 0; SSettings* pSettings; pSettings = settingsGetPointer(); + const SDecoinfo * pDecoinfo = getDecoInfo(); + if(pDecoinfo->output_time_to_surface_seconds) + { + tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); + } + else + { + nextstopDepthMeter = 0; + nextstopLengthSeconds = 0; + } + start.x = 0; stop.x = 799; stop.y = start.y = BigFontSeperationTopBottom; @@ -424,40 +438,6 @@ GFX_draw_line(tXscreen, start, stop, CLUT_Font020); } - /* depth */ - color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); - float depth = unit_depth_float(stateUsed->lifeData.depth_meter); - - if(depth <= 0.3f) - depth = 0; - - if(settingsGetPointer()->nonMetricalSystem) - snprintf(text,TEXTSIZE,"\032\f[feet]"); - else - snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); - GFX_write_string(&FontT42,tXl1,text,0); - - if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 ))) - || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))) - ) - { - snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min " - , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min) - , unit_depth_char1() - , unit_depth_char2() - ); - GFX_write_string(&FontT42,tXl1,text,0); - } - - if( depth < 100) - snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth); - else - snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); - - Gfx_colorsscheme_mod(text,color); - GFX_write_string(&FontT105,tXl1,text,1); - - /* ascentrate graph */ if(mode == DIVEMODE_Apnea) { @@ -555,69 +535,108 @@ } else { - /* ascentrate graph -standard mode */ - if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) - { - if(!pSettings->FlipDisplay) - { - start.y = tXl1->WindowY0 - 1; - } - else - { - start.y = tXl1->WindowY1 + 1; - } + if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter)) + { + color = t3_drawSlowExitGraph(tXscreen, tXl1, tXr1); + } + else + { + if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) /* ascentrate graph -standard mode */ + { + if(!pSettings->FlipDisplay) + { + start.y = tXl1->WindowY0 - 1; + } + else + { + start.y = tXl1->WindowY1 + 1; + } + + for(int i = 0; i<4;i++) + { + start.y += 5*8; + stop.y = start.y; + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 1; + } + else + { + start.x = tXr1->WindowX1 + 3; + } + stop.x = start.x - 17; + GFX_draw_line(tXscreen, start, stop, 0); + } + // new thick bar design Sept. 2015 + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 3 - 5; + } + else + { + start.x = tXr1->WindowX1 - 3 - 5; + } - for(int i = 0; i<4;i++) - { - start.y += 5*8; - stop.y = start.y; - if(!pSettings->FlipDisplay) - { - start.x = tXl1->WindowX1 - 1; - } - else - { - start.x = tXr1->WindowX1 - 1; - } - stop.x = start.x - 17; - GFX_draw_line(tXscreen, start, stop, 0); - } - // new thick bar design Sept. 2015 - if(!pSettings->FlipDisplay) - { - start.x = tXl1->WindowX1 - 3 - 5; - } - else - { - start.x = tXr1->WindowX1 - 3 - 5; - } + stop.x = start.x; + if(!pSettings->FlipDisplay) + { + start.y = tXl1->WindowY0 - 1; + } + else + { + start.y = tXl1->WindowY1 + 1; + } + + stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8); + stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 + if(stop.y >= 470) + stop.y = 470; + start.y += 7; // starte etwas weiter oben + if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) + color = CLUT_EverythingOkayGreen; + else + if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) + color = CLUT_WarningYellow; + else + color = CLUT_WarningRed; - stop.x = start.x; - if(!pSettings->FlipDisplay) - { - start.y = tXl1->WindowY0 - 1; - } - else - { - start.y = tXl1->WindowY1 + 1; - } + GFX_draw_thick_line(12,tXscreen, start, stop, color); + } + color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); + } + } + /* depth */ + float depth = unit_depth_float(stateUsed->lifeData.depth_meter); + + if(depth <= 0.3f) + depth = 0; + + if(settingsGetPointer()->nonMetricalSystem) + snprintf(text,TEXTSIZE,"\032\f[feet]"); + else + snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); + GFX_write_string(&FontT42,tXl1,text,0); - stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8); - stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 - if(stop.y >= 470) - stop.y = 470; - start.y += 7; // starte etwas weiter oben - if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10) - color = CLUT_EverythingOkayGreen; - else - if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15) - color = CLUT_WarningYellow; - else - color = CLUT_WarningRed; + if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 ))) + || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))) + ) + { + snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min " + , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min) + , unit_depth_char1() + , unit_depth_char2() + ); + GFX_write_string(&FontT42,tXl1,text,0); + } - GFX_draw_thick_line(12,tXscreen, start, stop, color); - } - } + if( depth < 100) + snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth); + else + snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); + + Gfx_colorsscheme_mod(text,color); + GFX_write_string(&FontT105,tXl1,text,1); + // divetime if(mode == DIVEMODE_Apnea) @@ -2125,3 +2144,88 @@ } } } + +#define ASCENT_GRAPH_YPIXEL 220 +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 */ +{ + static uint16_t countDownSec = 0; + uint8_t drawingMeterStep; + static float exitDepthMeter = 0.0; + + + uint8_t index = 0; + uint8_t color = 0; + point_t start, stop; + + SSettings* pSettings; + pSettings = settingsGetPointer(); + + + if(calculateSlowExit(&countDownSec, &exitDepthMeter, &color)) /* graph to be drawn? */ + { + if(!pSettings->FlipDisplay) + { + start.y = tXl1->WindowY0 - 1; + } + else + { + start.y = tXl1->WindowY1 + 1; + } + + drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */ + + for(index = 0; index < pSettings->last_stop_depth_meter; index++) /* draw meter indicators */ + { + start.y += drawingMeterStep; + stop.y = start.y; + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 1; + } + else + { + start.x = tXr1->WindowX1 + 3; + } + stop.x = start.x - 43; + GFX_draw_line(tXscreen, start, stop, 0); + } + + /* draw cntdown bar */ + + if(!pSettings->FlipDisplay) + { + start.x -= 20; + start.y = tXl1->WindowY0 + ASCENT_GRAPH_YPIXEL + 2; + } + else + { + start.x -= 25; + start.y = tXl1->WindowY1 + ASCENT_GRAPH_YPIXEL + 5; + } + stop.x = start.x; + stop.y = start.y - countDownSec * (ASCENT_GRAPH_YPIXEL / (float)(pSettings->slowExitTime * 60.0)); + if(stop.y >= 470) stop.y = 470; + if(!pSettings->FlipDisplay) + { + stop.y += 5; + } + GFX_draw_thick_line(15,tXscreen, start, stop, 3); + /* mark diver depth */ + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 32; + stop.x = start.x + 24; + } + else + { + start.x = tXr1->WindowX1 - 33; + stop.x = start.x + 24; + } + + + start.y = start.y - (stateUsed->lifeData.depth_meter * (ASCENT_GRAPH_YPIXEL) / pSettings->last_stop_depth_meter); + stop.y = start.y; + GFX_draw_thick_line(10,tXscreen, start, stop, 9); + } + return color; +}
--- a/Discovery/Src/t7.c Thu Dec 19 18:58:18 2024 +0100 +++ b/Discovery/Src/t7.c Thu Dec 19 22:16:36 2024 +0100 @@ -126,13 +126,6 @@ /* Private types -------------------------------------------------------------*/ -typedef enum -{ - SE_INIT = 0, - SE_REINIT, - SE_ACTIVE, - SE_END -} SSlowExitState; const uint8_t customviewsSurfaceStandard[] = { @@ -2882,7 +2875,8 @@ snprintf(TextR2,TEXTSIZE,"\032\f\002%c",TXT_Decostop); GFX_write_string(&FontT42,&t7r2,TextR2,0); - if((pSettings->VPM_conservatism.ub.alternative) && (fabs(stateUsed->lifeData.depth_meter - nextstopDepthMeter)) < 1.5) + if((stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) && (pSettings->VPM_conservatism.ub.alternative) + && (fabs(stateUsed->lifeData.depth_meter - nextstopDepthMeter)) < 1.5) { TextR2[0] = '\026'; textlength = 1; @@ -4820,132 +4814,62 @@ uint8_t t7_drawSlowExitGraph() /* this function is only called if diver is below last last stop depth */ { - static SSlowExitState slowExitState = SE_END; static uint16_t countDownSec = 0; - static uint8_t drawingMeterStep; + uint8_t drawingMeterStep; static float exitDepthMeter = 0.0; - static uint32_t exitSecTick = 0; - static uint32_t lastSecTick = 0; uint8_t index = 0; - static uint8_t color = 0; + uint8_t color = 0; point_t start, stop; SSettings* pSettings; pSettings = settingsGetPointer(); - if((stateUsed->lifeData.max_depth_meter < pSettings->last_stop_depth_meter) /* start of dive => reinit timer */ - || (slowExitState == SE_REINIT)) + + if(calculateSlowExit(&countDownSec, &exitDepthMeter, &color)) /* graph to be drawn? */ { - if(slowExitState != SE_INIT) + if(!pSettings->FlipDisplay) { - countDownSec = pSettings->slowExitTime * 60; - drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */ - slowExitState = SE_INIT; - exitDepthMeter = pSettings->last_stop_depth_meter; - color = 0; + start.y = t7l1.WindowY0 - 1; } - } - else - { - if(slowExitState != SE_END) + else + { + start.y = t7l3.WindowY0 - 25; + } + drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */ + for(index = 0; index < pSettings->last_stop_depth_meter; index++) /* draw meter indicators */ { - if((slowExitState == SE_INIT) && (stateUsed->lifeData.dive_time_seconds > 900)) /* min 15min divetime */ - { - slowExitState = SE_ACTIVE; - exitSecTick = HAL_GetTick(); - lastSecTick = exitSecTick; - } - else if(slowExitState == SE_ACTIVE) - { - if(time_elapsed_ms(lastSecTick, HAL_GetTick()) > 60000) /* restart timer if diver go below exit zone */ - { - slowExitState = SE_REINIT; - } - else if(time_elapsed_ms(exitSecTick, HAL_GetTick()) > 1000) - { - exitSecTick = HAL_GetTick(); - lastSecTick = exitSecTick; - /* select depth digit color */ - if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) < 0.5 ) - { - color = CLUT_NiceGreen; - } - else if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) <= 1.5) - { - color = CLUT_WarningYellow; - } - else if(stateUsed->lifeData.depth_meter - exitDepthMeter < -1.5 ) - { - color = CLUT_WarningRed; - } - else - { - color = 0; - } - - if((fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) <= 1.6 ) /* only decrease counter if diver is close to target depth */ - || (color == CLUT_WarningRed)) /* or if diver is far ahead */ - { - countDownSec--; - if(countDownSec == 0) - { - slowExitState = SE_END; - color = 0; - exitDepthMeter = 0; - } - else - { - exitDepthMeter -= (pSettings->last_stop_depth_meter / (float)(pSettings->slowExitTime * 60)); - } - } - } - if(!pSettings->FlipDisplay) - { - start.y = t7l1.WindowY0 - 1; - } - else - { - start.y = t7l3.WindowY0 - 25; - } - - for(index = 0; index < pSettings->last_stop_depth_meter; index++) /* draw meter indicators */ - { - start.y += drawingMeterStep; - stop.y = start.y; - start.x = CUSTOMBOX_LINE_LEFT - 1; - stop.x = start.x - 38; - GFX_draw_line(&t7screen, start, stop, 0); - } - - start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 20; - stop.x = start.x; - if(!pSettings->FlipDisplay) - { - start.y = t7l1.WindowY0 + ASCENT_GRAPH_YPIXEL + 5; - } - else - { - start.y = t7l3.WindowY0 - 25 + ASCENT_GRAPH_YPIXEL + 5; - } - stop.y = start.y - countDownSec * (ASCENT_GRAPH_YPIXEL / (float)(pSettings->slowExitTime * 60.0)); - if(stop.y >= 470) - stop.y = 470; - - if(!pSettings->FlipDisplay) - { - stop.y += 5; - } - GFX_draw_thick_line(15,&t7screen, start, stop, 3); - /* mark diver depth */ - start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 30; - stop.x = start.x + 24; - - start.y = start.y - (stateUsed->lifeData.depth_meter * (ASCENT_GRAPH_YPIXEL) / pSettings->last_stop_depth_meter); - stop.y = start.y; - GFX_draw_thick_line(10,&t7screen, start, stop, 9); - } + start.y += drawingMeterStep; + stop.y = start.y; + start.x = CUSTOMBOX_LINE_LEFT - 1; + stop.x = start.x - 38; + GFX_draw_line(&t7screen, start, stop, 0); + } + + start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 20; + stop.x = start.x; + if(!pSettings->FlipDisplay) + { + start.y = t7l1.WindowY0 + ASCENT_GRAPH_YPIXEL + 5; } + else + { + start.y = t7l3.WindowY0 - 25 + ASCENT_GRAPH_YPIXEL + 5; + } + stop.y = start.y - countDownSec * (ASCENT_GRAPH_YPIXEL / (float)(pSettings->slowExitTime * 60.0)); + if(stop.y >= 470) stop.y = 470; + if(!pSettings->FlipDisplay) + { + stop.y += 5; + } + GFX_draw_thick_line(15,&t7screen, start, stop, 3); + /* mark diver depth */ + start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 30; + stop.x = start.x + 24; + + start.y = start.y - (stateUsed->lifeData.depth_meter * (ASCENT_GRAPH_YPIXEL) / pSettings->last_stop_depth_meter); + stop.y = start.y; + GFX_draw_thick_line(10,&t7screen, start, stop, 9); } return color; }