comparison 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
comparison
equal deleted inserted replaced
271:1303747b5ba2 272:74a8296a2318
57 uint16_t count = 0; 57 uint16_t count = 0;
58 58
59 /* Private variables with external access via get_xxx() function -------------*/ 59 /* Private variables with external access via get_xxx() function -------------*/
60 60
61 /* Private function prototypes -----------------------------------------------*/ 61 /* Private function prototypes -----------------------------------------------*/
62 void tCCR_fallbackToFixedSetpoint(void); 62 static void tCCR_fallbackToFixedSetpoint(void);
63 63
64 #ifndef USART_IR_HUD 64 #ifndef USART_IR_HUD
65 65
66 void tCCR_init(void) 66 void tCCR_init(void)
67 { 67 {
341 } 341 }
342 342
343 #endif 343 #endif
344 /* Private functions ---------------------------------------------------------*/ 344 /* Private functions ---------------------------------------------------------*/
345 345
346 void tCCR_fallbackToFixedSetpoint(void) 346 static void tCCR_fallbackToFixedSetpoint(void)
347 { 347 {
348 if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption)) 348 if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption))
349 { 349 {
350 uint8_t setpointCbar, actualGasID; 350 uint8_t setpointCbar, actualGasID;
351 SDiveState *pState; 351
352 352 setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar;
353 if(stateUsed == stateRealGetPointer()) 353 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
354 pState = stateRealGetPointerWrite(); 354
355 else 355 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings;
356 pState = stateSimGetPointerWrite(); 356 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar);
357
358 setpointCbar = pState->diveSettings.setpoint[1].setpoint_cbar;
359 pState->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
360
361 actualGasID = pState->lifeData.actualGas.GasIdInSettings;
362 setActualGas_DM(&pState->lifeData,actualGasID,setpointCbar);
363 357
364 set_warning_fallback(); 358 set_warning_fallback();
365 } 359 }
366 } 360 }