# HG changeset patch # User Ideenmodellierer # Date 1757264923 -7200 # Node ID 3d9552e4997c5252b4c7bf514dfe8251ecad6e28 # Parent 158100a84ebdd8b56e3cc6c861201a3d610e416e Code improvment: line <=> menu id function: In generell the structure of the menus is defined by the tStructure.h using global state defines. In some implementation hardcoded line numbers are used. Risk: In case the order of menu items change the update of other code sections could be forgotten (in the case the update of the top menu) causing unintended behavior. To avoid this the hard coded lines have been replaced by a function connecting the intended function to the menu item defined in the tstructure.h. diff -r 158100a84ebd -r 3d9552e4997c Discovery/Inc/base.h --- a/Discovery/Inc/base.h Sun Sep 07 19:03:44 2025 +0200 +++ b/Discovery/Inc/base.h Sun Sep 07 19:08:43 2025 +0200 @@ -111,6 +111,7 @@ void set_globalState_Menu_Line(uint8_t line); uint8_t get_globalState_Menu_Line(void); void get_idSpecificStateList(uint32_t id, SStateList *output); +uint8_t get_lineOfID(uint32_t id); void delayMicros(uint32_t micros); void get_RTC_DateTime(RTC_DateTypeDef * sdatestructureget, RTC_TimeTypeDef * stimestructureget); void set_RTC_DateTime(RTC_DateTypeDef * sdatestructure, RTC_TimeTypeDef * stimestructure); diff -r 158100a84ebd -r 3d9552e4997c Discovery/Src/base.c --- a/Discovery/Src/base.c Sun Sep 07 19:03:44 2025 +0200 +++ b/Discovery/Src/base.c Sun Sep 07 19:08:43 2025 +0200 @@ -384,16 +384,16 @@ HAL_Delay( 100 ); stateRealGetPointerWrite()->lastKnownBatteryPercentage = 0; // damit das nicht in settings kopiert wird. - set_settings_to_Standard(); /* initialize setting structure with default value => will be overwritten by flash read operation */ + set_settings_to_Standard(EF_SETTINGS); /* initialize setting structure with default value => will be overwritten by flash read operation */ mod_settings_for_first_start_with_empty_ext_flash(); - ext_flash_read_settings(); + ext_flash_read_settings(EF_SETTINGS); if( newFirmwareVersionCheckViaSettings() ) // test for old firmware version in loaded settings { wasFirmwareUpdateCheckBattery = 1; set_settings_button_to_factory_with_individual_buttonBalance(); // will adapt individual values } - set_new_settings_missing_in_ext_flash(); // includes update of firmware version 161121 + set_new_settings_missing_in_ext_flash(EF_SETTINGS); // includes update of firmware version 161121 GFX_init( &pLayerInvisible ); TIM_BACKLIGHT_init(); @@ -412,7 +412,7 @@ tComm_Set_Bluetooth_Name(1); } */ - errorsInSettings = check_and_correct_settings(); + errorsInSettings = check_and_correct_settings(EF_SETTINGS); createDiveSettings(); #ifdef QUICK_SLEEP @@ -471,7 +471,7 @@ if( settingsGetPointer()->debugModeOnStart ) { settingsGetPointer()->debugModeOnStart = 0; - ext_flash_write_settings(0); + ext_flash_write_settings(EF_SETTINGS,0); setDebugMode(); openInfo( StIDEBUG ); } @@ -505,7 +505,7 @@ { createDiveSettings(); updateMenu(); - ext_flash_write_settings(0); + ext_flash_write_settings(EF_SETTINGS,0); } /* check if tasks depending on global state are pending */ @@ -1023,7 +1023,7 @@ GFX_logoAutoOff(); display_power_off(); ext_flash_write_devicedata(true); /* write data at default position */ - ext_flash_write_settings(true); /* write data at default position */ + ext_flash_write_settings(EF_SETTINGS,true); /* write data at default position */ set_globalState(StStop); } @@ -1055,6 +1055,16 @@ output->mode = (uint8_t)((id ) & 0xFF); } +uint8_t get_lineOfID(uint32_t id) +{ + uint8_t ret = (uint8_t)((id >> 16) & 0xFF); + if(ret > 6) + { + ret = 0; + } + return ret; +} + SButtonLock get_ButtonLock(void) { return ButtonLockState; diff -r 158100a84ebd -r 3d9552e4997c Discovery/Src/tMenu.c --- a/Discovery/Src/tMenu.c Sun Sep 07 19:03:44 2025 +0200 +++ b/Discovery/Src/tMenu.c Sun Sep 07 19:08:43 2025 +0200 @@ -797,7 +797,7 @@ update_content_with_new_frame(page, text, tabPosition, subtext); break; case StMDECO: - if((line == 1) || (line == 3)) // dive mode or ppO2 limits (the later for correct MOD in gaslists) + if((line == get_lineOfID(StMDECO1_OC)) || (line == get_lineOfID(StMDECO3_PPO2Max))) // dive mode or ppO2 limits (the later for correct MOD in gaslists) { tM_rebuild_pages(); menu.lineMemoryForNavigationForPage[page] = line; // fix 160623 @@ -826,7 +826,7 @@ update_content_actual_page(text, tabPosition, subtext); break; case StMSYS: - if((line == 2) || (line == 3) || (line == 6)) + if((line == get_lineOfID(StMSYS1_DateTime)) || (line == get_lineOfID(StMSYS2_English)) || (line == get_lineOfID(StMSYS_Profile))) { tM_rebuild_pages(); menu.lineMemoryForNavigationForPage[page] = line; // fix 160623