changeset 650:5f0d3dce5ef4

Automatik setpoint change: In previous versions a better set point was suggested by the OSTC but had to be confirmed using the quick menu functionality. To improve usability an option has been added to the setpoint menu which allows the selection of automatically setpoint changes. If activated the OSTC will automatically switch to the setpoint in case the matching depth is passed.
author Ideenmodellierer
date Mon, 19 Apr 2021 20:19:32 +0200
parents 60162a939c06
children 7b5a063f080f
files Common/Inc/settings.h Discovery/Inc/text_multilanguage.h Discovery/Src/settings.c Discovery/Src/tMenu.c Discovery/Src/tMenuEditSetpoint.c Discovery/Src/tMenuSetpoint.c Discovery/Src/text_multilanguage.c
diffstat 7 files changed, 110 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/settings.h	Mon Apr 19 20:16:24 2021 +0200
+++ b/Common/Inc/settings.h	Mon Apr 19 20:19:32 2021 +0200
@@ -71,6 +71,8 @@
 #define MAX_COMPASS_COMP 		(2u)
 #define MAX_VIEWPORT_MODE 		(0x7F)
 
+#define MAX_SCRUBBER_TIME 		(500u)
+
 typedef enum
 {
 	O2_SENSOR_SOURCE_OPTIC = 0,
@@ -245,8 +247,11 @@
 	/* new in 0xFFFF001E */
 	uint8_t ppo2sensors_source;
 	float   ppo2sensors_calibCoeff[3];
-	/* new in something */
 	uint8_t amPMTime;
+	/* new in 0xFFFF001F */
+	uint8_t autoSetpoint;
+	uint16_t scrubTimerMax;
+	uint16_t scrubTimerCur;
 } SSettings;
 
 typedef struct
--- a/Discovery/Inc/text_multilanguage.h	Mon Apr 19 20:16:24 2021 +0200
+++ b/Discovery/Inc/text_multilanguage.h	Mon Apr 19 20:19:32 2021 +0200
@@ -200,6 +200,7 @@
 		TXT2BYTE_CompassCalib,
 		TXT2BYTE_CompassInertia,
 		TXT2BYTE_UseSensor,
+		TXT2BYTE_AutomaticSP,
 		/* */
 		TXT2BYTE_WarnDecoMissed,
 		TXT2BYTE_WarnPPO2Low,
--- a/Discovery/Src/settings.c	Mon Apr 19 20:16:24 2021 +0200
+++ b/Discovery/Src/settings.c	Mon Apr 19 20:19:32 2021 +0200
@@ -85,7 +85,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF001E,
+    .header = 0xFFFF001F,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = 0,
@@ -323,6 +323,9 @@
 	.ppo2sensors_calibCoeff[1] = 0.0,
 	.ppo2sensors_calibCoeff[2] = 0.0,
 	.amPMTime = 0,
+	.autoSetpoint = 0,
+	.scrubTimerMax = 0,
+	.scrubTimerCur = 0,
 };
 
 /* Private function prototypes -----------------------------------------------*/
@@ -1439,6 +1442,20 @@
     	Settings.amPMTime = 0;
     	corrections++;
     }
+
+    if(Settings.autoSetpoint > 1) /* only boolean values allowed */
+    {
+    	Settings.autoSetpoint = 0;
+    	corrections++;
+    }
+
+    if((Settings.scrubTimerMax > MAX_SCRUBBER_TIME) || (Settings.scrubTimerCur > MAX_SCRUBBER_TIME))
+    {
+    	Settings.scrubTimerMax = 0;
+    	Settings.scrubTimerCur = 0;
+    	corrections++;
+    }
+
     if(corrections > 255)
         return 255;
     else
