diff Discovery/Src/vpm.c @ 907:46a21ff3f5ab Evo_2_23

Adaptation custom view deco plan for VPM: The VPM deco plan now shows the start of deco zone as well as the state of the deco table state. In case the table defined when reaching the deco zone is updated then the header line will change to yellow to indicate this. In case a deco stop is missed the head line will change to red.
author ideenmodellierer
date Sun, 13 Oct 2024 18:13:35 +0200
parents d4622533271d
children
line wrap: on
line diff
--- a/Discovery/Src/vpm.c	Sun Oct 13 18:07:23 2024 +0200
+++ b/Discovery/Src/vpm.c	Sun Oct 13 18:13:35 2024 +0200
@@ -132,6 +132,7 @@
 
 static const _Bool vpm_b = true;
 
+static SvpmTableState vpmTableState = VPM_TABLE_INIT;
 static SDecoinfo vpmTable;
 
 extern const float float_buehlmann_N2_factor_expositon_20_seconds[];
@@ -193,6 +194,8 @@
 static void  vpm_init_1(void);
 static void vpm_calc_deco_ceiling(void);
 
+uint8_t vpm_get_decozone(void);
+
 static void vpm_init_1(void)
 {
      units_equal_msw = true;
@@ -241,12 +244,18 @@
 			{
 				if(decreaseStopTime)
 				{
-					if((pLifeData->depth_meter > (float)(actual_deco_stop - 0.5))
+					if((pLifeData->depth_meter > (float)(actual_deco_stop - 1.5))
 						&& (pLifeData->depth_meter < (float)actual_deco_stop + 1.5))
 					{
 						pDecoInfo->output_stop_length_seconds[index]--;
 						decreaseStopTime = 0;
 					}
+					else if (pLifeData->depth_meter < (float)(actual_deco_stop - 1.5)) /* missed deco stop */
+					{
+						vpmTableState = VPM_TABLE_MISSED;
+						pDecoInfo->output_stop_length_seconds[index] = 0;
+						decreaseStopTime = 0;
+					}
 				}
 				pDecoInfo->output_time_to_surface_seconds += pDecoInfo->output_stop_length_seconds[index];
 			}
@@ -335,6 +344,13 @@
 			{
 				memcpy(&vpmTable, pDECOINFO, sizeof(SDecoinfo));
 				vpmTableActive = 1;
+				if(pVpm->deco_zone_reached) /* table should not change after deco zone was entered */
+				{
+					if(vpmTableState != VPM_TABLE_MISSED)
+					{
+						vpmTableState = VPM_TABLE_WARNING;
+					}
+				}
 			}
 			else
 			{
@@ -2489,5 +2505,14 @@
 void vpm_table_init()
 {
 	vpmTable.output_time_to_surface_seconds = 0;
+	vpmTableState = VPM_TABLE_INIT;
+}
+uint8_t vpm_get_decozone(void)
+{
+	return((uint8_t)pVpm->depth_start_of_deco_zone_save);
+}
+SvpmTableState vpm_get_TableState(void)
+{
+	return vpmTableState;
 }