Mercurial > public > ostc4
changeset 789:b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
author | heinrichsweikamp |
---|---|
date | Wed, 12 Jul 2023 10:13:25 +0200 |
parents | 4abfb8a2a435 |
children | 3b5f9557c053 |
files | Discovery/Inc/text_multilanguage.h Discovery/Src/tMenuEditSetpoint.c Discovery/Src/tMenuSetpoint.c Discovery/Src/text_multilanguage.c |
diffstat | 4 files changed, 109 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Inc/text_multilanguage.h Tue Jul 04 14:39:06 2023 +0200 +++ b/Discovery/Inc/text_multilanguage.h Wed Jul 12 10:13:25 2023 +0200 @@ -364,6 +364,7 @@ TXT2BYTE_SetpointDelayed, TXT2BYTE_Enabled, + TXT2BYTE_Custom, TXT2BYTE_Set, TXT2BYTE_Clear,
--- a/Discovery/Src/tMenuEditSetpoint.c Tue Jul 04 14:39:06 2023 +0200 +++ b/Discovery/Src/tMenuEditSetpoint.c Wed Jul 12 10:13:25 2023 +0200 @@ -98,7 +98,9 @@ int printSetpointName(char *text, uint8_t setpointId, SSettings *settings, bool useSmallFont) { int charsPrinted = 0; - if (settings->autoSetpoint) { + if (setpointId == 0) { + charsPrinted = snprintf(text, 10, "%s%c%c%s", useSmallFont ? "\016\016" : "", TXT_2BYTE, TXT2BYTE_Custom, useSmallFont ? "\017" : ""); + } else if (settings->autoSetpoint) { switch (setpointId) { case SETPOINT_INDEX_AUTO_LOW: charsPrinted = snprintf(text, 10, "%s%c%c%s", useSmallFont ? "\016\016" : "", TXT_2BYTE, TXT2BYTE_SetpointLow, useSmallFont ? "\017" : ""); @@ -124,34 +126,97 @@ } +static void changeSetpoint(uint8_t setpointCbar) +{ + uint8_t actualGasID; + if (!isLoopMode(stateUsedWrite->diveSettings.diveMode)) { + actualGasID = stateUsedWrite->lifeData.lastDiluent_GasIdInSettings; + if (actualGasID <= NUM_OFFSET_DILUENT || actualGasID > NUM_GASES + NUM_OFFSET_DILUENT) { + actualGasID = NUM_OFFSET_DILUENT + 1; + } + } else { + actualGasID = stateUsedWrite->lifeData.actualGas.GasIdInSettings; + } + + setActualGas_DM(&stateUsedWrite->lifeData, actualGasID, setpointCbar); + + checkSwitchToLoop(); + + clear_warning_fallback(); +} + + +static void startSetpointEdit(uint8_t line, uint8_t setpointId) +{ + SSettings *settings = settingsGetPointer(); + + set_globalState_Menu_Line(line); + + resetMenuEdit(CLUT_MenuPageGasSP); + + editSetpointPage.spID = setpointId; + editSetpointPage.pSetpointLine = settings->setpoint; + + uint8_t setpoint_cbar = editSetpointPage.pSetpointLine[setpointId].setpoint_cbar; + uint8_t depthDeco = editSetpointPage.pSetpointLine[setpointId].depth_meter; + uint8_t first = editSetpointPage.pSetpointLine[setpointId].note.ub.first; + + uint8_t setpointBar = setpoint_cbar / 100; + + char text[70]; + + uint8_t textPointer = snprintf(text, 20, "\001%c%c ", TXT_2BYTE, TXT2BYTE_Setpoint); + textPointer += printSetpointName(&text[textPointer], setpointId, settings, false); + snprintf(&text[textPointer], 20, " %c", TXT_Setpoint_Edit); + write_topline(text); + + uint16_t y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP); + + textPointer = snprintf(text, 4, "%c%c", TXT_2BYTE, TXT2BYTE_SetpointShort); + textPointer += printSetpointName(&text[textPointer], setpointId, settings, true); + textPointer += snprintf(&text[textPointer], 60, " %s* \016\016 bar\017", first ? "" : "\177"); + + if ((settings->autoSetpoint && setpointId == SETPOINT_INDEX_AUTO_DECO) || setpointId == 0) { + textPointer += snprintf(&text[textPointer], 4, "\n\r"); + write_label_var(20, 800, y_line, &FontT48, text); + + write_field_udigit(StMSP_ppo2_setting, 160, 800, y_line, &FontT48, "#.##", (uint32_t)setpointBar, (uint32_t)(setpoint_cbar - (100 * setpointBar)), 0, 0); + + if (settings->autoSetpoint && setpointId == SETPOINT_INDEX_AUTO_DECO) { + snprintf(text, 60, "\034 \035%c%c\n\r", TXT_2BYTE, TXT2BYTE_Enabled); + write_label_var(20, 800, y_line + ME_Y_LINE_STEP, &FontT48, text); + write_field_select(StMSP_Active, 160, 800, y_line + ME_Y_LINE_STEP, &FontT48, "#", settings->setpoint[setpointId].note.ub.active, 0, 0, 0); + } + } else { + textPointer += snprintf(&text[textPointer], 40, "\034 \016\016 \017 \016\016meter\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)setpointBar, (uint32_t)(setpoint_cbar - (100 * setpointBar)), depthDeco, 0); + } + setEvent(StMSP_ppo2_setting, (uint32_t)OnAction_SP_Setpoint); + setEvent(StMSP_Active, (uint32_t)OnAction_SP_SetpointActive); + + startEdit(); +} + + void openEdit_Setpoint(uint8_t line) { - SSettings *settings = settingsGetPointer(); - - uint8_t useSensorSubMenu = 0; - char text[20]; - uint8_t sensorActive[3]; + SSettings *settings = settingsGetPointer(); /* dive mode */ if (actual_menu_content != MENU_SURFACE) { - uint8_t setpointCbar, actualGasID; - setpointCbar = 100; + SSettings *settings = settingsGetPointer(); - // actualGasID - if(!isLoopMode(stateUsedWrite->diveSettings.diveMode)) - { - actualGasID = stateUsedWrite->lifeData.lastDiluent_GasIdInSettings; - if((actualGasID <= NUM_OFFSET_DILUENT) || (actualGasID > NUM_GASES + NUM_OFFSET_DILUENT)) - actualGasID = NUM_OFFSET_DILUENT + 1; - } - else - actualGasID = stateUsedWrite->lifeData.actualGas.GasIdInSettings; - - // setpointCbar, CCR_Mode and sensor menu + uint8_t setpointCbar = 100; + uint8_t useSensorSubMenu = 0; if (line < 6 && stateUsedWrite->diveSettings.diveMode != DIVEMODE_PSCR) { /* setpoints inactive in PSCR mode */ if (settings->autoSetpoint && line > SETPOINT_INDEX_AUTO_DECO) { + if (line == 5) { + startSetpointEdit(line, 0); + } + return; } @@ -174,11 +239,7 @@ } } - setActualGas_DM(&stateUsedWrite->lifeData,actualGasID, setpointCbar); - - checkSwitchToLoop(); - - clear_warning_fallback(); + changeSetpoint(setpointCbar); if(!useSensorSubMenu) { @@ -189,11 +250,14 @@ set_globalState_Menu_Line(line); resetMenuEdit(CLUT_MenuPageGasSP); + char text[20]; + text[0] = '\001'; text[1] = TXT_o2Sensors; text[2] = 0; write_topline(text); + uint8_t sensorActive[3]; if(stateUsedWrite->diveSettings.ppo2sensors_deactivated & 1) { snprintf (text,20,"Sensor 1"); @@ -238,54 +302,8 @@ } } else { /* surface mode */ - uint8_t spId, setpoint_cbar, depthDeco, first; - char text[70]; - uint8_t textPointer; - uint16_t y_line; - if ((!settings->autoSetpoint && line <= 5) || line <= SETPOINT_INDEX_AUTO_DECO) { - set_globalState_Menu_Line(line); - - resetMenuEdit(CLUT_MenuPageGasSP); - - spId = line; - editSetpointPage.spID = spId; - editSetpointPage.pSetpointLine = settings->setpoint; - - setpoint_cbar = editSetpointPage.pSetpointLine[spId].setpoint_cbar; - depthDeco = editSetpointPage.pSetpointLine[spId].depth_meter; - first = editSetpointPage.pSetpointLine[spId].note.ub.first; - - uint8_t setpointBar = setpoint_cbar / 100; - - textPointer = snprintf(text, 20, "\001%c%c ", TXT_2BYTE, TXT2BYTE_Setpoint); - textPointer += printSetpointName(&text[textPointer], line, settings, false); - snprintf(&text[textPointer], 20, " %c", TXT_Setpoint_Edit); - write_topline(text); - - y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP); - - textPointer = snprintf(text, 4, "%c%c", TXT_2BYTE, TXT2BYTE_SetpointShort); - textPointer += printSetpointName(&text[textPointer], line, settings, true); - textPointer += snprintf(&text[textPointer], 60, " %s* \016\016 bar\017", first ? "" : "\177"); - - if (settings->autoSetpoint && line == SETPOINT_INDEX_AUTO_DECO) { - textPointer += snprintf(&text[textPointer], 4, "\n\r"); - write_label_var(20, 800, y_line, &FontT48, text); - - write_field_udigit(StMSP_ppo2_setting, 160, 800, y_line, &FontT48, "#.##", (uint32_t)setpointBar, (uint32_t)(setpoint_cbar - (100 * setpointBar)), settings->setpoint[line].note.ub.active, 0); - - snprintf(text, 60, "\034 \035%c%c\n\r", TXT_2BYTE, TXT2BYTE_Enabled); - write_label_var(20, 800, y_line + ME_Y_LINE_STEP, &FontT48, text); - write_field_select(StMSP_Active, 160, 800, y_line + ME_Y_LINE_STEP, &FontT48, "#", settings->setpoint[line].note.ub.active, 0, 0, 0); - } else { - textPointer += snprintf(&text[textPointer], 40, "\034 \016\016 \017 \016\016meter\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)setpointBar, (uint32_t)(setpoint_cbar - (100 * setpointBar)), depthDeco, 0); - } - setEvent(StMSP_ppo2_setting, (uint32_t)OnAction_SP_Setpoint); - setEvent(StMSP_Active, (uint32_t)OnAction_SP_SetpointActive); - startEdit(); + startSetpointEdit(line, line); } else if (line == 5) { settings->delaySetpointLow = !settings->delaySetpointLow; @@ -300,6 +318,7 @@ } } + static uint8_t OnAction_SP_Setpoint(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { SSettings *settings = settingsGetPointer(); @@ -333,6 +352,10 @@ checkAndFixSetpointSettings(); return EXIT_TO_NEXT_MENU; + } else if (editSetpointPage.spID == 0) { + changeSetpoint(new_cbar); + + return UPDATE_AND_EXIT_TO_HOME; } else { if (newDepth > 255) { newDepth = 255;
--- a/Discovery/Src/tMenuSetpoint.c Tue Jul 04 14:39:06 2023 +0200 +++ b/Discovery/Src/tMenuSetpoint.c Wed Jul 12 10:13:25 2023 +0200 @@ -58,8 +58,13 @@ for(int spId=1;spId<=NUM_GASES;spId++) { if (settings->autoSetpoint) { - if (actual_menu_content == MENU_SURFACE && spId == 5) { - textPointer += snprintf(&text[textPointer], 40, "\020%c%c\016\016%c%c\017 %c%c\002%c\n\r", TXT_2BYTE, TXT2BYTE_SetpointShort, TXT_2BYTE, TXT2BYTE_SetpointLow, TXT_2BYTE, TXT2BYTE_SetpointDelayed, settings->delaySetpointLow ? '\005' : '\006'); + if (spId == 5) { + if (actual_menu_content == MENU_SURFACE) { + textPointer += snprintf(&text[textPointer], 40, "\020%c%c\016\016%c%c\017 %c%c\002%c\n\r", TXT_2BYTE, TXT2BYTE_SetpointShort, TXT_2BYTE, TXT2BYTE_SetpointLow, TXT_2BYTE, TXT2BYTE_SetpointDelayed, settings->delaySetpointLow ? '\005' : '\006'); + } else { + textPointer += snprintf(&text[textPointer], 40, "\020%c%c %c%c\n\r", TXT_2BYTE, TXT2BYTE_Custom, TXT_2BYTE, TXT2BYTE_Setpoint); + } + continue; } else if (spId > SETPOINT_INDEX_AUTO_DECO) { textPointer += snprintf(&text[textPointer], 3, "\n\r");
--- a/Discovery/Src/text_multilanguage.c Tue Jul 04 14:39:06 2023 +0200 +++ b/Discovery/Src/text_multilanguage.c Wed Jul 12 10:13:25 2023 +0200 @@ -1877,6 +1877,12 @@ static uint8_t text_IT_Enabled[] = "abilitato"; static uint8_t text_ES_Enabled[] = "activado"; +static uint8_t text_EN_Custom[] = "Custom"; +static uint8_t text_DE_Custom[] = "Benützer"; +static uint8_t text_FR_Custom[] = "Custom"; +static uint8_t text_IT_Custom[] = "Custom"; +static uint8_t text_ES_Custom[] = "Custom"; + /* Lookup Table -------------------------------------------------------------*/ const tText text_array[] = @@ -2156,6 +2162,7 @@ {(uint8_t)TXT2BYTE_SetpointDelayed, {text_EN_SetpointDelayed, text_DE_SetpointDelayed, text_FR_SetpointDelayed, text_IT_SetpointDelayed, text_ES_SetpointDelayed}}, {(uint8_t)TXT2BYTE_Enabled, {text_EN_Enabled, text_DE_Enabled, text_FR_Enabled, text_IT_Enabled, text_ES_Enabled}}, + {(uint8_t)TXT2BYTE_Custom, {text_EN_Custom, text_DE_Custom, text_FR_Custom, text_IT_Custom, text_ES_Custom}}, {(uint8_t)TXT2BYTE_Set, {text_EN_Set, text_DE_Set, text_FR_Set, text_IT_Set, text_ES_Set}}, {(uint8_t)TXT2BYTE_Clear, {text_EN_Clear, text_DE_Clear, text_FR_Clear, text_IT_Clear, text_ES_Clear}},