diff Discovery/Src/tCCR.c @ 272:74a8296a2318 write-from-sim

cleanup: simplify stateUsed usage Get rid of some local stateUsed pointers used to differentiate between normal dive and simulator mode. Simply use the (properly set) global data for this. Its rather useless to do this test on countless locations. Trivial cleanup. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Sat, 27 Apr 2019 12:27:46 +0200
parents 5f11787b4f42
children 31e471d60797
line wrap: on
line diff
--- a/Discovery/Src/tCCR.c	Sat Apr 27 09:32:16 2019 +0200
+++ b/Discovery/Src/tCCR.c	Sat Apr 27 12:27:46 2019 +0200
@@ -59,7 +59,7 @@
 /* Private variables with external access via get_xxx() function -------------*/
 
 /* Private function prototypes -----------------------------------------------*/
-void tCCR_fallbackToFixedSetpoint(void);
+static void tCCR_fallbackToFixedSetpoint(void);
 
 #ifndef USART_IR_HUD
 
@@ -343,23 +343,17 @@
 #endif
 /* Private functions ---------------------------------------------------------*/
 
-void tCCR_fallbackToFixedSetpoint(void)
+static void tCCR_fallbackToFixedSetpoint(void)
 {
     if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption))
     {
         uint8_t setpointCbar, actualGasID;
-        SDiveState *pState;
 
-        if(stateUsed == stateRealGetPointer())
-            pState = stateRealGetPointerWrite();
-        else
-            pState = stateSimGetPointerWrite();
+        setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar;
+        stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
 
-        setpointCbar = pState->diveSettings.setpoint[1].setpoint_cbar;
-        pState->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
-
-        actualGasID = pState->lifeData.actualGas.GasIdInSettings;
-        setActualGas_DM(&pState->lifeData,actualGasID,setpointCbar);
+        actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings;
+        setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar);
 
         set_warning_fallback();
     }