# HG changeset patch # User Ideenmodellierer # Date 1607803511 -3600 # Node ID 830de438e0b0ea7fd6c6fcec68a3cd178c065c37 # Parent 3860b8fa4b29efd6f1ac7db3d3532e92a2ce7de0 Added option for 100% o2 calibration: For the implementation of the selection of the calib gas the reactivation of the menu elemen "FIELD_TOGGLE" was necessary. Within the calibration menu item it is now possible to select between air and 100% o2 calibration. The calibration itself no consideres the ambient pressure during calculation of the coeff. diff -r 3860b8fa4b29 -r 830de438e0b0 Discovery/Inc/tMenuEdit.h --- a/Discovery/Inc/tMenuEdit.h Sat Dec 12 20:54:31 2020 +0100 +++ b/Discovery/Inc/tMenuEdit.h Sat Dec 12 21:05:11 2020 +0100 @@ -95,7 +95,7 @@ void exitMenuEdit_to_Home_with_Menu_Update(void); void exitMenuEdit_to_Menu_with_Menu_Update(void); void exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(void); - +void exitMenuEditField(void); void tMenuEdit_writeSettingsToFlash(void); GFX_DrawCfgScreen* getMenuEditScreen(void); diff -r 3860b8fa4b29 -r 830de438e0b0 Discovery/Inc/text_multilanguage.h --- a/Discovery/Inc/text_multilanguage.h Sat Dec 12 20:54:31 2020 +0100 +++ b/Discovery/Inc/text_multilanguage.h Sat Dec 12 21:05:11 2020 +0100 @@ -268,7 +268,7 @@ TXT2BYTE_SetToMOD, /* */ TXT2BYTE_HUDbattery, - TXT2BYTE_O2CalibAir, + TXT2BYTE_O2Calib, TXT2BYTE_O2Interface, TXT2BYTE_O2IFOptic, TXT2BYTE_O2IFAnalog, diff -r 3860b8fa4b29 -r 830de438e0b0 Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Sat Dec 12 20:54:31 2020 +0100 +++ b/Discovery/Src/data_exchange_main.c Sat Dec 12 21:05:11 2020 +0100 @@ -102,7 +102,6 @@ #define UNKNOWN_DATE_MONTH 1 #define UNKNOWN_DATE_YEAR 16 -#define IGNORE_O2_VOLTAGE_LEVEL_MV (0.5f) /* Private function prototypes -----------------------------------------------*/ static uint8_t DataEX_check_header_and_footer_ok(void); diff -r 3860b8fa4b29 -r 830de438e0b0 Discovery/Src/tMenuEdit.c --- a/Discovery/Src/tMenuEdit.c Sat Dec 12 20:54:31 2020 +0100 +++ b/Discovery/Src/tMenuEdit.c Sat Dec 12 21:05:11 2020 +0100 @@ -206,6 +206,7 @@ switch(globState) { case (StMHARD3_O2_Sensor1 & MaskFieldDigit): + case (StMHARD3_O2_Calibrate): case (StMHARD3_O2_Source): refreshFct = refresh_O2Sensors; break; case (StMHARD2_Compass_SetCourse & MaskFieldDigit): refreshFct = refresh_CompassEdit; @@ -434,7 +435,7 @@ if(ident[id].maintype == FIELD_NUMBERS) content = ident[id].newText[ident[id].begin[block] + subBlockPosition]; else - if(ident[id].maintype == FIELD_ON_OFF) + if((ident[id].maintype == FIELD_ON_OFF) || (ident[id].maintype == FIELD_TOGGLE)) content = ident[id].input[block]; else content = 0; /* just a default for protection */ @@ -545,6 +546,11 @@ // now fixed for button settings with newContent <= '0'+99 condition change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldSelected); } + if(ident[id].maintype == FIELD_TOGGLE) + { + change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); + } + newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); @@ -1413,6 +1419,32 @@ id++; } } +void write_field_toggle(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1, uint8_t int2) +{ + if(id >= 9) return; + ident[id].maintype = FIELD_TOGGLE; + ident[id].subtype = FIELD_TOGGLE; + ident[id].coord[0] = XleftGimpStyle; + ident[id].coord[1] = XrightGimpStyle; + ident[id].coord[2] = YtopGimpStyle; + ident[id].fontUsed = (tFont *)Font; + ident[id].callerID = editID; + strncpy(ident[id].orgText, text, 32); + strncpy(ident[id].newText, text, 32); + ident[id].orgText[31] = 0; + ident[id].newText[31] = 0; + + change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); + + if(editID == 0) write_content_without_Id(); + else + { + write_content_of_actual_Id(); + if(!tME_stop) idLast = id; + id++; + } +} + /* was build for field_on_off diff -r 3860b8fa4b29 -r 830de438e0b0 Discovery/Src/tMenuEditHardware.c --- a/Discovery/Src/tMenuEditHardware.c Sat Dec 12 20:54:31 2020 +0100 +++ b/Discovery/Src/tMenuEditHardware.c Sat Dec 12 21:05:11 2020 +0100 @@ -72,6 +72,7 @@ #define O2_CALIB_FRACTION_AIR (0.209F) +static uint8_t O2_calib_gas = 21; void openEdit_Hardware(uint8_t line) { @@ -310,9 +311,11 @@ else { text[0] = TXT_2BYTE; - text[1] = TXT2BYTE_O2CalibAir; + text[1] = TXT2BYTE_O2Calib; text[2] = 0; write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); + snprintf(text, 20,"%d%%", O2_calib_gas); + write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); } for(int i=0;i<3;i++) @@ -344,7 +347,14 @@ tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); tMenuEdit_refresh_field(StMHARD3_O2_Fallback); - write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); + if(get_globalState() == StMHARD3_O2_Calibrate) + { + write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus); + } + else + { + write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); + } } @@ -369,7 +379,10 @@ if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) { - write_field_button(StMHARD3_O2_Calibrate, 30, 800, ME_Y_LINE4, &FontT48, ""); + write_label_fix( 30, 800, ME_Y_LINE4, &FontT48, TXT2BYTE_O2Calib); + write_label_var( 400, 800, ME_Y_LINE4, &FontT48, "\016\016 %\017"); + + write_field_toggle(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, "", 21, 100); } text[0] = TXT_Fallback; @@ -468,25 +481,56 @@ uint8_t loop; const SDiveState *pStateReal = stateRealGetPointer(); SSettings* pSettings = settingsGetPointer(); + uint8_t retVal = UNSPECIFIC_RETURN; + float compensatedRef; - for(loop=0;loop<3;loop++) - { - if((pSettings->ppo2sensors_deactivated & (0x1 << loop)) == 0) - { - if(pStateReal->lifeData.sensorVoltage_mV[loop] > 0.0001) /* sensor connected ?*/ + if(action == ACTION_BUTTON_ENTER_FINAL) + { + if(O2_calib_gas == 21) + { + compensatedRef = O2_CALIB_FRACTION_AIR * pStateReal->lifeData.pressure_ambient_bar / 1.0; + } + else + { + compensatedRef = 100.0 * pStateReal->lifeData.pressure_ambient_bar / 1.0; + } + for(loop=0;loop<3;loop++) { - pSettings->ppo2sensors_calibCoeff[loop] = O2_CALIB_FRACTION_AIR / pStateReal->lifeData.sensorVoltage_mV[loop]; + if((pSettings->ppo2sensors_deactivated & (0x1 << loop)) == 0) + { + if(pStateReal->lifeData.sensorVoltage_mV[loop] > 0.0001) /* sensor connected ?*/ + { + pSettings->ppo2sensors_calibCoeff[loop] = compensatedRef / pStateReal->lifeData.sensorVoltage_mV[loop]; + } + else + { + pSettings->ppo2sensors_calibCoeff[loop] = 0.0; + settingsGetPointer()->ppo2sensors_deactivated |= 0x1 << loop; + } + } } - else - { - pSettings->ppo2sensors_calibCoeff[loop] = 0.0; - settingsGetPointer()->ppo2sensors_deactivated |= 0x1 << loop; - tMenuEdit_set_on_off(editId, 0); - } + tMenuEdit_newInput(editId, O2_calib_gas, 0, 0, 0); + retVal = UPDATE_DIVESETTINGS; + } + if(action == ACTION_BUTTON_NEXT) + { + if(O2_calib_gas == 21) + { + O2_calib_gas = 100; } - } + else + { + O2_calib_gas = 21; + } + } + retVal = O2_calib_gas; - return UPDATE_DIVESETTINGS; + if(action == ACTION_BUTTON_BACK) + { + exitMenuEditField(); + } + + return retVal; } uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { diff -r 3860b8fa4b29 -r 830de438e0b0 Discovery/Src/tMenuEditPlanner.c --- a/Discovery/Src/tMenuEditPlanner.c Sat Dec 12 20:54:31 2020 +0100 +++ b/Discovery/Src/tMenuEditPlanner.c Sat Dec 12 21:05:11 2020 +0100 @@ -34,6 +34,7 @@ #include "simulation.h" #include "tHome.h" //for tHome_gas_writer() #include "tMenuEdit.h" +#include "unit.h" /* Private types -------------------------------------------------------------*/ uint8_t resultPage = 0; diff -r 3860b8fa4b29 -r 830de438e0b0 Discovery/Src/text_multilanguage.c --- a/Discovery/Src/text_multilanguage.c Sat Dec 12 20:54:31 2020 +0100 +++ b/Discovery/Src/text_multilanguage.c Sat Dec 12 21:05:11 2020 +0100 @@ -1235,11 +1235,11 @@ static uint8_t text_IT_HUDBattery[] = "Batteria HUD"; static uint8_t text_ES_HUDBattery[] = "Carga del HUD"; -static uint8_t text_EN_O2CalibAir[] = "Calibrate Air"; -static uint8_t text_DE_O2CalibAir[] = "Kalibrierung Luft"; -static uint8_t text_FR_O2CalibAir[] = ""; -static uint8_t text_IT_O2CalibAir[] = ""; -static uint8_t text_ES_O2CalibAir[] = ""; +static uint8_t text_EN_O2Calib[] = "Calibrate"; +static uint8_t text_DE_O2Calib[] = "Kalibrierung"; +static uint8_t text_FR_O2Calib[] = ""; +static uint8_t text_IT_O2Calib[] = ""; +static uint8_t text_ES_O2Calib[] = ""; static uint8_t text_EN_O2Interface[] = "O2 Interface"; static uint8_t text_DE_O2Interface[] = "O2 Interface"; @@ -1844,7 +1844,7 @@ {(uint8_t)TXT2BYTE_CornerStandard, {text_EN_CornerStandard, text_DE_CornerStandard, text_FR_CornerStandard, text_IT_CornerStandard, text_ES_CornerStandard}}, {(uint8_t)TXT2BYTE_SetToMOD, {text_EN_SetToMOD, text_DE_SetToMOD, text_FR_SetToMOD, text_IT_SetToMOD, text_ES_SetToMOD}}, {(uint8_t)TXT2BYTE_HUDbattery, {text_EN_HUDBattery, text_DE_HUDBattery, text_FR_HUDBattery, text_IT_HUDBattery, text_ES_HUDBattery}}, - {(uint8_t)TXT2BYTE_O2CalibAir, {text_EN_O2CalibAir, text_DE_O2CalibAir, text_FR_O2CalibAir, text_IT_O2CalibAir, text_ES_O2CalibAir}}, + {(uint8_t)TXT2BYTE_O2Calib, {text_EN_O2Calib, text_DE_O2Calib, text_FR_O2Calib, text_IT_O2Calib, text_ES_O2Calib}}, {(uint8_t)TXT2BYTE_O2Interface, {text_EN_O2Interface, text_DE_O2Interface, text_FR_O2Interface, text_IT_O2Interface, text_ES_O2Interface}}, {(uint8_t)TXT2BYTE_O2IFOptic, {text_EN_O2IFOptic, text_DE_O2IFOptic, text_FR_O2IFOptic, text_IT_O2IFOptic, text_ES_O2IFOptic}}, {(uint8_t)TXT2BYTE_O2IFAnalog, {text_EN_O2IFAnalog, text_DE_O2IFAnalog, text_FR_O2IFAnalog, text_IT_O2IFAnalog, text_ES_O2IFAnalog}},