--- a/Discovery/Src/tMenu.c	Mon Apr 19 20:16:24 2021 +0200
+++ b/Discovery/Src/tMenu.c	Mon Apr 19 20:19:32 2021 +0200
@@ -883,7 +883,7 @@
 
 void selectPage(uint32_t selection)
 {
-    uint8_t page, line;
+    uint8_t page;
     SStateList idList;
 
 	SSettings* pSettings;
--- a/Discovery/Src/tMenuEditSetpoint.c	Mon Apr 19 20:16:24 2021 +0200
+++ b/Discovery/Src/tMenuEditSetpoint.c	Mon Apr 19 20:19:32 2021 +0200
@@ -191,63 +191,80 @@
         uint8_t textPointer;
         uint16_t y_line;
 
-        set_globalState_Menu_Line(line);
-
-        resetMenuEdit(CLUT_MenuPageGasSP);
+        if(line < 6)
+        {
+			set_globalState_Menu_Line(line);
 
-        spId = line;
-        editSetpointPage.spID = spId;
-        SSettings *data = settingsGetPointer();
-        editSetpointPage.pSetpointLine = data->setpoint;
+			resetMenuEdit(CLUT_MenuPageGasSP);
+
+			spId = line;
+			editSetpointPage.spID = spId;
+			SSettings *data = settingsGetPointer();
+			editSetpointPage.pSetpointLine = data->setpoint;
 
-        setpoint_cbar = editSetpointPage.pSetpointLine[spId].setpoint_cbar;
-        depthDeco = editSetpointPage.pSetpointLine[spId].depth_meter;
-        //active = editSetpointPage.pSetpointLine[spId].note.ub.active;
-        first = editSetpointPage.pSetpointLine[spId].note.ub.first;
+			setpoint_cbar = editSetpointPage.pSetpointLine[spId].setpoint_cbar;
+			depthDeco = editSetpointPage.pSetpointLine[spId].depth_meter;
+			//active = editSetpointPage.pSetpointLine[spId].note.ub.active;
+			first = editSetpointPage.pSetpointLine[spId].note.ub.first;
 
-        sp_high = setpoint_cbar / 100;
+			sp_high = setpoint_cbar / 100;
 
-        strcpy(text, "\001" "Setpoint #0 X");
-        text[11] += spId;
-        text[13] = TXT_Setpoint_Edit;
-        write_topline(text);
+			strcpy(text, "\001" "Setpoint #0 X");
+			text[11] += spId;
+			text[13] = TXT_Setpoint_Edit;
+			write_topline(text);
 
 
-        y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP);
+			y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP);
 
-        textPointer = 0;
-        text[textPointer++] = 'S';
-        text[textPointer++] = 'P';
-        text[textPointer++] = '0' + spId;
-        text[textPointer++] = ' ';
-        text[textPointer++] = ' ';
+			textPointer = 0;
+			text[textPointer++] = 'S';
+			text[textPointer++] = 'P';
+			text[textPointer++] = '0' + spId;
+			text[textPointer++] = ' ';
+			text[textPointer++] = ' ';
 
-        if(first == 0)
-            strcpy(&text[textPointer++],"\177");
+			if(first == 0)
+				strcpy(&text[textPointer++],"\177");
 
-        textPointer += snprintf(&text[textPointer], 60,\
-            "* "
-            "       "
-            "\016\016"
-            " bar"
-            "\017"
-            "\034"
-            "   "
-            "\016\016"
-            " "
-            "\017"
-            "           "
-            "\016\016"
-            "meter"
-            "\017"
-            "\035"
-            "\n\r"
-        );
-        write_label_var(  20, 800, y_line, &FontT48, text);
+			textPointer += snprintf(&text[textPointer], 60,\
+				"* "
+				"       "
+				"\016\016"
+				" bar"
+				"\017"
+				"\034"
+				"   "
+				"\016\016"
+				" "
+				"\017"
+				"           "
+				"\016\016"
+				"meter"
+				"\017"
+				"\035"
+				"\n\r"
+			);
+			write_label_var(  20, 800, y_line, &FontT48, text);
 
