changeset 770:8deb28b2d4da

CCR overview in surface mode. Makes it easy to quickly check that all settings (mode, setpoints, diluent, scrubber timer) are correct when preparing to dive (also makes the OC gas list available in surface mode for the same reason).
author heinrichsweikamp
date Fri, 21 Apr 2023 09:47:44 +0200
parents 6b248bcdbf28
children 29d9b5bc7946
files Discovery/Inc/tHome.h Discovery/Inc/text_multilanguage.h Discovery/Src/t7.c Discovery/Src/text_multilanguage.c
diffstat 4 files changed, 243 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/tHome.h	Fri Apr 21 09:47:06 2023 +0200
+++ b/Discovery/Inc/tHome.h	Fri Apr 21 09:47:44 2023 +0200
@@ -75,6 +75,7 @@
 		CVIEW_CompassDebug,
 		CVIEW_SummaryOfLeftCorner,
 		CVIEW_Charger,
+		CVIEW_CcrSummary,
 		CVIEW_END,
 		CVIEW_T3_Decostop,
 		CVIEW_T3_TTS,
--- a/Discovery/Inc/text_multilanguage.h	Fri Apr 21 09:47:06 2023 +0200
+++ b/Discovery/Inc/text_multilanguage.h	Fri Apr 21 09:47:44 2023 +0200
@@ -350,6 +350,10 @@
 		TXT2BYTE_CheckSettings,
 		TXT2BYTE_NotCalibrated,
 
+        TXT2BYTE_CcrSummary,
+        TXT2BYTE_Setpoint,
+        TXT2BYTE_Scrubber,
+
 		TXT2BYTE_END
 };
 
--- a/Discovery/Src/t7.c	Fri Apr 21 09:47:06 2023 +0200
+++ b/Discovery/Src/t7.c	Fri Apr 21 09:47:44 2023 +0200
@@ -141,8 +141,10 @@
     CVIEW_sensors,
     CVIEW_Compass,
     CVIEW_Tissues,
+    CVIEW_Gaslist,
     CVIEW_sensors_mV,
 	CVIEW_Charger,
+    CVIEW_CcrSummary,
     CVIEW_END
 };
 
@@ -173,6 +175,8 @@
 #define SHOW_AMBIENTE_SURFACE_DELTA		(0.02f)
 #define SHOW_AMBIENTE_DEBOUNCE			(0.003f)
 
+#define MAX_NUM_SUMMARY_LINES 6
+
 /* Exported functions --------------------------------------------------------*/
 
 void t7_init(void)
@@ -1646,10 +1650,11 @@
 {
 	uint8_t i = 0;
 	uint8_t cv_disabled = 0;
+    SSettings *settings = settingsGetPointer();
 
    	while(cv_changelist[i] != CVIEW_END)
     {
-         if((view == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i]))
+         if((view == cv_changelist[i]) && !CHECK_BIT_THOME(settings->cv_configuration, cv_changelist[i]))
          {
         	 cv_disabled = 1;
                break;
@@ -1668,6 +1673,9 @@
        	cv_disabled = 1;
     }
 
+    if (view == CVIEW_CcrSummary && !isLoopMode(settings->dive_mode)) {
+        cv_disabled = 1;
+    }
 
     return cv_disabled;
 }
@@ -1759,6 +1767,206 @@
 }
 
 
