Mercurial > public > ostc4
diff Discovery/Src/tMenuEditSetpoint.c @ 775:46c6d2380d4e
Add a shortcuts to change the setpoint to the loop to the 'normal' display when diving. It is only shown when diving in CCR mode and on the loop.
Uses the configured setpoint with the highest / lowest switch depth as the high / low setpoints respectively. (mikeller)
author | heinrichsweikamp |
---|---|
date | Thu, 11 May 2023 12:13:03 +0200 |
parents | 2c243233c999 |
children | 4abfb8a2a435 |
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditSetpoint.c Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Src/tMenuEditSetpoint.c Thu May 11 12:13:03 2023 +0200 @@ -27,8 +27,6 @@ ////////////////////////////////////////////////////////////////////////////// /* Includes ------------------------------------------------------------------*/ -#include <stdbool.h> - #include "tMenuEditSetpoint.h" #include "check_warning.h" @@ -47,6 +45,8 @@ /* Private variables ---------------------------------------------------------*/ static SEditSetpointPage editSetpointPage; +static uint8_t switchToSetpointCbar; + /* Private function prototypes -----------------------------------------------*/ /* Announced function prototypes -----------------------------------------------*/ @@ -372,6 +372,40 @@ } +bool findSwitchToSetpoint(void) +{ + uint8_t setpointLowId = getSetpointLowId(); + uint8_t setpointHighId = getSetpointHighId(); + uint8_t setpointCurrentCbar = stateUsed->lifeData.actualGas.setPoint_cbar; + if (setpointLowId && setpointCurrentCbar != stateUsed->diveSettings.setpoint[setpointLowId].setpoint_cbar && ((!setpointHighId || setpointCurrentCbar == stateUsed->diveSettings.setpoint[setpointHighId].setpoint_cbar) || stateUsed->lifeData.depth_meter < stateUsed->diveSettings.setpoint[setpointLowId].depth_meter)) { + switchToSetpointCbar = stateUsed->diveSettings.setpoint[setpointLowId].setpoint_cbar; + } else if (setpointHighId && setpointCurrentCbar != stateUsed->diveSettings.setpoint[setpointHighId].setpoint_cbar) { + switchToSetpointCbar = stateUsed->diveSettings.setpoint[setpointHighId].setpoint_cbar; + } else { + // We don't have a setpoint to switch to + switchToSetpointCbar = 0; + + return false; + } + + return true; +} + + +uint8_t getSwitchToSetpointCbar(void) +{ + return switchToSetpointCbar; +} + + +void checkSwitchSetpoint(void) +{ + if (switchToSetpointCbar) { + setActualGas_DM(&stateUsedWrite->lifeData, stateUsed->lifeData.lastDiluent_GasIdInSettings, switchToSetpointCbar); + } +} + + static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1)