-        write_field_udigit(StMSP_ppo2_setting,	160, 800, y_line, &FontT48, "#.##            ###", (uint32_t)sp_high, (uint32_t)(setpoint_cbar - (100 * sp_high)), depthDeco, 0);
-        setEvent(StMSP_ppo2_setting,	(uint32_t)OnAction_SP_Setpoint);
-        startEdit();
+			write_field_udigit(StMSP_ppo2_setting,	160, 800, y_line, &FontT48, "#.##            ###", (uint32_t)sp_high, (uint32_t)(setpoint_cbar - (100 * sp_high)), depthDeco, 0);
+			setEvent(StMSP_ppo2_setting,	(uint32_t)OnAction_SP_Setpoint);
+			startEdit();
+		}
+        else
+        {
+            SSettings *pSettings = settingsGetPointer();
+
+            if(pSettings->autoSetpoint == 0)
+            {
+                pSettings->autoSetpoint = 1;
+            }
+            else
+            {
+                pSettings->autoSetpoint = 0;
+            }
+            exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only();
+        }
     }
 }
 
--- a/Discovery/Src/tMenuSetpoint.c	Mon Apr 19 20:16:24 2021 +0200
+++ b/Discovery/Src/tMenuSetpoint.c	Mon Apr 19 20:19:32 2021 +0200
@@ -133,5 +133,17 @@
         text[textPointer++] = '\r';
         text[textPointer++] = 0;
     }
+    else
+    {
+        text[textPointer++] = '\020';
+        text[textPointer++] = TXT_2BYTE;
+        text[textPointer++] = TXT2BYTE_AutomaticSP;
+        text[textPointer++] = '\002';
+        if(settingsGetPointer()->autoSetpoint)
+                    text[textPointer++] = '\005';
+                else
+                    text[textPointer++] = '\006';
+        text[textPointer++] = 0;
+    }
     return StMSP;
 }
--- a/Discovery/Src/text_multilanguage.c	Mon Apr 19 20:16:24 2021 +0200
+++ b/Discovery/Src/text_multilanguage.c	Mon Apr 19 20:19:32 2021 +0200
@@ -910,6 +910,13 @@
 static uint8_t text_IT_UseSensor[] = "Sensore";
 static uint8_t text_ES_UseSensor[] = "Usar sensor";
 
+// Dive Menu (CCR mode)
+static uint8_t text_EN_AutomaticSP[] = "Switch SP automatically";
+static uint8_t text_DE_AutomaticSP[] = "Automatischer SP Wechsel";
+static uint8_t text_FR_AutomaticSP[] = "";
+static uint8_t text_IT_AutomaticSP[] = "";
+static uint8_t text_ES_AutomaticSP[] = "";
+
 // Warning
 static uint8_t text_EN_WarnDecoMissed[] = "Deco stop";
 static uint8_t text_DE_WarnDecoMissed[] = "Deco Stopp";
@@ -1804,6 +1811,7 @@
     {(uint8_t)TXT2BYTE_CompassCalib, 	{text_EN_CompassCalib, text_DE_CompassCalib, text_FR_CompassCalib, text_IT_CompassCalib, text_ES_CompassCalib}},
 	{(uint8_t)TXT2BYTE_CompassInertia,	{text_EN_CompassInertia, text_DE_CompassInertia, text_FR_CompassInertia, text_IT_CompassInertia, text_ES_CompassInertia}},
 	{(uint8_t)TXT2BYTE_UseSensor,		{text_EN_UseSensor, text_DE_UseSensor, text_FR_UseSensor, text_IT_UseSensor, text_ES_UseSensor}},
+	{(uint8_t)TXT2BYTE_AutomaticSP,		{text_EN_AutomaticSP, text_DE_AutomaticSP, text_FR_AutomaticSP, text_IT_AutomaticSP, text_ES_AutomaticSP}},
     {(uint8_t)TXT2BYTE_WarnDecoMissed,  {text_EN_WarnDecoMissed, text_DE_WarnDecoMissed, text_FR_WarnDecoMissed, text_IT_WarnDecoMissed, text_ES_WarnDecoMissed}},
     {(uint8_t)TXT2BYTE_WarnPPO2Low,		{text_EN_WarnPPO2Low, text_DE_WarnPPO2Low, text_FR_WarnPPO2Low, text_IT_WarnPPO2Low, text_ES_WarnPPO2Low}},
     {(uint8_t)TXT2BYTE_WarnPPO2High,	{text_EN_WarnPPO2High, text_DE_WarnPPO2High, text_FR_WarnPPO2High, text_IT_WarnPPO2High, text_ES_WarnPPO2High}},