comparison 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
comparison
equal deleted inserted replaced
774:6169309d6eb9 775:46c6d2380d4e
25 /// You should have received a copy of the GNU General Public License 25 /// You should have received a copy of the GNU General Public License
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 ////////////////////////////////////////////////////////////////////////////// 27 //////////////////////////////////////////////////////////////////////////////
28 28
29 /* Includes ------------------------------------------------------------------*/ 29 /* Includes ------------------------------------------------------------------*/
30 #include <stdbool.h>
31
32 #include "tMenuEditSetpoint.h" 30 #include "tMenuEditSetpoint.h"
33 31
34 #include "check_warning.h" 32 #include "check_warning.h"
35 #include "gfx_fonts.h" 33 #include "gfx_fonts.h"
36 #include "tMenuEdit.h" 34 #include "tMenuEdit.h"
44 } SEditSetpointPage; 42 } SEditSetpointPage;
45 43
46 44
47 /* Private variables ---------------------------------------------------------*/ 45 /* Private variables ---------------------------------------------------------*/
48 static SEditSetpointPage editSetpointPage; 46 static SEditSetpointPage editSetpointPage;
47
48 static uint8_t switchToSetpointCbar;
49 49
50 /* Private function prototypes -----------------------------------------------*/ 50 /* Private function prototypes -----------------------------------------------*/
51 51
52 /* Announced function prototypes -----------------------------------------------*/ 52 /* Announced function prototypes -----------------------------------------------*/
53 static uint8_t OnAction_SP_Setpoint (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 53 static uint8_t OnAction_SP_Setpoint (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
370 setActualGas_DM(&stateUsedWrite->lifeData, gasId, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar); 370 setActualGas_DM(&stateUsedWrite->lifeData, gasId, stateUsedWrite->diveSettings.setpoint[spId].setpoint_cbar);
371 } 371 }
372 } 372 }
373 373
374 374
375 bool findSwitchToSetpoint(void)
376 {
377 uint8_t setpointLowId = getSetpointLowId();
378 uint8_t setpointHighId = getSetpointHighId();
379 uint8_t setpointCurrentCbar = stateUsed->lifeData.actualGas.setPoint_cbar;
380 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)) {
381 switchToSetpointCbar = stateUsed->diveSettings.setpoint[setpointLowId].setpoint_cbar;
382 } else if (setpointHighId && setpointCurrentCbar != stateUsed->diveSettings.setpoint[setpointHighId].setpoint_cbar) {
383 switchToSetpointCbar = stateUsed->diveSettings.setpoint[setpointHighId].setpoint_cbar;
384 } else {
385 // We don't have a setpoint to switch to
386 switchToSetpointCbar = 0;
387
388 return false;
389 }
390
391 return true;
392 }
393
394
395 uint8_t getSwitchToSetpointCbar(void)
396 {
397 return switchToSetpointCbar;
398 }
399
400
401 void checkSwitchSetpoint(void)
402 {
403 if (switchToSetpointCbar) {
404 setActualGas_DM(&stateUsedWrite->lifeData, stateUsed->lifeData.lastDiluent_GasIdInSettings, switchToSetpointCbar);
405 }
406 }
407
408
375 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 409 static uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
376 { 410 {
377 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1) 411 if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1)
378 { 412 {
379 stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 4+2; 413 stateUsedWrite->diveSettings.ppo2sensors_deactivated &= 4+2;