+static void t7_CcrSummary(SSettings *settings)
+{
+    unsigned numLines = 1; // CCR Mode
+
+    SGasLine *diluentsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL };
+    unsigned i = NUM_OFFSET_DILUENT + 1;
+    // Add diluent at start of dive
+    while (i <= NUM_OFFSET_DILUENT + 1 + NUM_GASES) {
+        if (settings->gas[i].note.ub.active && settings->gas[i].note.ub.first) {
+            diluentsToShow[0] = &settings->gas[i];
+            numLines++;
+
+            break;
+        }
+
+        i++;
+    }
+
+    bool showScrubberTime = false;
+    if (settings->scrubTimerMode != SCRUB_TIMER_OFF) {
+        numLines++;
+        showScrubberTime = true;
+    }
+
+    bool showManualSetpoints = false;
+    unsigned offset;
+    SSetpointLine *setpointsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL };
+    if (settings->CCR_Mode == CCRMODE_FixedSetpoint || settings->fallbackToFixedSetpoint) {
+        // Add setpoint at start of dive
+        offset = numLines;
+        i = 1;
+        while (i <= NUM_GASES) {
+            if (settings->setpoint[i].note.ub.active && settings->setpoint[i].note.ub.first) {
+                setpointsToShow[numLines - offset] = &settings->setpoint[i];
+                numLines++;
+
+                break;
+            }
+
+            i++;
+        }
+
+        if (settings->autoSetpoint) {
+            i = 1;
+            while (i <= NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) {
+                if (settings->setpoint[i].note.ub.active && !settings->setpoint[i].note.ub.first && settings->setpoint[i].depth_meter) {
+                    setpointsToShow[numLines - offset] = &settings->setpoint[i];
+                    numLines++;
+                }
+
+                i++;
+            }
+        } else {
+            showManualSetpoints = true;
+        }
+    }
+
+    // Add remaining active diluents
+    i = NUM_OFFSET_DILUENT + 1;
+    offset = numLines;
+    if (diluentsToShow[0]) {
+        offset--;
+    }
+    while (i < NUM_OFFSET_DILUENT + 1 + NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) {
+        if (settings->gas[i].note.ub.active && !settings->gas[i].note.ub.first) {
+            diluentsToShow[numLines - offset] = &settings->gas[i];
+            numLines++;
+        }
+
+        i++;
+    }
+
+    if (showManualSetpoints) {
+        // Fill up the remaining lines with setpoints
+        offset = numLines;
+        if (setpointsToShow[0]) {
+            offset--;
+        }
+        i = 2;
+        while (i <= NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) {
+            if (settings->setpoint[i].note.ub.active && !settings->setpoint[i].note.ub.first) {
+                setpointsToShow[numLines - offset] = &settings->setpoint[i];
+                numLines++;
+            }
+
+            i++;
+        }
+    }
+
+    char heading[128];
+    unsigned headingIndex = 0;
+
+    char data[128];
+    unsigned dataIndex = 0;
+
+    heading[headingIndex++] = '\032';
+    heading[headingIndex++] = '\016';
+    heading[headingIndex++] = '\016';
+    heading[headingIndex++] = TXT_CCRmode;
+
+    data[dataIndex++] = '\t';
+    char *modeText;
+    if (settings->CCR_Mode == CCRMODE_Sensors) {
+        if (settings->fallbackToFixedSetpoint) {
+            modeText = (char *)&"Sens/FB";
+        } else {
+            modeText = (char *)&"Sensor";
+        }
+    } else {
+        modeText = (char *)&"Fixed";
+    }
+    dataIndex += snprintf(&data[dataIndex], 10, "\020%s", modeText);
+
+    i = 0;
+    while (setpointsToShow[i] != NULL && i < MAX_NUM_SUMMARY_LINES - 1) {
+        heading[headingIndex++] = '\n';
+        heading[headingIndex++] = '\r';
+        if (i == 0) {
+            heading[headingIndex++] = TXT_2BYTE;
+            heading[headingIndex++] = TXT2BYTE_Setpoint;
+        }
+
+        data[dataIndex++] = '\n';
+        data[dataIndex++] = '\r';
+        data[dataIndex++] = '\t';
+        dataIndex += snprintf(&data[dataIndex], 10, "\020%01.2f", setpointsToShow[i]->setpoint_cbar / 100.0);
+        if (settings->autoSetpoint) {
+            dataIndex += snprintf(&data[dataIndex], 10, "\016\016 %um\017", setpointsToShow[i]->depth_meter);
+        }
+
+        i++;
+    }
+
+    i = 0;
+    while (diluentsToShow[i] != NULL && i < MAX_NUM_SUMMARY_LINES - 1) {
+        heading[headingIndex++] = '\n';
+        heading[headingIndex++] = '\r';
+        if (i == 0) {
+            heading[headingIndex++] = TXT_Diluent_Gas_Edit;
+        }
+
+        data[dataIndex++] = '\n';
+        data[dataIndex++] = '\r';
+        data[dataIndex++] = '\t';
+        data[dataIndex++] = '\020';
+        dataIndex += write_gas(&data[dataIndex], diluentsToShow[i]->oxygen_percentage, diluentsToShow[i]->helium_percentage);
+        if (diluentsToShow[i]->note.ub.deco) {
+            char *space = " ";
+            if (diluentsToShow[i]->depth_meter > 99) {
+                space = (char *)"";
+            }
+            dataIndex += snprintf(&data[dataIndex], 10, "\016\016%s%um\017", space, diluentsToShow[i]->depth_meter);
+        }
+
+        i++;
+    }
+
+    if (showScrubberTime) {
+        heading[headingIndex++] = '\n';
+        heading[headingIndex++] = '\r';
+        heading[headingIndex++] = TXT_2BYTE;
+        heading[headingIndex++] = TXT2BYTE_Scrubber;
+
+        data[dataIndex++] = '\n';
+        data[dataIndex++] = '\r';
+        data[dataIndex++] = '\t';
+        dataIndex += printScrubberText(&data[dataIndex], 10, settings);
+    }
+
+    heading[headingIndex++] = '\017';
+    heading[headingIndex++] = 0;
+
+    data[dataIndex++] = 0;
+
+    t7cY0free.WindowLineSpacing = 48;
+    t7cY0free.WindowNumberOfTextLines = 6;
+    t7cY0free.WindowTab = 375;
+
+    t7cY0free.WindowY0 = t7cC.WindowY0 - 10;
+    if (!settings->FlipDisplay) {
+        t7cY0free.WindowX0 += 10;
+        t7cY0free.WindowY0 += 10;
+        t7cY0free.WindowY1 = 355;
+        GFX_write_string(&FontT24, &t7cY0free, heading, 1);
+        t7cY0free.WindowX0 -= 10;
+        t7cY0free.WindowY0 -= 10;
+    } else {
+        t7cY0free.WindowY1 -= 10;
+        t7cY0free.WindowX1 -= 10;
+        GFX_write_string(&FontT24, &t7cY0free, heading, 1);
+        t7cY0free.WindowY1 += 10;
+        t7cY0free.WindowX1 += 10;
+    }
+
+    t7_colorscheme_mod(data);
+
+    GFX_write_string(&FontT42, &t7cY0free, data, 1);
+}
+
+
 void t7_refresh_customview(void)
 {
 	static uint8_t last_customview = CVIEW_END;
@@ -2297,6 +2505,13 @@
         t7cY0free.WindowNumberOfTextLines = 6;
         GFX_write_string(&FontT42, &t7cY0free, text, 1);
         break;
+    case CVIEW_CcrSummary:
+        snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_CcrSummary);
+        GFX_write_string(&FontT42, &t7cH, text, 0);
+
+        t7_CcrSummary(pSettings);
+
+        break;
     }
 }
 
