diff Discovery/Src/settings.c @ 662:1b995079c045 Betatest

PSCR Mode
author heinrichs weikamp
date Tue, 14 Dec 2021 15:36:10 +0100
parents 9513a92b293b
children 12d029f38430
line wrap: on
line diff
--- a/Discovery/Src/settings.c	Mon Nov 01 12:39:34 2021 +0100
+++ b/Discovery/Src/settings.c	Tue Dec 14 15:36:10 2021 +0100
@@ -36,6 +36,8 @@
 #include "t7.h"
 #include "data_central.h"
 
+static uint8_t settingsWarning = 0;		/* Active if setting values have been corrected */
+
 SSettings Settings;
 
 const uint8_t RTErequiredHigh = 2;
@@ -85,10 +87,10 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF001F,
+    .header = 0xFFFF0021,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
-    .logFlashNextSampleStartAddress = 0,
+    .logFlashNextSampleStartAddress = SAMPLESTART,
 
     .gas[0].oxygen_percentage = 21,
     .gas[1].oxygen_percentage = 21,
@@ -219,7 +221,7 @@
     .ppO2_min = 15,
     .CNS_max = 90,
     .ascent_MeterPerMinute_max = 30,
-    .ascent_MeterPerMinute_showGraph = 7,
+    .ascent_MeterPerMinute_showGraph = 30,
     .future_TTS = 5,
     .GF_high = 85,
     .GF_low = 30,
@@ -268,13 +270,9 @@
     .bluetoothActive = 0,
     .safetystopDepth = 5,
     .updateSettingsAllowedFromHeader = 0xFFFF0002,
-    .scooterControl = 0,
-    .scooterDrag = 2,
-    .scooterLoad = 2,
-    .scooterNumberOfBatteries = 1,
-    .scooterBattSize = 760,
-    .scooterSPARE1[0] = 0,
-    .scooterSPARE2[0] = 0,
+	.pscr_lung_ratio = 10,
+	.pscr_o2_drop = 4,
+	.co2_sensor_active = 0,
     .ppo2sensors_deactivated = 0,
     .tX_colorscheme  = 0,
     .tX_userselectedLeftLowerCornerPrimary = LLC_Temperature,
@@ -371,8 +369,6 @@
     SSettings* pSettings = settingsGetPointer();
     const SSettings* pStandard = settingsGetPointerStandard();
 
