# HG changeset patch # User heinrichsweikamp # Date 1683799983 -7200 # Node ID 46c6d2380d4ed2f47eb5d74a0758cf21605f39e7 # Parent 6169309d6eb9331e9fe15080407a04ff29254f2a 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) diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Inc/check_warning.h --- a/Discovery/Inc/check_warning.h Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Inc/check_warning.h Thu May 11 12:13:03 2023 +0200 @@ -42,5 +42,6 @@ uint8_t debounce_warning_fallback(uint16_t debounceStepms); void reset_debounce_warning_fallback(); - +uint8_t getSetpointHighId(void); +uint8_t getSetpointLowId(void); #endif // CHECK_WARNING_H diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Inc/tMenuEditSetpoint.h --- a/Discovery/Inc/tMenuEditSetpoint.h Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Inc/tMenuEditSetpoint.h Thu May 11 12:13:03 2023 +0200 @@ -30,9 +30,13 @@ /* Includes ------------------------------------------------------------------*/ #include +#include void openEdit_Setpoint(uint8_t line); void openEdit_DiveSelectBetterSetpoint(bool useLastDiluent); void checkSwitchToLoop(void); +bool findSwitchToSetpoint(void); +uint8_t getSwitchToSetpointCbar(void); +void checkSwitchSetpoint(void); #endif /* TMENU_EDIT_SETPOINT_H */ diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Inc/tStructure.h --- a/Discovery/Inc/tStructure.h Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Inc/tStructure.h Thu May 11 12:13:03 2023 +0200 @@ -104,6 +104,7 @@ #define StDSIM5 _MB(1,2,13,0,0) #define StDSIM6 _MB(1,2,14,0,0) #define StDBAILOUT _MB(1,2,15,0,0) +#define StDSETPOINT _MB(1,2,16,0,0) #define StUART_STANDARD _MB(3,1,0,0,0) #define StUART_RTECONNECT _MB(3,2,0,0,0) diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Inc/text_multilanguage.h --- a/Discovery/Inc/text_multilanguage.h Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Inc/text_multilanguage.h Thu May 11 12:13:03 2023 +0200 @@ -355,6 +355,7 @@ TXT2BYTE_Scrubber, TXT2BYTE_BailoutShort, TXT2BYTE_LoopShort, + TXT2BYTE_SetpointShort, TXT2BYTE_Set, TXT2BYTE_Clear, diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Src/t7.c --- a/Discovery/Src/t7.c Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Src/t7.c Thu May 11 12:13:03 2023 +0200 @@ -46,6 +46,7 @@ #include "motion.h" #include "configuration.h" #include "base.h" +#include "tMenuEditSetpoint.h" /* Private function prototypes -----------------------------------------------*/ @@ -2794,6 +2795,10 @@ } GFX_write_string_color(&FontT48, &t7c2, TextR1, 0, CLUT_WarningYellow); + } else if (get_globalState() == StDSETPOINT) { + snprintf(TextR1, TEXTSIZE, "\a\001 %c%c %01.2f? ", TXT_2BYTE, TXT2BYTE_SetpointShort, getSwitchToSetpointCbar() / 100.0); + + GFX_write_string_color(&FontT48, &t7c2, TextR1, 0, CLUT_WarningYellow); } else if(get_globalState() == StDSIM1) { diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Src/tHome.c --- a/Discovery/Src/tHome.c Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Src/tHome.c Thu May 11 12:13:03 2023 +0200 @@ -281,6 +281,16 @@ break; case StDBAILOUT: + if (settingsGetPointer()->dive_mode == DIVEMODE_CCR && isLoopMode(stateUsed->diveSettings.diveMode) && findSwitchToSetpoint()) { + set_globalState(StDSETPOINT); + + break; + } + + checkSetStateSim(settings); + + break; + case StDSETPOINT: checkSetStateSim(settings); break; @@ -484,6 +494,12 @@ set_globalState(StD); break; + case StDSETPOINT: + checkSwitchSetpoint(); + + set_globalState(StD); + + break; case StDBEAR: // t5_gauge setCompassHeading((uint16_t)stateUsed->lifeData.compass_heading); set_globalState(StD); diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Src/tMenuEditSetpoint.c --- 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 - #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) diff -r 6169309d6eb9 -r 46c6d2380d4e Discovery/Src/text_multilanguage.c --- a/Discovery/Src/text_multilanguage.c Wed May 10 16:25:39 2023 +0200 +++ b/Discovery/Src/text_multilanguage.c Thu May 11 12:13:03 2023 +0200 @@ -1835,6 +1835,12 @@ static uint8_t text_IT_LoopShort[] = "CC"; static uint8_t text_ES_LoopShort[] = "CC"; +static uint8_t text_EN_SetpointShort[] = "SP"; +static uint8_t text_DE_SetpointShort[] = "SP"; +static uint8_t text_FR_SetpointShort[] = "SP"; +static uint8_t text_IT_SetpointShort[] = "SP"; +static uint8_t text_ES_SetpointShort[] = "SP"; + /* Lookup Table -------------------------------------------------------------*/ const tText text_array[] = @@ -2103,10 +2109,11 @@ {(uint8_t)TXT2BYTE_CcrSummary, {text_EN_CcrSummary, text_DE_CcrSummary, text_FR_CcrSummary, text_IT_CcrSummary, text_ES_CcrSummary}}, {(uint8_t)TXT2BYTE_Setpoint, {text_EN_Setpoint, text_DE_Setpoint, text_FR_Setpoint, text_IT_Setpoint, text_ES_Setpoint}}, {(uint8_t)TXT2BYTE_Scrubber, {text_EN_Scrubber, text_DE_Scrubber, text_FR_Scrubber, text_IT_Scrubber, text_ES_Scrubber}}, + {(uint8_t)TXT2BYTE_BailoutShort, {text_EN_BailoutShort, text_DE_BailoutShort, text_FR_BailoutShort, text_IT_BailoutShort, text_ES_BailoutShort}}, + {(uint8_t)TXT2BYTE_LoopShort, {text_EN_LoopShort, text_DE_LoopShort, text_FR_LoopShort, text_IT_LoopShort, text_ES_LoopShort}}, + {(uint8_t)TXT2BYTE_SetpointShort, {text_EN_SetpointShort, text_DE_SetpointShort, text_FR_SetpointShort, text_IT_SetpointShort, text_ES_SetpointShort}}, {(uint8_t)TXT2BYTE_Set, {text_EN_Set, text_DE_Set, text_FR_Set, text_IT_Set, text_ES_Set}}, {(uint8_t)TXT2BYTE_Clear, {text_EN_Clear, text_DE_Clear, text_FR_Clear, text_IT_Clear, text_ES_Clear}}, {(uint8_t)TXT2BYTE_Reset, {text_EN_Reset, text_DE_Reset, text_FR_Reset, text_IT_Reset, text_ES_Reset}}, - {(uint8_t)TXT2BYTE_BailoutShort, {text_EN_BailoutShort, text_DE_BailoutShort, text_FR_BailoutShort, text_IT_BailoutShort, text_ES_BailoutShort}}, - {(uint8_t)TXT2BYTE_LoopShort, {text_EN_LoopShort, text_DE_LoopShort, text_FR_LoopShort, text_IT_LoopShort, text_ES_LoopShort}}, };