--- a/Discovery/Src/text_multilanguage.c	Fri Apr 21 09:47:06 2023 +0200
+++ b/Discovery/Src/text_multilanguage.c	Fri Apr 21 09:47:44 2023 +0200
@@ -1784,6 +1784,24 @@
 static uint8_t text_IT_NotCalibrated[] = "non calibrata";
 static uint8_t text_ES_NotCalibrated[] = "no calibrada";
 
+static uint8_t text_EN_CcrSummary[] = "CCR Overview";
+static uint8_t text_DE_CcrSummary[] = "CCR Uebersicht"; // T42 hat keine großen Umlaute hw 170103
+static uint8_t text_FR_CcrSummary[] = "Aperçu du CCR";
+static uint8_t text_IT_CcrSummary[] = "Panoramica CCR";
+static uint8_t text_ES_CcrSummary[] = "Desc. gen. CCR";
+
+static uint8_t text_EN_Setpoint[] = "Setpoint";
+static uint8_t text_DE_Setpoint[] = "Setpoint";
+static uint8_t text_FR_Setpoint[] = "Setpoint";
+static uint8_t text_IT_Setpoint[] = "Setpoint";
+static uint8_t text_ES_Setpoint[] = "Setpoint";
+
+static uint8_t text_EN_Scrubber[] = "Scrubber";
+static uint8_t text_DE_Scrubber[] = "Atemkalk";
+static uint8_t text_FR_Scrubber[] = "Scrubber";
+static uint8_t text_IT_Scrubber[] = "Scrubber";
+static uint8_t text_ES_Scrubber[] = "Scrubber";
+
 /* Lookup Table -------------------------------------------------------------*/
 
 const tText text_array[] =
@@ -2048,4 +2066,8 @@
 
 	{(uint8_t)TXT2BYTE_CheckSettings, 	{text_EN_CheckSettings, text_DE_CheckSettings, text_FR_CheckSettings, text_IT_CheckSettings, text_ES_CheckSettings}},
 	{(uint8_t)TXT2BYTE_NotCalibrated, 	{text_EN_NotCalibrated, text_DE_NotCalibrated, text_FR_NotCalibrated, text_IT_NotCalibrated, text_ES_NotCalibrated}},
+
+	{(uint8_t)TXT2BYTE_CcrSummary, 	{text_EN_CcrSummary, text_DE_CcrSummary, text_FR_CcrSummary, text_IT_CcrSummary, text_ES_CcrSummary}},
+	{(uint8_t)TXT2BYTE_Setpoint, 	{text_EN_Setpoint, text_DE_Setpoint, text_FR_Setpoint, text_IT_Setpoint, text_ES_Setpoint}},
+	{(uint8_t)TXT2BYTE_Scrubber, 	{text_EN_Scrubber, text_DE_Scrubber, text_FR_Scrubber, text_IT_Scrubber, text_ES_Scrubber}},
 };