-    pSettings->scooterControl = 0;
-
     /* Pointing to the old header data => set new data depending on what had been added since last version */
     switch(pSettings->header)
     {
@@ -433,15 +429,7 @@
     case 0xFFFF000F:
         pSettings->compassBearing                   = 0;
         // no break
-    case 0xFFFF0010:
-        pSettings->scooterDrag                      = 2;
-        pSettings->scooterLoad                      = 2;
-        pSettings->scooterSPARE1[0]                 = 0;
-        pSettings->scooterSPARE2[0]                 = 0;
-        // no break
     case 0xFFFF0011:
-        pSettings->scooterNumberOfBatteries         = 1;
-        pSettings->scooterBattSize                  = 760;
         pSettings->lastKnownBatteryPercentage       = 0;
         // no break
     case 0xFFFF0012:
@@ -496,7 +484,21 @@
     	pSettings->ppo2sensors_calibCoeff[0] = 0.0;
     	pSettings->ppo2sensors_calibCoeff[1] = 0.0;
     	pSettings->ppo2sensors_calibCoeff[2] = 0.0;
+    	pSettings->amPMTime = 0;
     	// no break
+    case 0xFFFF001E:
+    	pSettings->autoSetpoint = 0;
+    	pSettings->scrubTimerMax = 0;
+    	pSettings->scrubTimerCur = 0;
+    	pSettings->scrubTimerMode = SCRUB_TIMER_OFF;
+    	// no break
+    case 0xFFFF001F:
+    	pSettings->pscr_lung_ratio = 10;
+    	pSettings->pscr_o2_drop = 4;
+    	// no break
+    case 0xFFFF0020:
+    	pSettings->co2_sensor_active = 0;
+    	// no break;
     default:
         pSettings->header = pStandard->header;
         break; // no break before!!
@@ -536,6 +538,9 @@
     uint8_t firstGasFoundOC = 0;
     uint8_t firstGasFoundCCR = 0;
 
+
+    settingsWarning = 0; /* reset warning indicator */
+
 /*	uint32_t header;
  */
 
@@ -564,7 +569,8 @@
     if(	(Settings.dive_mode != DIVEMODE_OC) 		&&
             (Settings.dive_mode != DIVEMODE_CCR)  	&&
             (Settings.dive_mode != DIVEMODE_Gauge)	&&
-            (Settings.dive_mode != DIVEMODE_Apnea)		)
+            (Settings.dive_mode != DIVEMODE_Apnea)	&&
+			(Settings.dive_mode != DIVEMODE_PSCR))
     {
         Settings.dive_mode = DIVEMODE_OC;
         corrections++;
@@ -618,9 +624,9 @@
         }
         if(Settings.gas[i].note.ub.first)
         {
-            if(Settings.setpoint[i].note.ub.active != 1)
+            if(Settings.gas[i].note.ub.active != 1)
             {
-                Settings.setpoint[i].note.ub.active = 1;
+                Settings.gas[i].note.ub.active = 1;
                 corrections++;
             }
             if(Settings.gas[i].note.ub.travel == 1)
@@ -671,6 +677,7 @@
         Settings.gas[1].note.ub.first = 1;
         Settings.gas[1].note.ub.travel = 0;
         Settings.gas[1].note.ub.deco = 0;
+        corrections++;
     }
     if(!firstGasFoundCCR)
     {
@@ -678,6 +685,7 @@
         Settings.gas[1 + NUM_GASES].note.ub.first = 1;
         Settings.gas[1 + NUM_GASES].note.ub.travel = 0;
         Settings.gas[1 + NUM_GASES].note.ub.deco = 0;
+        corrections++;
     }
 /*	SSetpointLine setpoint[1 + NUM_GASES];
  */
@@ -747,6 +755,7 @@
 /*	uint8_t CCR_Mode;
  */
     if(	(Settings.CCR_Mode != CCRMODE_Sensors) &&
+    		(Settings.CCR_Mode != CCRMODE_Simulation) &&
             (Settings.CCR_Mode != CCRMODE_FixedSetpoint))
     {
         Settings.CCR_Mode = CCRMODE_FixedSetpoint;
@@ -1461,10 +1470,36 @@
     	Settings.scrubTimerMode = SCRUB_TIMER_OFF;
     	corrections++;
     }
+
+    if((Settings.pscr_lung_ratio > PSCR_MAX_LUNG_RATIO) || (Settings.pscr_lung_ratio < PSCR_MIN_LUNG_RATIO))
+    {
+    	Settings.pscr_lung_ratio = 10;
+    	corrections++;
+    }
+    if(Settings.pscr_o2_drop > PSCR_MAX_O2_DROP)
+    {
+    	Settings.pscr_o2_drop = 4;
+    	corrections++;
+    }
+
+    if(Settings.co2_sensor_active > 1)
+    {
+    	Settings.co2_sensor_active = 0;
+    	corrections++;
+    }
+
+    if(corrections)
+    {
+    	settingsWarning = 1;
+    }
+    else
+
     if(corrections > 255)
-        return 255;
-    else
-        return (uint8_t)corrections;
+    {
+    	corrections = 255;
+    }
+
+    return (uint8_t)corrections;
 }
 
 
@@ -2921,3 +2956,13 @@
         }
     }
 }
+
+void reset_SettingWarning()
+{
+	settingsWarning = 0;
+}
+inline uint8_t isSettingsWarning()
+{
+	return settingsWarning;
+}
+