Mercurial > public > ostc4
diff Discovery/Src/timer.c @ 519:2c49561c8062
Reset Safety Stop display in case of a new descend:
In previous version safety stop was displayed in while the stop depth was reached. The count down was interrupted in case of a new descend but the safety stop was still displayed, blocking the NDL visualization in the big font view. To avoid this scenario a restart function has been added which will return to NDL view in case of a descend > 2m. If just a short drop happend then the countdown will be continued when the safety stop depth is reached again. If that takes more then a minute the safety stop counter is restarted.
author | Ideenmodellierer |
---|---|
date | Sun, 06 Sep 2020 22:11:51 +0200 |
parents | ddbe8bed5096 |
children | aa6006975e76 |
line wrap: on
line diff
--- a/Discovery/Src/timer.c Sun Sep 06 21:17:59 2020 +0200 +++ b/Discovery/Src/timer.c Sun Sep 06 22:11:51 2020 +0200 @@ -46,6 +46,8 @@ static int last_second = -1; static _Bool bSafetyStop = false; static float last_depth_meter = 0; + static uint8_t safetyStopResetCnt = 0; + static uint16_t safetyStopRestartCnt = 0; long stopWatchTime_Second = 0; if(checkOncePerSecond) @@ -86,15 +88,44 @@ } } + /* Has the diver left safety stop depth (descend)? => need to restart safety stop timer? */ + if(safetyStopCountDown_Second != 0) + { + if(stateUsed->lifeData.depth_meter >= (settingsGetPointer()->safetystopDepth + 2.0)) + { + safetyStopRestartCnt = safetyStopCountDown_Second; + safetyStopCountDown_Second = 0; + safetyStopResetCnt = 60; /* restart safety stop from scratch if depth is left for more than one minute */ + } + } + else if(safetyStopResetCnt) + { + safetyStopResetCnt--; + if(safetyStopResetCnt == 0) + { + safetyStopRestartCnt = 0; + } + } + //Countdown starts at 5 meters if(bSafetyStop && (stateUsed->lifeData.depth_meter - 0.0001f <= (settingsGetPointer()->safetystopDepth) )) { if(safetyStopCountDown_Second == 0) { - safetyStopCountDown_Second = (settingsGetPointer()->safetystopDuration) * 60; + if(safetyStopRestartCnt) /* just a short interrupt of the safetystop => continue using old count */ + { + safetyStopCountDown_Second = safetyStopRestartCnt; + safetyStopRestartCnt = 0; + } + else /* setup safety stop duration */ + { + safetyStopCountDown_Second = (settingsGetPointer()->safetystopDuration) * 60; + } } else + { safetyStopCountDown_Second--; + } } // after safetystopDuration minutes or below 3 (2) meter safetyStop is disabled