Mercurial > public > ostc4
diff Discovery/Src/settings.c @ 788:4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
author | heinrichsweikamp |
---|---|
date | Tue, 04 Jul 2023 14:39:06 +0200 |
parents | 45b8f3c2acce |
children | 25103f5c7e29 |
line wrap: on
line diff
--- a/Discovery/Src/settings.c Sun Jun 04 21:59:26 2023 +0200 +++ b/Discovery/Src/settings.c Tue Jul 04 14:39:06 2023 +0200 @@ -27,7 +27,6 @@ ////////////////////////////////////////////////////////////////////////////// #include <string.h> -#include <stdbool.h> #include "settings.h" #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS @@ -334,6 +333,7 @@ .ext_sensor_map[4] = SENSOR_NONE, .buttonLockActive = 0, .compassDeclinationDeg = 0, + .delaySetpointLow = false, }; /* Private function prototypes -----------------------------------------------*/ @@ -537,6 +537,7 @@ // no break; case 0xFFFF0025: pSettings->compassDeclinationDeg = pStandard->compassDeclinationDeg; + pSettings->delaySetpointLow = pStandard->delaySetpointLow; // no break; default: @@ -592,6 +593,52 @@ } +bool checkAndFixSetpointSettings(void) +{ + SSettings *settings = settingsGetPointer(); + + bool fixed = false; + if (settings->autoSetpoint) { + SSetpointLine *setpointLow = &settings->setpoint[SETPOINT_INDEX_AUTO_LOW]; + if (setpointLow->setpoint_cbar >= 100) { + setpointLow->setpoint_cbar = 70; + + fixed = true; + } + if (setpointLow->depth_meter == 0 || setpointLow->depth_meter > 100) { + setpointLow->depth_meter = 2; + + fixed = true; + } + SSetpointLine *setpointHigh = &settings->setpoint[SETPOINT_INDEX_AUTO_HIGH]; + if (setpointHigh->setpoint_cbar <= setpointLow->setpoint_cbar) { + setpointHigh->setpoint_cbar = 130; + + fixed = true; + } + if (setpointHigh->depth_meter <= setpointLow->depth_meter) { + setpointHigh->depth_meter = setpointLow->depth_meter + 6; + + fixed = true; + } + + SSetpointLine *setpointDeco = &settings->setpoint[SETPOINT_INDEX_AUTO_DECO]; + if (setpointDeco->note.ub.active) { + if (setpointDeco->setpoint_cbar == setpointHigh->setpoint_cbar || setpointDeco->setpoint_cbar == setpointLow->setpoint_cbar) { + setpointDeco->setpoint_cbar = 10 * (setpointHigh->setpoint_cbar / 10) - 10; + if (setpointDeco->setpoint_cbar == setpointLow->setpoint_cbar) { + setpointDeco->setpoint_cbar += 5; + } + + fixed = true; + } + } + } + + return fixed; +} + + uint8_t check_and_correct_settings(void) { uint32_t corrections = 0; @@ -766,52 +813,12 @@ Settings.setpoint[i].depth_meter = 250; corrections++; } - if(Settings.setpoint[i].note.ub.deco) - { - if(Settings.setpoint[i].note.ub.active != 1) - { - Settings.setpoint[i].note.ub.active = 1; - corrections++; - } - if(Settings.setpoint[i].note.ub.travel == 1) - { - Settings.setpoint[i].note.ub.travel = 0; - corrections++; - } - } - if(Settings.setpoint[i].note.ub.travel) - { - if(Settings.setpoint[i].note.ub.active != 1) - { - Settings.setpoint[i].note.ub.active = 1; - corrections++; - } - if(Settings.setpoint[i].note.ub.deco == 1) - { - Settings.setpoint[i].note.ub.deco = 0; - corrections++; - } - } - if(Settings.setpoint[i].note.ub.first) - { - if(Settings.setpoint[i].note.ub.active != 1) - { - Settings.setpoint[i].note.ub.active = 1; - corrections++; - } - if(Settings.setpoint[i].note.ub.travel == 1) - { - Settings.setpoint[i].note.ub.travel = 0; - corrections++; - } - if(Settings.setpoint[i].note.ub.deco == 1) - { - Settings.setpoint[i].note.ub.deco = 0; - corrections++; - } - } } // for(int i=1; i<=NUM_GASES;i++) + if (checkAndFixSetpointSettings()) { + corrections++; + } + /* uint8_t CCR_Mode; */ if( (Settings.CCR_Mode != CCRMODE_Sensors) && @@ -3070,4 +3077,3 @@ { return settingsWarning; } -