Mercurial > public > ostc4
changeset 1037:2af07aa38531 GasConsumption
Merge with external development branches:
Some features have been prepared for integration: Profiles, DMA UART on Firmware part, Bluetooth discovery and messges logging for development phase. All these new function are deactivated by compile switch and may be activated using the configuration.h for testing purpose.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 15 Sep 2025 21:12:44 +0200 |
| parents | e938901f6386 (diff) 5865f0aeb438 (current diff) |
| children | 677d293c669f |
| files | Common/Inc/configuration.h Discovery/Inc/tStructure.h Discovery/Src/base.c Discovery/Src/tMenu.c Discovery/Src/tMenuEdit.c Discovery/Src/tMenuEditSystem.c Discovery/Src/tMenuSystem.c FontPack/base_upperRegion.c |
| diffstat | 26 files changed, 1193 insertions(+), 520 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/configuration.h Sun Aug 10 15:28:59 2025 +0200 +++ b/Common/Inc/configuration.h Mon Sep 15 21:12:44 2025 +0200 @@ -103,9 +103,13 @@ /* #define ENABLE_SLEEP_DEBUG */ /* Enable to receive data from the radio connection usart */ -#define ENABLE_USART_RADIO +/* #define ENABLE_USART_RADIO */ /* Enable to show messages which are den during runtime in a popup window */ -#define ENABLE_LOGGER_WINDOW +/* #define ENABLE_LOGGER_WINDOW */ + +/* Enable to have the possibility to switch between four individual sets of settings */ +/* #define ENABLE_SETTING_PROFILES */ + #endif
--- a/Common/Inc/settings.h Sun Aug 10 15:28:59 2025 +0200 +++ b/Common/Inc/settings.h Mon Sep 15 21:12:44 2025 +0200 @@ -95,6 +95,8 @@ #define FUTURE_SPARE_SIZE (0u) /* Applied for reuse of old, not used, scooter block (was 32 bytes)*/ +#define NUMBER_OF_PROFILES (4u) + typedef enum { O2_SENSOR_SOURCE_OPTIC = 0, @@ -329,6 +331,9 @@ /* new in 0xFFFF002c */ StimeZone timeZone; uint8_t warningBuzzer; + /* new in 0xFFFF002d */ + uint8_t profileName[NUMBER_OF_PROFILES][9]; + uint8_t activeProfile; } SSettings; uint8_t writeData(uint8_t *); @@ -342,9 +347,11 @@ uint8_t getDecoType(void); uint8_t getFutureTTS(void); +uint16_t settingsGetSize(); SSettings* settingsGetPointer(void); +SSettings* profileGetPointer(uint8_t number); const SSettings* settingsGetPointerStandard(void); -void set_settings_to_Standard(void); +void set_settings_to_Standard(uint8_t whichSettings); void mod_settings_for_first_start_with_empty_ext_flash(void); const SFirmwareData* firmwareDataGetPointer(void); const SHardwareData* hardwareDataGetPointer(void); @@ -361,8 +368,8 @@ void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow); void setFlipDisplay(uint8_t flipDisplay); -void set_new_settings_missing_in_ext_flash(void); -uint8_t check_and_correct_settings(void); +void set_new_settings_missing_in_ext_flash(uint8_t whichSettings); +uint8_t check_and_correct_settings(uint8_t whichSettings); uint8_t newFirmwareVersionCheckViaSettings(void); void set_settings_button_to_factory_with_individual_buttonBalance(void); uint8_t getLicence(void);
--- a/Discovery/Inc/base.h Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Inc/base.h Mon Sep 15 21:12:44 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);
--- a/Discovery/Inc/externLogbookFlash.h Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Inc/externLogbookFlash.h Mon Sep 15 21:12:44 2025 +0200 @@ -41,7 +41,17 @@ */ #define DDSTART 0x00000000 #define DDSTOP 0x00000FFF -#define unused1START 0x00001000 + +#define PROFILE0_START 0x00001000 /* store profiles within one 4k sector because they are always read / written as one block */ +#define PROFILE0_STOP 0x000013FF /* no ring functionality is implemented because changes are not expected very often */ +#define PROFILE1_START 0x00001400 +#define PROFILE1_STOP 0x000017FF +#define PROFILE2_START 0x00001800 +#define PROFILE2_STOP 0x00001BFF +#define PROFILE3_START 0x00001C00 +#define PROFILE3_STOP 0x00001FFF + +#define unused1START 0x00002000 #define unused1STOP 0x00007FFF /* 32 KB */ @@ -84,6 +94,22 @@ #define SECTOR_INUSE (4) #define SECTOR_EMPTY (5) + +typedef enum{ + EF_HEADER, + EF_SAMPLE, + EF_DEVICEDATA, + EF_VPMDATA, + EF_SETTINGS, + EF_FIRMWARE, + EF_FIRMWARE2, + EF_PROFILE0, + EF_PROFILE1, + EF_PROFILE2, + EF_PROFILE3, +}which_ring_enum; + + /* Exported types ------------------------------------------------------------*/ typedef struct{ uint8_t byteLow; @@ -108,8 +134,8 @@ } convert16_Type; /* Exported functions --------------------------------------------------------*/ -void ext_flash_write_settings(uint8_t resetRing); -uint8_t ext_flash_read_settings(void); +void ext_flash_write_settings(uint8_t whichSettings, uint8_t resetRing); +uint8_t ext_flash_read_settings(uint8_t whichSettings); void ext_flash_write_devicedata(uint8_t resetRing); uint16_t ext_flash_read_devicedata(uint8_t *buffer, uint16_t max_length);
--- a/Discovery/Inc/tMenuEdit.h Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Inc/tMenuEdit.h Mon Sep 15 21:12:44 2025 +0200 @@ -68,7 +68,10 @@ void tMenuEdit_select(uint32_t editID); void evaluateNewString (uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4); +void evaluateNewStringText(uint32_t editID, uint8_t *pNewString); + void tMenuEdit_newInput (uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4); +void tMenuEdit_newInputText(uint32_t editID, uint8_t* ptext); void tMenuEdit_newButtonText(uint32_t editID, char *text); void tMenuEdit_set_on_off(uint32_t editID, uint32_t int1); @@ -91,6 +94,7 @@ 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); void write_field_on_off(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1); void write_field_fpoint(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, float input); +void write_field_text(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t* pInput); void stop_cursor_fields(void);
--- a/Discovery/Inc/tStructure.h Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Inc/tStructure.h Mon Sep 15 21:12:44 2025 +0200 @@ -315,6 +315,46 @@ #define StMSYS1_GNSSDT _MB(2,8,1,5,0) #define StMSYS1_ZONE _MB(2,8,1,6,0) +#ifdef ENABLE_SETTING_PROFILES +#define StMSYS_Profile _MB(2,8,2,0,0) +#define StMSYS_ProfileA _MB(2,8,2,1,0) +#define StMSYS_ProfileB _MB(2,8,2,2,0) +#define StMSYS_ProfileC _MB(2,8,2,3,0) +#define StMSYS_ProfileD _MB(2,8,2,4,0) + +#define StMSYS2_English _MB(2,8,3,1,0) +#define StMSYS2_German _MB(2,8,3,2,0) +#define StMSYS2_French _MB(2,8,3,3,0) +#define StMSYS2_Italian _MB(2,8,3,4,0) +#define StMSYS2_Espanol _MB(2,8,3,5,0) + +#define StMSYS3_Units _MB(2,8,4,1,0) +#define StMSYS3_Colors _MB(2,8,4,2,0) +#ifdef HAVE_DEBUG_VIEW +#define StMSYS3_Debug _MB(2,8,4,3,0) +#endif + +#define StMSYS4_Info _MB(2,8,5,1,0) + +#define StMSYS5_Exit _MB(2,8,6,1,0) +#define StMSYS5_LogbookOffset _MB(2,8,6,7,0) +#define StMSYS5_ResetAll _MB(2,8,6,2,0) +#define StMSYS5_ResetDeco _MB(2,8,6,3,0) +#define StMSYS5_Reboot _MB(2,8,6,4,0) +#define StMSYS5_Maintenance _MB(2,8,6,5,0) +#define StMSYS5_ResetLogbook _MB(2,8,6,6,0) +#define StMSYS5_SetBattCharge _MB(2,8,6,7,0) +#define StMSYS5_RebootRTE _MB(2,8,6,8,0) +#define StMSYS5_RebootMainCPU _MB(2,8,6,9,0) +#define StMSYS5_ScreenTest _MB(2,8,6,10,0) +#define StMSYS5_SetFactoryBC _MB(2,8,6,11,0) +#define StMSYS5_ResetBluetooth _MB(2,8,6,12,0) +#define StMSYS5_SetSampleIndx _MB(2,8,6,13,0) +#define StMSYS5_AdjustSurfPres _MB(2,8,6,14,0) +#define StMSYS5_FlashBoot _MB(2,8,6,15,0) + +#else + #define StMSYS2_English _MB(2,8,2,1,0) #define StMSYS2_German _MB(2,8,2,2,0) #define StMSYS2_French _MB(2,8,2,3,0) @@ -323,7 +363,9 @@ #define StMSYS3_Units _MB(2,8,3,1,0) #define StMSYS3_Colors _MB(2,8,3,2,0) +#ifdef HAVE_DEBUG_VIEW #define StMSYS3_Debug _MB(2,8,3,3,0) +#endif #define StMSYS4_Info _MB(2,8,4,1,0) @@ -343,6 +385,8 @@ #define StMSYS5_SetSampleIndx _MB(2,8,5,13,0) #define StMSYS5_AdjustSurfPres _MB(2,8,5,14,0) #define StMSYS5_FlashBoot _MB(2,8,5,15,0) +#endif + #define StMSYS_Custom0 _MB(2,8,1,0,0) #define StMSYS_Custom1 _MB(2,8,2,0,0)
--- a/Discovery/Src/base.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/base.c Mon Sep 15 21:12:44 2025 +0200 @@ -389,16 +389,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(); @@ -417,7 +417,7 @@ tComm_Set_Bluetooth_Name(1); } */ - errorsInSettings = check_and_correct_settings(); + errorsInSettings = check_and_correct_settings(EF_SETTINGS); createDiveSettings(); #ifdef QUICK_SLEEP @@ -476,7 +476,7 @@ if( settingsGetPointer()->debugModeOnStart ) { settingsGetPointer()->debugModeOnStart = 0; - ext_flash_write_settings(0); + ext_flash_write_settings(EF_SETTINGS,0); setDebugMode(); openInfo( StIDEBUG ); } @@ -511,7 +511,7 @@ { createDiveSettings(); updateMenu(); - ext_flash_write_settings(0); + ext_flash_write_settings(EF_SETTINGS,0); } /* check if tasks depending on global state are pending */ @@ -1050,7 +1050,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); } @@ -1082,6 +1082,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;
--- a/Discovery/Src/externLogbookFlash.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/externLogbookFlash.c Mon Sep 15 21:12:44 2025 +0200 @@ -84,17 +84,6 @@ #define HEADER2OFFSET 0x400 -typedef enum{ - EF_HEADER, - EF_SAMPLE, - EF_DEVICEDATA, - EF_VPMDATA, - EF_SETTINGS, - EF_FIRMWARE, - EF_FIRMWARE2, -}which_ring_enum; - - typedef struct{ uint8_t IsBusy:1; uint8_t IsWriteEnabled:1; @@ -130,6 +119,7 @@ static uint32_t actualPointerDevicedata = DDSTART; static uint32_t actualPointerVPM = 0; static uint32_t actualPointerSettings = SETTINGSSTART; +static uint32_t actualPointerProfile = PROFILE0_START; static uint32_t actualPointerFirmware = 0; static uint32_t actualPointerFirmware2 = 0; @@ -527,28 +517,44 @@ return; } #else -void ext_flash_write_settings(uint8_t resetRing) +void ext_flash_write_settings(uint8_t whichSettings, uint8_t resetRing) { - uint8_t *pData; + SSettings *pSettings; const uint16_t length = sizeof(SSettings); uint8_t length_lo, length_hi; uint8_t dataLength[2] = { 0 }; + pSettings = settingsGetPointer(); + ext_flash_disable_protection(); - if(stateRealGetPointer()->lastKnownBatteryPercentage) + switch (whichSettings) { - settingsGetPointer()->lastKnownBatteryPercentage = stateRealGetPointer()->lastKnownBatteryPercentage; - } - settingsGetPointer()->backup_localtime_rtc_tr = stateRealGetPointer()->lifeData.timeBinaryFormat; - settingsGetPointer()->backup_localtime_rtc_dr = stateRealGetPointer()->lifeData.dateBinaryFormat; - - pData = (uint8_t *)settingsGetPointer(); - - /* Reset the Ring to the start address if requested (e.g. because we write the default block during shutdown) */ - if((resetRing) || ((actualPointerSettings + length) >= SETTINGSSTOP)) - { - actualPointerSettings = SETTINGSSTART; + default: + case EF_SETTINGS: if(stateRealGetPointer()->lastKnownBatteryPercentage) + { + pSettings->lastKnownBatteryPercentage = stateRealGetPointer()->lastKnownBatteryPercentage; + } + pSettings->backup_localtime_rtc_tr = stateRealGetPointer()->lifeData.timeBinaryFormat; + pSettings->backup_localtime_rtc_dr = stateRealGetPointer()->lifeData.dateBinaryFormat; + /* Reset the Ring to the start address if requested (e.g. because we write the default block during shutdown) */ + if((resetRing) || ((actualPointerSettings + length) >= SETTINGSSTOP)) + { + actualPointerSettings = SETTINGSSTART; + } + break; + case EF_PROFILE0: actualPointerProfile = PROFILE0_START; + pSettings = profileGetPointer(0); + break; + case EF_PROFILE1: actualPointerProfile = PROFILE1_START; + pSettings = profileGetPointer(1); + break; + case EF_PROFILE2: actualPointerProfile = PROFILE2_START; + pSettings = profileGetPointer(2); + break; + case EF_PROFILE3: actualPointerProfile = PROFILE3_START; + pSettings = profileGetPointer(3); + break; } length_lo = (uint8_t)(length & 0xFF); @@ -556,8 +562,8 @@ dataLength[0] = length_lo; dataLength[1] = length_hi; - ef_write_block(dataLength,2, EF_SETTINGS, 0); - ef_write_block(pData,length, EF_SETTINGS, 0); + ef_write_block(dataLength,2, whichSettings, 0); + ef_write_block((uint8_t*)pSettings,length, whichSettings, 0); // ext_flash_enable_protection(); } #endif @@ -570,7 +576,7 @@ * new settings should be fine as they are added * and loaded before calling this function */ -uint8_t ext_flash_read_settings(void) +uint8_t ext_flash_read_settings(uint8_t whichSettings) { uint8_t returnValue = HAL_BUSY; uint8_t exit = 0; @@ -579,69 +585,90 @@ uint8_t length_lo, length_hi; uint16_t lengthOnEEPROM; uint32_t header; - SSettings *pSettings = settingsGetPointer(); - - actualAddress = SETTINGSSTART; + SSettings* pSettings = settingsGetPointer(); - ext_flash_read_block_start(); - ext_flash_read_block(&length_lo, EF_SETTINGS); - ext_flash_read_block(&length_hi, EF_SETTINGS); - - while ((length_lo != 0xFF) && (length_hi != 0xFF) && (exit == 0)) /* get the latest stored setting block */ + switch(whichSettings) + { + case EF_SETTINGS: pSettings = settingsGetPointer(); + actualAddress = SETTINGSSTART; + break; + case EF_PROFILE0: pSettings = profileGetPointer(0); + actualAddress = PROFILE0_START; + break; + case EF_PROFILE1: pSettings = profileGetPointer(1); + actualAddress = PROFILE1_START; + break; + case EF_PROFILE2: pSettings = profileGetPointer(2); + actualAddress = PROFILE2_START; + break; + case EF_PROFILE3: pSettings = profileGetPointer(3); + actualAddress = PROFILE3_START; + break; + default: returnValue = HAL_ERROR; + } + + if(returnValue != HAL_ERROR) { - lengthOnEEPROM = length_hi * 256; - lengthOnEEPROM += length_lo; - if(lengthOnEEPROM <= lengthStandardNow) /* EEPROM Header size equal or smaller => settings constant or upgraded */ + ext_flash_read_block_start(); + ext_flash_read_block(&length_lo, whichSettings); + ext_flash_read_block(&length_hi, whichSettings); + + while ((length_lo != 0xFF) && (length_hi != 0xFF) && (exit == 0)) /* get the latest stored setting block */ { - ext_flash_read_block_multi(&header, 4, EF_SETTINGS); - if((header <= pSettings->header) && (header >= pSettings->updateSettingsAllowedFromHeader)) /* check to allow update of header */ + lengthOnEEPROM = length_hi * 256; + lengthOnEEPROM += length_lo; + if(lengthOnEEPROM <= lengthStandardNow) /* EEPROM Header size equal or smaller => settings constant or upgraded */ { - returnValue = HAL_OK; - pSettings->header = header; - pData = (uint8_t *)pSettings + 4; /* header */ - for(uint16_t i = 0; i < (lengthOnEEPROM-4); i++) - ext_flash_read_block(&pData[i], EF_SETTINGS); - if(header != pSettings->header) /* setting layout changed => no additional setting sets expected */ + ext_flash_read_block_multi(&header, 4, whichSettings); + if((header <= pSettings->header) && (header >= pSettings->updateSettingsAllowedFromHeader)) /* check to allow update of header */ { + returnValue = HAL_OK; + pSettings->header = header; + pData = (uint8_t *)pSettings + 4; /* header */ + for(uint16_t i = 0; i < (lengthOnEEPROM-4); i++) + ext_flash_read_block(&pData[i], whichSettings); + if(header != pSettings->header) /* setting layout changed => no additional setting sets expected */ + { + exit = 1; + } + } + else + { + returnValue = HAL_ERROR; exit = 1; } } - else + else /* size of settings decreased => possible downgrade of firmware */ { - returnValue = HAL_ERROR; + ext_flash_read_block_multi(&header, 4, whichSettings); + + if(header > 0xFFFF0014) /* verify that new (old) header should be compatible (only less bytes, no change in layout) */ + { + returnValue = HAL_OK; + pSettings->header = header; + pData = (uint8_t *)pSettings + 4; /* header */ + for(uint16_t i = 0; i < (lengthStandardNow-4); i++) /* only read the data fitting into the structure */ + ext_flash_read_block(&pData[i], whichSettings); + } + else + { + returnValue = HAL_ERROR; + } exit = 1; } + ext_flash_read_block(&length_lo, whichSettings); + ext_flash_read_block(&length_hi, whichSettings); } - else /* size of settings decreased => possible downgrade of firmware */ - { - ext_flash_read_block_multi(&header, 4, EF_SETTINGS); + ext_flash_decf_address_ring(whichSettings); /* set pointer back to empty address */ + ext_flash_decf_address_ring(whichSettings); + ext_flash_read_block_stop(); - if(header > 0xFFFF0014) /* verify that new (old) header should be compatible (only less bytes, no change in layout) */ - { - returnValue = HAL_OK; - pSettings->header = header; - pData = (uint8_t *)pSettings + 4; /* header */ - for(uint16_t i = 0; i < (lengthStandardNow-4); i++) /* only read the data fitting into the structure */ - ext_flash_read_block(&pData[i], EF_SETTINGS); - } - else - { - returnValue = HAL_ERROR; - } - exit = 1; + if(actualAddress > actualPointerSettings) /* the write pointer has not yet been set up probably */ + { + actualPointerSettings = actualAddress; } - ext_flash_read_block(&length_lo, EF_SETTINGS); - ext_flash_read_block(&length_hi, EF_SETTINGS); + ext_flash_read_block_stop(); } - ext_flash_decf_address_ring(EF_SETTINGS); /* set pointer back to empty address */ - ext_flash_decf_address_ring(EF_SETTINGS); - ext_flash_read_block_stop(); - - if(actualAddress > actualPointerSettings) /* the write pointer has not yet been set up probably */ - { - actualPointerSettings = actualAddress; - } - ext_flash_read_block_stop(); return returnValue; } @@ -1851,6 +1878,13 @@ ringStart = FWSTART2; ringStop = FWSTOP2; break; + case EF_PROFILE0: + case EF_PROFILE1: + case EF_PROFILE2: + case EF_PROFILE3: actualAddress = actualPointerProfile; + ringStart = PROFILE0_START; + ringStop = PROFILE3_STOP; + break; default: ringStart = FLASHSTART; ringStop = FLASHSTOP; @@ -1932,6 +1966,11 @@ case EF_FIRMWARE2: actualPointerFirmware2 = actualAddress; break; + case EF_PROFILE0: + case EF_PROFILE1: + case EF_PROFILE2: + case EF_PROFILE3: actualPointerProfile = actualAddress; + break; default: break; } @@ -1996,6 +2035,13 @@ ringStart = SETTINGSSTART; ringStop = SETTINGSSTOP; break; + case EF_PROFILE0: + case EF_PROFILE1: + case EF_PROFILE2: + case EF_PROFILE3: ringStart = PROFILE0_START; + ringStop = PROFILE3_STOP; + break; + default: ringStart = FLASHSTART; ringStop = FLASHSTOP; @@ -2145,6 +2191,12 @@ ringStart = FWSTART2; ringStop = FWSTOP2; break; + case EF_PROFILE0: + case EF_PROFILE1: + case EF_PROFILE2: + case EF_PROFILE3: ringStart = PROFILE0_START; + ringStop = PROFILE3_STOP; + break; default: ringStart = FLASHSTART; ringStop = FLASHSTOP; @@ -2190,6 +2242,13 @@ ringStart = FWSTART2; ringStop = FWSTOP2; break; + case EF_PROFILE0: + case EF_PROFILE1: + case EF_PROFILE2: + case EF_PROFILE3: ringStart = PROFILE0_START; + ringStop = PROFILE3_STOP; + break; + default: ringStart = FLASHSTART; ringStop = FLASHSTOP;
--- a/Discovery/Src/logbook.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/logbook.c Mon Sep 15 21:12:44 2025 +0200 @@ -1426,7 +1426,7 @@ { pSettings->logbookOffset++; } - ext_flash_write_settings(0); + ext_flash_write_settings(EF_SETTINGS,0); ext_flash_disable_protection_for_logbook(); ext_flash_CloseSector(); /* this is just a repair function which invalidates a not used sector in case a log maintenance was called before dive */
--- a/Discovery/Src/settings.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/settings.c Mon Sep 15 21:12:44 2025 +0200 @@ -46,6 +46,8 @@ SSettings Settings; +SSettings Profile[NUMBER_OF_PROFILES]; /* may be optimized if RAM is getting short. profile copies are only used by profile dialog */ + /* static structure is used to keep things simple avoiding larger code changes */ const uint8_t RTErequiredHigh = 3; const uint8_t RTErequiredLow = 6; @@ -93,7 +95,7 @@ * There might even be entries with fixed values that have no range */ const SSettings SettingsStandard = { - .header = 0xFFFF002C, + .header = 0xFFFF002D, .warning_blink_dsec = 8 * 2, .lastDiveLogId = 0, .logFlashNextSampleStartAddress = SAMPLESTART, @@ -347,14 +349,30 @@ .slowExitTime = 0, .timeZone.hours = 0, .timeZone.minutes = 0, - .warningBuzzer = 0 + .warningBuzzer = 0, + .profileName[0] = "STANDARD", + .profileName[1] = "OC_TX___", + .profileName[2] = "MCCR____", + .profileName[3] = "ECCR____", + .activeProfile = 0, }; /* Private function prototypes -----------------------------------------------*/ uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to); +/* The profiles are store in a 4k flash block => make sure that size does not violate the size of the flash block (settings * 4) */ +_Static_assert(sizeof(Settings) < 1000, "To much settings to support multiple profiles"); + + /* Functions -----------------------------------------------------------------*/ + +uint16_t settingsGetSize() +{ + return sizeof (Settings); +} + + void setFlipDisplay(uint8_t flipDisplay) { bool settingChanged = flipDisplay != Settings.FlipDisplay; @@ -382,34 +400,49 @@ /// // =============================================================================== SSettings* pSettings; -void set_new_settings_missing_in_ext_flash(void) +void set_new_settings_missing_in_ext_flash(uint8_t whichSettings) { uint32_t tmp = 0; + pSettings = settingsGetPointer(); + switch(whichSettings) + { + default: + case EF_SETTINGS: + break; + case EF_PROFILE0: pSettings = profileGetPointer(0); + break; + case EF_PROFILE1: pSettings = profileGetPointer(1); + break; + case EF_PROFILE2: pSettings = profileGetPointer(2); + break; + case EF_PROFILE3: pSettings = profileGetPointer(3); + break; + } // never delete this part setting the serial if(hardwareDataGetPointer()->secondarySerial != 0xFFFF) { - settingsGetPointer()->serialHigh = (hardwareDataGetPointer()->secondarySerial / 256); - settingsGetPointer()->serialLow = (hardwareDataGetPointer()->secondarySerial & 0xFF); + pSettings->serialHigh = (hardwareDataGetPointer()->secondarySerial / 256); + pSettings->serialLow = (hardwareDataGetPointer()->secondarySerial & 0xFF); } else if(hardwareDataGetPointer()->primarySerial != 0xFFFF) { - settingsGetPointer()->serialHigh = (hardwareDataGetPointer()->primarySerial / 256); - settingsGetPointer()->serialLow = (hardwareDataGetPointer()->primarySerial & 0xFF); + pSettings->serialHigh = (hardwareDataGetPointer()->primarySerial / 256); + pSettings->serialLow = (hardwareDataGetPointer()->primarySerial & 0xFF); } else { - settingsGetPointer()->serialHigh = 0; - settingsGetPointer()->serialLow = 0; + pSettings->serialHigh = 0; + pSettings->serialLow = 0; } - settingsGetPointer()->firmwareVersion[0] = firmware_FirmwareData.versionFirst; - settingsGetPointer()->firmwareVersion[1] = firmware_FirmwareData.versionSecond; - settingsGetPointer()->firmwareVersion[2] = firmware_FirmwareData.versionThird; - settingsGetPointer()->firmwareVersion[3] = firmware_FirmwareData.versionBeta; + pSettings->firmwareVersion[0] = firmware_FirmwareData.versionFirst; + pSettings->firmwareVersion[1] = firmware_FirmwareData.versionSecond; + pSettings->firmwareVersion[2] = firmware_FirmwareData.versionThird; + pSettings->firmwareVersion[3] = firmware_FirmwareData.versionBeta; - pSettings = settingsGetPointer(); + const SSettings* pStandard = settingsGetPointerStandard(); /* Pointing to the old header data => set new data depending on what had been added since last version */ @@ -612,15 +645,23 @@ case 0xFFFF0028: // no break; case 0xFFFF0029: - Settings.cvAutofocus = 0; + pSettings->cvAutofocus = 0; // no break; case 0xFFFF002A: - Settings.slowExitTime = 0; + pSettings->slowExitTime = 0; // no break; case 0xFFFF002B: - Settings.timeZone.hours = 0; - Settings.timeZone.minutes = 0; - Settings.warningBuzzer = 0; + pSettings->timeZone.hours = 0; + pSettings->timeZone.minutes = 0; + pSettings->warningBuzzer = 0; + // no break; + case 0xFFFF002C: + sprintf((char*)pSettings->profileName[0],"STANDARD"); + sprintf((char*)pSettings->profileName[1],"OC_TX___"); + sprintf((char*)pSettings->profileName[2],"MCCR____"); + sprintf((char*)pSettings->profileName[3],"ECCR____"); + pSettings->activeProfile = 0; + // no break; default: pSettings->header = pStandard->header; @@ -736,7 +777,7 @@ } } -uint8_t check_and_correct_settings(void) +uint8_t check_and_correct_settings(uint8_t whichSettings) { uint32_t corrections = 0; uint8_t firstGasFoundOC = 0; @@ -747,14 +788,33 @@ settingsWarning = 0; /* reset warning indicator */ SettingsStatus.FirstCorrection = 0xFF; + pSettings = settingsGetPointer(); + + switch(whichSettings) + { + default: + case EF_SETTINGS: + break; + case EF_PROFILE0: pSettings = profileGetPointer(0); + break; + case EF_PROFILE1: pSettings = profileGetPointer(1); + break; + case EF_PROFILE2: pSettings = profileGetPointer(2); + break; + case EF_PROFILE3: pSettings = profileGetPointer(3); + break; + } + + + /* uint32_t header; */ /* uint8_t warning_blink_dsec; 1/10 seconds */ - if((Settings.warning_blink_dsec < 1) || (Settings.warning_blink_dsec > 100)) + if((pSettings->warning_blink_dsec < 1) || (pSettings->warning_blink_dsec > 100)) { - Settings.warning_blink_dsec = SettingsStandard.warning_blink_dsec; + pSettings->warning_blink_dsec = SettingsStandard.warning_blink_dsec; corrections++; setFirstCorrection(parameterId); } @@ -764,9 +824,9 @@ /* uint32_t logFlashNextSampleStartAddress; */ - if((Settings.logFlashNextSampleStartAddress < SAMPLESTART) || (Settings.logFlashNextSampleStartAddress > SAMPLESTOP)) + if((pSettings->logFlashNextSampleStartAddress < SAMPLESTART) || (pSettings->logFlashNextSampleStartAddress > SAMPLESTOP)) { - Settings.logFlashNextSampleStartAddress = SAMPLESTART; + pSettings->logFlashNextSampleStartAddress = SAMPLESTART; corrections++; setFirstCorrection(parameterId); } @@ -774,13 +834,13 @@ /* uint8_t dive_mode; has to before the gases */ - if( (Settings.dive_mode != DIVEMODE_OC) && - (Settings.dive_mode != DIVEMODE_CCR) && - (Settings.dive_mode != DIVEMODE_Gauge) && - (Settings.dive_mode != DIVEMODE_Apnea) && - (Settings.dive_mode != DIVEMODE_PSCR)) + if( (pSettings->dive_mode != DIVEMODE_OC) && + (pSettings->dive_mode != DIVEMODE_CCR) && + (pSettings->dive_mode != DIVEMODE_Gauge) && + (pSettings->dive_mode != DIVEMODE_Apnea) && + (pSettings->dive_mode != DIVEMODE_PSCR)) { - Settings.dive_mode = DIVEMODE_OC; + pSettings->dive_mode = DIVEMODE_OC; corrections++; setFirstCorrection(parameterId); } @@ -790,71 +850,71 @@ */ for(int i=1; i<=2*NUM_GASES;i++) { - if(Settings.gas[i].oxygen_percentage < 4) + if(pSettings->gas[i].oxygen_percentage < 4) { - Settings.gas[i].oxygen_percentage = 4; + pSettings->gas[i].oxygen_percentage = 4; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].oxygen_percentage > 100) + if(pSettings->gas[i].oxygen_percentage > 100) { - Settings.gas[i].oxygen_percentage = 100; + pSettings->gas[i].oxygen_percentage = 100; corrections++; setFirstCorrection(parameterId); } - if((Settings.gas[i].oxygen_percentage + Settings.gas[i].helium_percentage) > 100) + if((pSettings->gas[i].oxygen_percentage + pSettings->gas[i].helium_percentage) > 100) { - Settings.gas[i].helium_percentage = 100 - Settings.gas[i].oxygen_percentage; + pSettings->gas[i].helium_percentage = 100 - pSettings->gas[i].oxygen_percentage; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].note.ub.deco) + if(pSettings->gas[i].note.ub.deco) { - if(Settings.gas[i].note.ub.active != 1) + if(pSettings->gas[i].note.ub.active != 1) { - Settings.gas[i].note.ub.active = 1; + pSettings->gas[i].note.ub.active = 1; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].note.ub.travel == 1) + if(pSettings->gas[i].note.ub.travel == 1) { - Settings.gas[i].note.ub.travel = 0; + pSettings->gas[i].note.ub.travel = 0; corrections++; setFirstCorrection(parameterId); } } - if(Settings.gas[i].note.ub.travel) + if(pSettings->gas[i].note.ub.travel) { - if(Settings.gas[i].note.ub.active != 1) + if(pSettings->gas[i].note.ub.active != 1) { - Settings.gas[i].note.ub.active = 1; + pSettings->gas[i].note.ub.active = 1; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].note.ub.deco == 1) + if(pSettings->gas[i].note.ub.deco == 1) { - Settings.gas[i].note.ub.deco = 0; + pSettings->gas[i].note.ub.deco = 0; corrections++; setFirstCorrection(parameterId); } } - if(Settings.gas[i].note.ub.first) + if(pSettings->gas[i].note.ub.first) { - if(Settings.gas[i].note.ub.active != 1) + if(pSettings->gas[i].note.ub.active != 1) { - Settings.gas[i].note.ub.active = 1; + pSettings->gas[i].note.ub.active = 1; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].note.ub.travel == 1) + if(pSettings->gas[i].note.ub.travel == 1) { - Settings.gas[i].note.ub.travel = 0; + pSettings->gas[i].note.ub.travel = 0; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].note.ub.deco == 1) + if(pSettings->gas[i].note.ub.deco == 1) { - Settings.gas[i].note.ub.deco = 0; + pSettings->gas[i].note.ub.deco = 0; corrections++; setFirstCorrection(parameterId); } @@ -864,30 +924,30 @@ if((i>NUM_GASES) && (!firstGasFoundCCR)) firstGasFoundCCR = 1; else - Settings.gas[i].note.ub.first = 0; + pSettings->gas[i].note.ub.first = 0; } - if(Settings.gas[i].bottle_size_liter > 40) + if(pSettings->gas[i].bottle_size_liter > 40) { - Settings.gas[i].bottle_size_liter = 40; + pSettings->gas[i].bottle_size_liter = 40; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].depth_meter > 250) + if(pSettings->gas[i].depth_meter > 250) { - Settings.gas[i].depth_meter = 250; + pSettings->gas[i].depth_meter = 250; corrections++; setFirstCorrection(parameterId); } - if(Settings.gas[i].depth_meter_travel > 250) + if(pSettings->gas[i].depth_meter_travel > 250) { - Settings.gas[i].depth_meter_travel = 250; + pSettings->gas[i].depth_meter_travel = 250; corrections++; setFirstCorrection(parameterId); } - /*if(Settings.gas[i].note.ub.senderCode) + /*if(pSettings->gas[i].note.ub.senderCode) { } - if(Settings.gas[i].bottle_wireless_id) + if(pSettings->gas[i].bottle_wireless_id) { } */ @@ -895,20 +955,20 @@ parameterId++; /* 4 */ if(!firstGasFoundOC) { - Settings.gas[1].note.ub.active = 1; - Settings.gas[1].note.ub.first = 1; - Settings.gas[1].note.ub.travel = 0; - Settings.gas[1].note.ub.deco = 0; + pSettings->gas[1].note.ub.active = 1; + pSettings->gas[1].note.ub.first = 1; + pSettings->gas[1].note.ub.travel = 0; + pSettings->gas[1].note.ub.deco = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 5 */ if(!firstGasFoundCCR) { - Settings.gas[1 + NUM_GASES].note.ub.active = 1; - Settings.gas[1 + NUM_GASES].note.ub.first = 1; - Settings.gas[1 + NUM_GASES].note.ub.travel = 0; - Settings.gas[1 + NUM_GASES].note.ub.deco = 0; + pSettings->gas[1 + NUM_GASES].note.ub.active = 1; + pSettings->gas[1 + NUM_GASES].note.ub.first = 1; + pSettings->gas[1 + NUM_GASES].note.ub.travel = 0; + pSettings->gas[1 + NUM_GASES].note.ub.deco = 0; corrections++; setFirstCorrection(parameterId); } @@ -917,21 +977,21 @@ */ for(int i=1; i<=NUM_GASES;i++) { - if(Settings.setpoint[i].setpoint_cbar < MIN_PPO2_SP_CBAR) + if(pSettings->setpoint[i].setpoint_cbar < MIN_PPO2_SP_CBAR) { - Settings.setpoint[i].setpoint_cbar = MIN_PPO2_SP_CBAR; + pSettings->setpoint[i].setpoint_cbar = MIN_PPO2_SP_CBAR; corrections++; setFirstCorrection(parameterId); } - if(Settings.setpoint[i].setpoint_cbar > 160) + if(pSettings->setpoint[i].setpoint_cbar > 160) { - Settings.setpoint[i].setpoint_cbar = 160; + pSettings->setpoint[i].setpoint_cbar = 160; corrections++; setFirstCorrection(parameterId); } - if(Settings.setpoint[i].depth_meter > 250) + if(pSettings->setpoint[i].depth_meter > 250) { - Settings.setpoint[i].depth_meter = 250; + pSettings->setpoint[i].depth_meter = 250; corrections++; setFirstCorrection(parameterId); } @@ -944,44 +1004,44 @@ parameterId++; /* 8 */ /* uint8_t CCR_Mode; */ - if( (Settings.CCR_Mode != CCRMODE_Sensors) && - (Settings.CCR_Mode != CCRMODE_Simulation) && - (Settings.CCR_Mode != CCRMODE_FixedSetpoint)) + if( (pSettings->CCR_Mode != CCRMODE_Sensors) && + (pSettings->CCR_Mode != CCRMODE_Simulation) && + (pSettings->CCR_Mode != CCRMODE_FixedSetpoint)) { - Settings.CCR_Mode = CCRMODE_FixedSetpoint; + pSettings->CCR_Mode = CCRMODE_FixedSetpoint; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 9 */ /* split2x4_Type deco_type; */ - if( (Settings.deco_type.ub.standard != GF_MODE) && - (Settings.deco_type.ub.standard != VPM_MODE)) + if( (pSettings->deco_type.ub.standard != GF_MODE) && + (pSettings->deco_type.ub.standard != VPM_MODE)) { - Settings.deco_type.ub.standard = VPM_MODE; + pSettings->deco_type.ub.standard = VPM_MODE; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 10 */ - if(Settings.deco_type.ub.alternative != GF_MODE) + if(pSettings->deco_type.ub.alternative != GF_MODE) { - Settings.deco_type.ub.alternative = GF_MODE; + pSettings->deco_type.ub.alternative = GF_MODE; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 11 */ /* uint8_t ppO2_max_deco; */ - if(Settings.ppO2_max_deco > 190) + if(pSettings->ppO2_max_deco > 190) { - Settings.ppO2_max_deco = 190; + pSettings->ppO2_max_deco = 190; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 12 */ - if(Settings.ppO2_max_deco < 100) + if(pSettings->ppO2_max_deco < 100) { - Settings.ppO2_max_deco = 100; + pSettings->ppO2_max_deco = 100; corrections++; setFirstCorrection(parameterId); } @@ -989,351 +1049,351 @@ /* uint8_t ppO2_max_std; */ - if(Settings.ppO2_max_std > 190) + if(pSettings->ppO2_max_std > 190) { - Settings.ppO2_max_std = 190; + pSettings->ppO2_max_std = 190; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 14 */ - if(Settings.ppO2_max_std < 100) + if(pSettings->ppO2_max_std < 100) { - Settings.ppO2_max_std = 100; + pSettings->ppO2_max_std = 100; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 15 */ /* uint8_t ppO2_min; */ - if(Settings.ppO2_min != 15) + if(pSettings->ppO2_min != 15) { - Settings.ppO2_min = 15; + pSettings->ppO2_min = 15; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 16 */ /* uint8_t CNS_max; */ - if(Settings.CNS_max != 90) + if(pSettings->CNS_max != 90) { - Settings.CNS_max = 90; + pSettings->CNS_max = 90; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 17 */ /* uint8_t ascent_MeterPerMinute_max; */ - if(Settings.ascent_MeterPerMinute_max != 30) + if(pSettings->ascent_MeterPerMinute_max != 30) { - Settings.ascent_MeterPerMinute_max = 30; + pSettings->ascent_MeterPerMinute_max = 30; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 18 */ /* uint8_t ascent_MeterPerMinute_showGraph; */ - if(Settings.ascent_MeterPerMinute_showGraph != 30) + if(pSettings->ascent_MeterPerMinute_showGraph != 30) { - Settings.ascent_MeterPerMinute_showGraph = 30; + pSettings->ascent_MeterPerMinute_showGraph = 30; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 19 */ /* uint8_t future_TTS; */ - if(Settings.future_TTS > 15) + if(pSettings->future_TTS > 15) { - Settings.future_TTS = 15; + pSettings->future_TTS = 15; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 20 */ /* uint8_t GF_high; */ - if(Settings.GF_high > 99) + if(pSettings->GF_high > 99) { - Settings.GF_high = 99; + pSettings->GF_high = 99; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 21 */ - if(Settings.GF_high < 45) + if(pSettings->GF_high < 45) { - Settings.GF_high = 45; + pSettings->GF_high = 45; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 22 */ /* uint8_t GF_low; */ - if(Settings.GF_low > 99) + if(pSettings->GF_low > 99) { - Settings.GF_low = 99; + pSettings->GF_low = 99; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 23 */ - if(Settings.GF_low < 10) + if(pSettings->GF_low < 10) { - Settings.GF_low = 10; + pSettings->GF_low = 10; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 24 */ - if(Settings.GF_low > Settings.GF_high) + if(pSettings->GF_low > pSettings->GF_high) { - Settings.GF_low = Settings.GF_high; + pSettings->GF_low = pSettings->GF_high; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 25 */ /* uint8_t aGF_high; */ - if(Settings.aGF_high > 99) + if(pSettings->aGF_high > 99) { - Settings.aGF_high = 99; + pSettings->aGF_high = 99; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 26 */ - if(Settings.aGF_high < 45) + if(pSettings->aGF_high < 45) { - Settings.aGF_high = 45; + pSettings->aGF_high = 45; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 27 */ /* uint8_t aGF_low; */ - if(Settings.aGF_low > 99) + if(pSettings->aGF_low > 99) { - Settings.aGF_low = 99; + pSettings->aGF_low = 99; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 28 */ - if(Settings.aGF_low < 10) + if(pSettings->aGF_low < 10) { - Settings.aGF_low = 10; + pSettings->aGF_low = 10; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 29 */ - if(Settings.aGF_low > Settings.aGF_high) + if(pSettings->aGF_low > pSettings->aGF_high) { - Settings.aGF_low = Settings.aGF_high; + pSettings->aGF_low = pSettings->aGF_high; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 30 */ /* split2x4_Type VPM_conservatism; */ - if(Settings.VPM_conservatism.ub.standard > 5) + if(pSettings->VPM_conservatism.ub.standard > 5) { - Settings.VPM_conservatism.ub.standard = 5; + pSettings->VPM_conservatism.ub.standard = 5; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 31 */ - if(Settings.VPM_conservatism.ub.alternative > 5) + if(pSettings->VPM_conservatism.ub.alternative > 5) { - Settings.VPM_conservatism.ub.alternative = 5; + pSettings->VPM_conservatism.ub.alternative = 5; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 32 */ /* uint8_t safetystopDuration; */ - if(Settings.safetystopDuration > 5) + if(pSettings->safetystopDuration > 5) { - Settings.safetystopDuration = 5; + pSettings->safetystopDuration = 5; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 33 */ /* uint8_t AtemMinutenVolumenLiter; */ - if(Settings.AtemMinutenVolumenLiter != 25) + if(pSettings->AtemMinutenVolumenLiter != 25) { - Settings.AtemMinutenVolumenLiter = 25; + pSettings->AtemMinutenVolumenLiter = 25; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 34 */ /* uint8_t ReserveFractionDenominator; */ - if(Settings.ReserveFractionDenominator != 4) + if(pSettings->ReserveFractionDenominator != 4) { - Settings.ReserveFractionDenominator = 4; + pSettings->ReserveFractionDenominator = 4; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 35 */ /* uint8_t salinity; */ - if(Settings.salinity > 4) + if(pSettings->salinity > 4) { - Settings.salinity = 4; + pSettings->salinity = 4; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 36 */ /* uint8_t last_stop_depth_meter; */ - if(Settings.last_stop_depth_meter > 9) + if(pSettings->last_stop_depth_meter > 9) { - Settings.last_stop_depth_meter = 9; + pSettings->last_stop_depth_meter = 9; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 37 */ - if(Settings.last_stop_depth_meter < 3) + if(pSettings->last_stop_depth_meter < 3) { - Settings.last_stop_depth_meter = 3; + pSettings->last_stop_depth_meter = 3; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 38 */ /* uint8_t stop_increment_depth_meter; */ - if(Settings.stop_increment_depth_meter != 3) + if(pSettings->stop_increment_depth_meter != 3) { - Settings.stop_increment_depth_meter = 3; + pSettings->stop_increment_depth_meter = 3; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 39 */ /* uint8_t brightness; */ - if(Settings.brightness > 4) + if(pSettings->brightness > 4) { - Settings.brightness = 4; + pSettings->brightness = 4; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 40 */ /* uint8_t date_format; */ - if( (Settings.date_format != DDMMYY) && - (Settings.date_format != MMDDYY) && - (Settings.date_format != YYMMDD)) + if( (pSettings->date_format != DDMMYY) && + (pSettings->date_format != MMDDYY) && + (pSettings->date_format != YYMMDD)) { - Settings.date_format = DDMMYY; + pSettings->date_format = DDMMYY; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 41 */ /* uint8_t selected_language; */ - if(Settings.selected_language >= LANGUAGE_END) + if(pSettings->selected_language >= LANGUAGE_END) { - Settings.selected_language = LANGUAGE_English; + pSettings->selected_language = LANGUAGE_English; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 42 */ /* char customtext[60]; */ - if(Settings.customtext[59] != 0) + if(pSettings->customtext[59] != 0) { - Settings.customtext[59] = 0; + pSettings->customtext[59] = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 43 */ /* uint16_t timeoutSurfacemode; */ - if( (Settings.timeoutSurfacemode != 20) && // Quick Sleep Option - (Settings.timeoutSurfacemode != 120)) + if( (pSettings->timeoutSurfacemode != 20) && // Quick Sleep Option + (pSettings->timeoutSurfacemode != 120)) { - Settings.timeoutSurfacemode = 120; + pSettings->timeoutSurfacemode = 120; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 44 */ /* uint8_t timeoutMenuSurface; */ - if(Settings.timeoutMenuSurface != 120) + if(pSettings->timeoutMenuSurface != 120) { - Settings.timeoutMenuSurface = 120; + pSettings->timeoutMenuSurface = 120; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 45 */ /* uint8_t timeoutMenuDive; */ - if(Settings.timeoutMenuDive != 120) + if(pSettings->timeoutMenuDive != 120) { - Settings.timeoutMenuDive = 120; + pSettings->timeoutMenuDive = 120; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 46 */ /* uint8_t timeoutMenuEdit; */ - if(Settings.timeoutMenuEdit != 120) + if(pSettings->timeoutMenuEdit != 120) { - Settings.timeoutMenuEdit = 120; + pSettings->timeoutMenuEdit = 120; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 47 */ /* uint8_t timeoutInfo; */ - if(Settings.timeoutInfo != 120) + if(pSettings->timeoutInfo != 120) { - Settings.timeoutInfo = 120; + pSettings->timeoutInfo = 120; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 48 */ /* uint8_t timeoutInfoCompass; */ - if(Settings.timeoutInfoCompass != 60) + if(pSettings->timeoutInfoCompass != 60) { - Settings.timeoutInfoCompass = 60; + pSettings->timeoutInfoCompass = 60; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 49 */ /* uint8_t design; */ - if(Settings.design != 7) + if(pSettings->design != 7) { - Settings.design = 7; + pSettings->design = 7; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 50 */ /* uint16_t timeoutDiveReachedZeroDepth; */ - if(Settings.timeoutDiveReachedZeroDepth != 300) + if(pSettings->timeoutDiveReachedZeroDepth != 300) { - Settings.timeoutDiveReachedZeroDepth = 300; + pSettings->timeoutDiveReachedZeroDepth = 300; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 51 */ /* uint16_t divetimeToCreateLogbook; */ - if(Settings.divetimeToCreateLogbook != 60) + if(pSettings->divetimeToCreateLogbook != 60) { - Settings.divetimeToCreateLogbook = 60; + pSettings->divetimeToCreateLogbook = 60; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 52 */ - if(Settings.slowExitTime > 9) + if(pSettings->slowExitTime > 9) { - Settings.divetimeToCreateLogbook = 0; + pSettings->divetimeToCreateLogbook = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 53 */ - if(Settings.warningBuzzer > 1) + if(pSettings->warningBuzzer > 1) { - Settings.warningBuzzer = 0; + pSettings->warningBuzzer = 0; corrections++; setFirstCorrection(parameterId); } @@ -1365,28 +1425,28 @@ */ #ifdef HAVE_DEBUG_VIEW - if(Settings.showDebugInfo > 1) + if(pSettings->showDebugInfo > 1) { - Settings.showDebugInfo = 0; + pSettings->showDebugInfo = 0; corrections++; } #else - Settings.showDebugInfo = 0; + pSettings->showDebugInfo = 0; #endif /* uint8_t ButtonResponsiveness[4]; */ // Base value, index 3 - if(Settings.ButtonResponsiveness[3] < MIN_BUTTONRESPONSIVENESS_GUI) + if(pSettings->ButtonResponsiveness[3] < MIN_BUTTONRESPONSIVENESS_GUI) { - Settings.ButtonResponsiveness[3] = MIN_BUTTONRESPONSIVENESS_GUI; + pSettings->ButtonResponsiveness[3] = MIN_BUTTONRESPONSIVENESS_GUI; corrections++; setFirstCorrection(parameterId); } else - if(Settings.ButtonResponsiveness[3] > MAX_BUTTONRESPONSIVENESS_GUI) + if(pSettings->ButtonResponsiveness[3] > MAX_BUTTONRESPONSIVENESS_GUI) { - Settings.ButtonResponsiveness[3] = MAX_BUTTONRESPONSIVENESS_GUI; + pSettings->ButtonResponsiveness[3] = MAX_BUTTONRESPONSIVENESS_GUI; corrections++; setFirstCorrection(parameterId); } @@ -1394,16 +1454,16 @@ // flex values 0, 1, 2 for(int i=0; i<3;i++) { - if(Settings.ButtonResponsiveness[i] < MIN_BUTTONRESPONSIVENESS) // 50-10 //Fix for broken buttons. :) + if(pSettings->ButtonResponsiveness[i] < MIN_BUTTONRESPONSIVENESS) // 50-10 //Fix for broken buttons. :) { - Settings.ButtonResponsiveness[i] = MIN_BUTTONRESPONSIVENESS; + pSettings->ButtonResponsiveness[i] = MIN_BUTTONRESPONSIVENESS; corrections++; setFirstCorrection(parameterId); } else - if(Settings.ButtonResponsiveness[i] > MAX_BUTTONRESPONSIVENESS) // 110+20 + if(pSettings->ButtonResponsiveness[i] > MAX_BUTTONRESPONSIVENESS) // 110+20 { - Settings.ButtonResponsiveness[i] = MAX_BUTTONRESPONSIVENESS; + pSettings->ButtonResponsiveness[i] = MAX_BUTTONRESPONSIVENESS; corrections++; setFirstCorrection(parameterId); } @@ -1413,16 +1473,16 @@ */ for(int i=0; i<3;i++) { - if(Settings.buttonBalance[i] < 2) // 2 = -10 + if(pSettings->buttonBalance[i] < 2) // 2 = -10 { - Settings.buttonBalance[i] = 2; + pSettings->buttonBalance[i] = 2; corrections++; setFirstCorrection(parameterId); } else - if(Settings.buttonBalance[i] > 5) // 3 = 0, 4 = +10, 5 = +20 + if(pSettings->buttonBalance[i] > 5) // 3 = 0, 4 = +10, 5 = +20 { - Settings.buttonBalance[i] = 5; + pSettings->buttonBalance[i] = 5; corrections++; setFirstCorrection(parameterId); } @@ -1430,43 +1490,43 @@ parameterId++; /* 57 */ /* uint8_t nonMetricalSystem; */ - if(Settings.nonMetricalSystem > 1) + if(pSettings->nonMetricalSystem > 1) { - Settings.nonMetricalSystem = 1; + pSettings->nonMetricalSystem = 1; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 58 */ /* uint8_t fallbackToFixedSetpoint; */ - if(Settings.fallbackToFixedSetpoint > 1) + if(pSettings->fallbackToFixedSetpoint > 1) { - Settings.fallbackToFixedSetpoint = 1; + pSettings->fallbackToFixedSetpoint = 1; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 59 */ /* uint8_t bluetoothActive; */ - if(Settings.bluetoothActive > 1) + if(pSettings->bluetoothActive > 1) { - Settings.bluetoothActive = 1; + pSettings->bluetoothActive = 1; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 60 */ /* uint8_t safetystopDepth; */ - if(Settings.safetystopDepth > 6) + if(pSettings->safetystopDepth > 6) { - Settings.safetystopDepth = 6; + pSettings->safetystopDepth = 6; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 61 */ - if(Settings.safetystopDepth < 3) + if(pSettings->safetystopDepth < 3) { - Settings.safetystopDepth = 3; + pSettings->safetystopDepth = 3; corrections++; setFirstCorrection(parameterId); } @@ -1476,140 +1536,140 @@ /* uint8_t ppo2sensors_deactivated; */ - if(Settings.ppo2sensors_deactivated > (1+2+4)) + if(pSettings->ppo2sensors_deactivated > (1+2+4)) { - Settings.ppo2sensors_deactivated = 0; + pSettings->ppo2sensors_deactivated = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 63 */ /* uint8_t tX_colorscheme; */ - if(Settings.tX_colorscheme > 3) + if(pSettings->tX_colorscheme > 3) { - Settings.tX_colorscheme = 0; + pSettings->tX_colorscheme = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 64 */ /* uint8_t tX_userselectedLeftLowerCornerPrimary; */ - if(Settings.tX_userselectedLeftLowerCornerPrimary >= LLC_END) + if(pSettings->tX_userselectedLeftLowerCornerPrimary >= LLC_END) { - Settings.tX_userselectedLeftLowerCornerPrimary = LLC_Temperature; + pSettings->tX_userselectedLeftLowerCornerPrimary = LLC_Temperature; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 65 */ /* uint8_t tX_userselectedLeftLowerCornerTimeout; */ - if(Settings.tX_userselectedLeftLowerCornerTimeout > 60) + if(pSettings->tX_userselectedLeftLowerCornerTimeout > 60) { - Settings.tX_userselectedLeftLowerCornerTimeout = 0; + pSettings->tX_userselectedLeftLowerCornerTimeout = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 66 */ /* uint8_t tX_customViewPrimary; */ - if(Settings.tX_customViewPrimary >= CVIEW_END) + if(pSettings->tX_customViewPrimary >= CVIEW_END) { - Settings.tX_customViewPrimary = 1; + pSettings->tX_customViewPrimary = 1; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 67 */ /* uint8_t tX_customViewTimeout; */ - if(Settings.tX_customViewTimeout > 60) + if(pSettings->tX_customViewTimeout > 60) { - Settings.tX_customViewTimeout = 0; + pSettings->tX_customViewTimeout = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 68 */ /* uint8_t timeoutEnterButtonSelectDive; */ - if(Settings.timeoutEnterButtonSelectDive != 10) + if(pSettings->timeoutEnterButtonSelectDive != 10) { - Settings.timeoutEnterButtonSelectDive = 10; + pSettings->timeoutEnterButtonSelectDive = 10; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 69 */ /* uint8_t logbookOffset; */ - if(Settings.logbookOffset > 9000) + if(pSettings->logbookOffset > 9000) { - Settings.logbookOffset = 0; + pSettings->logbookOffset = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 70 */ /* uint8_t alwaysShowPPO2; */ - if(Settings.alwaysShowPPO2 > 1) + if(pSettings->alwaysShowPPO2 > 1) { - Settings.alwaysShowPPO2 = 0; + pSettings->alwaysShowPPO2 = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 71 */ /* uint8_t extraDisplay; */ - if(Settings.extraDisplay >= EXTRADISPLAY_END) + if(pSettings->extraDisplay >= EXTRADISPLAY_END) { - Settings.extraDisplay = EXTRADISPLAY_BIGFONT; + pSettings->extraDisplay = EXTRADISPLAY_BIGFONT; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 72 */ /* int8_t offsetPressure_mbar; */ - if((Settings.offsetPressure_mbar > PRESSURE_OFFSET_LIMIT_MBAR) || - (Settings.offsetPressure_mbar < -1 * PRESSURE_OFFSET_LIMIT_MBAR)) + if((pSettings->offsetPressure_mbar > PRESSURE_OFFSET_LIMIT_MBAR) || + (pSettings->offsetPressure_mbar < -1 * PRESSURE_OFFSET_LIMIT_MBAR)) { - Settings.offsetPressure_mbar = 0; + pSettings->offsetPressure_mbar = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 73 */ /* int8_t offsetTemperature_centigrad; */ - if((Settings.offsetTemperature_centigrad > 20) || - (Settings.offsetTemperature_centigrad < -20)) + if((pSettings->offsetTemperature_centigrad > 20) || + (pSettings->offsetTemperature_centigrad < -20)) { - Settings.offsetTemperature_centigrad = 0; + pSettings->offsetTemperature_centigrad = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 74 */ /* uint8_t gasConsumption_travel_l_min; */ - if((Settings.gasConsumption_travel_l_min < 5) || - (Settings.gasConsumption_travel_l_min > 50)) + if((pSettings->gasConsumption_travel_l_min < 5) || + (pSettings->gasConsumption_travel_l_min > 50)) { - Settings.gasConsumption_travel_l_min = 20; + pSettings->gasConsumption_travel_l_min = 20; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 75 */ /* uint8_t gasConsumption_bottom_l_min; */ - if((Settings.gasConsumption_bottom_l_min < 5) || - (Settings.gasConsumption_bottom_l_min > 50)) + if((pSettings->gasConsumption_bottom_l_min < 5) || + (pSettings->gasConsumption_bottom_l_min > 50)) { - Settings.gasConsumption_bottom_l_min = 20; + pSettings->gasConsumption_bottom_l_min = 20; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 76 */ /* uint8_t gasConsumption_deco_l_min; */ - if((Settings.gasConsumption_deco_l_min < 5) || - (Settings.gasConsumption_deco_l_min > 50)) + if((pSettings->gasConsumption_deco_l_min < 5) || + (pSettings->gasConsumption_deco_l_min > 50)) { - Settings.gasConsumption_deco_l_min = 20; + pSettings->gasConsumption_deco_l_min = 20; corrections++; setFirstCorrection(parameterId); } @@ -1617,38 +1677,38 @@ /* uint8_t showDebugInfo; */ #ifdef BOOT16 - Settings.showDebugInfo = 0; + pSettings->showDebugInfo = 0; #else - if(Settings.showDebugInfo > 1) - Settings.showDebugInfo = 0; + if(pSettings->showDebugInfo > 1) + pSettings->showDebugInfo = 0; #endif /* uint8_t selected_language; */ #ifdef BOOT16 - if(Settings.selected_language > 1) - Settings.selected_language = 0; + if(pSettings->selected_language > 1) + pSettings->selected_language = 0; #else - if(Settings.selected_language > 4) - Settings.selected_language = 0; + if(pSettings->selected_language > 4) + pSettings->selected_language = 0; #endif /* uint8_t display_toogle_desc; 1/10 seconds */ - if((Settings.display_toogle_desc < 20) || (Settings.display_toogle_desc > 600)) + if((pSettings->display_toogle_desc < 20) || (pSettings->display_toogle_desc > 600)) { - Settings.display_toogle_desc = SettingsStandard.display_toogle_desc; + pSettings->display_toogle_desc = SettingsStandard.display_toogle_desc; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 78 */ /* uint8_t debugModeOnStart; */ - if(Settings.debugModeOnStart > 1) + if(pSettings->debugModeOnStart > 1) { - Settings.debugModeOnStart = 0; + pSettings->debugModeOnStart = 0; corrections++; setFirstCorrection(parameterId); } @@ -1658,16 +1718,16 @@ */ if(hardwareDataGetPointer()->primarySerial == 90) - Settings.IAmStolenPleaseKillMe++; + pSettings->IAmStolenPleaseKillMe++; else - Settings.IAmStolenPleaseKillMe = 0; + pSettings->IAmStolenPleaseKillMe = 0; /* uint8_t debugModeOnStart; */ - if(Settings.compassBearing > 360) + if(pSettings->compassBearing > 360) { - Settings.compassBearing = 0; + pSettings->compassBearing = 0; corrections++; setFirstCorrection(parameterId); } @@ -1675,32 +1735,32 @@ parameterId++; /* 80 */ /* uint8_t lastKnownBatteryPercentage; */ - if(Settings.lastKnownBatteryPercentage > 100) + if(pSettings->lastKnownBatteryPercentage > 100) { - Settings.lastKnownBatteryPercentage = 100; + pSettings->lastKnownBatteryPercentage = 100; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 81 */ /* uint8_t VPM_model */ - if((Settings.VPM_model != VPM_FROM_FORTRAN) && (Settings.VPM_model != VPM_BACHELORWORK)) + if((pSettings->VPM_model != VPM_FROM_FORTRAN) && (pSettings->VPM_model != VPM_BACHELORWORK)) { - Settings.VPM_model = VPM_FROM_FORTRAN; + pSettings->VPM_model = VPM_FROM_FORTRAN; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 82 */ /* uint8_t Buehlmann_model */ - if((Settings.GF_model != BUEHLMANN_OSTC4) && (Settings.GF_model != BUEHLMANN_hwOS)) + if((pSettings->GF_model != BUEHLMANN_OSTC4) && (pSettings->GF_model != BUEHLMANN_hwOS)) { - Settings.GF_model = BUEHLMANN_OSTC4; + pSettings->GF_model = BUEHLMANN_OSTC4; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 83 */ - if(Settings.FlipDisplay > 1) /* only boolean values allowed */ + if(pSettings->FlipDisplay > 1) /* only boolean values allowed */ { setFlipDisplay(1); corrections++; @@ -1708,186 +1768,186 @@ } parameterId++; /* 84 */ #ifdef ENABLE_MOTION_CONTROL - if(Settings.MotionDetection >= MOTION_DETECT_END) + if(pSettings->MotionDetection >= MOTION_DETECT_END) { - Settings.MotionDetection = MOTION_DETECT_OFF; + pSettings->MotionDetection = MOTION_DETECT_OFF; corrections++; setFirstCorrection(parameterId); } #else - Settings.MotionDetection = MOTION_DETECT_OFF; - Settings.viewPortMode = 0; - Settings.viewRoll = 0.0; - Settings.viewPitch = 0.0; - Settings.viewYaw = 0.0; + pSettings->MotionDetection = MOTION_DETECT_OFF; + pSettings->viewPortMode = 0; + pSettings->viewRoll = 0.0; + pSettings->viewPitch = 0.0; + pSettings->viewYaw = 0.0; #endif parameterId++; /* 85 */ - if(Settings.compassInertia > MAX_COMPASS_COMP) + if(pSettings->compassInertia > MAX_COMPASS_COMP) { - Settings.compassInertia = 0; + pSettings->compassInertia = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 86 */ - if(Settings.tX_customViewPrimaryBF > CVIEW_T3_END) + if(pSettings->tX_customViewPrimaryBF > CVIEW_T3_END) { - Settings.tX_customViewPrimaryBF = CVIEW_T3_Decostop; + pSettings->tX_customViewPrimaryBF = CVIEW_T3_Decostop; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 87 */ - if(Settings.viewPortMode > MAX_VIEWPORT_MODE) + if(pSettings->viewPortMode > MAX_VIEWPORT_MODE) { - Settings.viewPortMode = 0; + pSettings->viewPortMode = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 88 */ - if(Settings.ppo2sensors_source >= O2_SENSOR_SOURCE_MAX) + if(pSettings->ppo2sensors_source >= O2_SENSOR_SOURCE_MAX) { - Settings.ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC; - Settings.ppo2sensors_calibCoeff[0] = 0.0; - Settings.ppo2sensors_calibCoeff[1] = 0.0; - Settings.ppo2sensors_calibCoeff[2] = 0.0; + pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC; + pSettings->ppo2sensors_calibCoeff[0] = 0.0; + pSettings->ppo2sensors_calibCoeff[1] = 0.0; + pSettings->ppo2sensors_calibCoeff[2] = 0.0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 89 */ - if(Settings.amPMTime > 1) /* only boolean values allowed */ + if(pSettings->amPMTime > 1) /* only boolean values allowed */ { - Settings.amPMTime = 0; + pSettings->amPMTime = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 90 */ - if(Settings.autoSetpoint > 1) /* only boolean values allowed */ + if(pSettings->autoSetpoint > 1) /* only boolean values allowed */ { - Settings.autoSetpoint = 0; + pSettings->autoSetpoint = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 91 */ - if (Settings.scrubberActiveId > 0x03) { + if (pSettings->scrubberActiveId > 0x03) { /* scrubber active is used as bitfield => two timer => 2 bits in use */ - Settings.scrubberActiveId = 0x00; + pSettings->scrubberActiveId = 0x00; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 92 */ - if((Settings.scrubberData[0].TimerMax > MAX_SCRUBBER_TIME) || Settings.scrubberData[0].TimerCur < MIN_SCRUBBER_TIME || Settings.scrubberData[0].TimerCur > (int16_t)MAX_SCRUBBER_TIME) + if((pSettings->scrubberData[0].TimerMax > MAX_SCRUBBER_TIME) || pSettings->scrubberData[0].TimerCur < MIN_SCRUBBER_TIME || pSettings->scrubberData[0].TimerCur > (int16_t)MAX_SCRUBBER_TIME) { - Settings.scrubberData[0].TimerMax = 0; - Settings.scrubberData[0].TimerCur = 0; + pSettings->scrubberData[0].TimerMax = 0; + pSettings->scrubberData[0].TimerCur = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 93 */ - if((Settings.scrubberData[1].TimerMax > MAX_SCRUBBER_TIME) || Settings.scrubberData[1].TimerCur < MIN_SCRUBBER_TIME || Settings.scrubberData[1].TimerCur > (int16_t)MAX_SCRUBBER_TIME) + if((pSettings->scrubberData[1].TimerMax > MAX_SCRUBBER_TIME) || pSettings->scrubberData[1].TimerCur < MIN_SCRUBBER_TIME || pSettings->scrubberData[1].TimerCur > (int16_t)MAX_SCRUBBER_TIME) { - Settings.scrubberData[1].TimerMax = 0; - Settings.scrubberData[1].TimerCur = 0; + pSettings->scrubberData[1].TimerMax = 0; + pSettings->scrubberData[1].TimerCur = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 94 */ - if (Settings.scrubTimerMode == INVALID_SCRUB_TIMER_OFF || Settings.scrubTimerMode > SCRUB_TIMER_END) { - Settings.scrubTimerMode = SCRUB_TIMER_MINUTES; + if (pSettings->scrubTimerMode == INVALID_SCRUB_TIMER_OFF || pSettings->scrubTimerMode > SCRUB_TIMER_END) { + pSettings->scrubTimerMode = SCRUB_TIMER_MINUTES; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 95 */ - if((Settings.pscr_lung_ratio > PSCR_MAX_LUNG_RATIO) || (Settings.pscr_lung_ratio < PSCR_MIN_LUNG_RATIO)) + if((pSettings->pscr_lung_ratio > PSCR_MAX_LUNG_RATIO) || (pSettings->pscr_lung_ratio < PSCR_MIN_LUNG_RATIO)) { - Settings.pscr_lung_ratio = 10; + pSettings->pscr_lung_ratio = 10; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 96 */ - if(Settings.pscr_o2_drop > PSCR_MAX_O2_DROP) + if(pSettings->pscr_o2_drop > PSCR_MAX_O2_DROP) { - Settings.pscr_o2_drop = 4; + pSettings->pscr_o2_drop = 4; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 97 */ - if(Settings.co2_sensor_active > 1) + if(pSettings->co2_sensor_active > 1) { - Settings.co2_sensor_active = 0; + pSettings->co2_sensor_active = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 98 */ - if(Settings.ext_uart_protocol > UART_MAX_PROTOCOL) + if(pSettings->ext_uart_protocol > UART_MAX_PROTOCOL) { - Settings.ext_uart_protocol = 0; + pSettings->ext_uart_protocol = 0; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 99 */ - if((Settings.ext_sensor_map[0] >= SENSOR_END) - || (Settings.ext_sensor_map[1] >= SENSOR_END) - || (Settings.ext_sensor_map[2] >= SENSOR_END) - || (Settings.ext_sensor_map[3] >= SENSOR_END) - || (Settings.ext_sensor_map[4] >= SENSOR_END) - || (Settings.ext_sensor_map[5] >= SENSOR_END) - || (Settings.ext_sensor_map[6] >= SENSOR_END) - || (Settings.ext_sensor_map[7] >= SENSOR_END)) + if((pSettings->ext_sensor_map[0] >= SENSOR_END) + || (pSettings->ext_sensor_map[1] >= SENSOR_END) + || (pSettings->ext_sensor_map[2] >= SENSOR_END) + || (pSettings->ext_sensor_map[3] >= SENSOR_END) + || (pSettings->ext_sensor_map[4] >= SENSOR_END) + || (pSettings->ext_sensor_map[5] >= SENSOR_END) + || (pSettings->ext_sensor_map[6] >= SENSOR_END) + || (pSettings->ext_sensor_map[7] >= SENSOR_END)) { - Settings.ext_sensor_map[0] = SENSOR_OPTIC; - Settings.ext_sensor_map[1] = SENSOR_OPTIC; - Settings.ext_sensor_map[2] = SENSOR_OPTIC; - Settings.ext_sensor_map[3] = SENSOR_NONE; - Settings.ext_sensor_map[4] = SENSOR_NONE; - Settings.ext_sensor_map[5] = SENSOR_NONE; - Settings.ext_sensor_map[6] = SENSOR_NONE; - Settings.ext_sensor_map[7] = SENSOR_NONE; + pSettings->ext_sensor_map[0] = SENSOR_OPTIC; + pSettings->ext_sensor_map[1] = SENSOR_OPTIC; + pSettings->ext_sensor_map[2] = SENSOR_OPTIC; + pSettings->ext_sensor_map[3] = SENSOR_NONE; + pSettings->ext_sensor_map[4] = SENSOR_NONE; + pSettings->ext_sensor_map[5] = SENSOR_NONE; + pSettings->ext_sensor_map[6] = SENSOR_NONE; + pSettings->ext_sensor_map[7] = SENSOR_NONE; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 100 */ - if(Settings.buttonLockActive > 1) + if(pSettings->buttonLockActive > 1) { - Settings.buttonLockActive = 1; + pSettings->buttonLockActive = 1; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 101 */ - if (Settings.compassDeclinationDeg > MAX_COMPASS_DECLINATION_DEG) { - Settings.compassDeclinationDeg = MAX_COMPASS_DECLINATION_DEG; + if (pSettings->compassDeclinationDeg > MAX_COMPASS_DECLINATION_DEG) { + pSettings->compassDeclinationDeg = MAX_COMPASS_DECLINATION_DEG; corrections++; setFirstCorrection(parameterId); - } else if (Settings.compassDeclinationDeg < -MAX_COMPASS_DECLINATION_DEG) { - Settings.compassDeclinationDeg = -MAX_COMPASS_DECLINATION_DEG; + } else if (pSettings->compassDeclinationDeg < -MAX_COMPASS_DECLINATION_DEG) { + pSettings->compassDeclinationDeg = -MAX_COMPASS_DECLINATION_DEG; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 102 */ - if (Settings.timerDurationS > 599) { - Settings.timerDurationS = 599; + if (pSettings->timerDurationS > 599) { + pSettings->timerDurationS = 599; corrections++; setFirstCorrection(parameterId); - } else if (Settings.timerDurationS < 1) { - Settings.timerDurationS = 1; + } else if (pSettings->timerDurationS < 1) { + pSettings->timerDurationS = 1; corrections++; setFirstCorrection(parameterId); } parameterId++; /* 103 */ - if(Settings.cvAutofocus > 1) + if(pSettings->cvAutofocus > 1) { corrections++; - Settings.cvAutofocus = 0; + pSettings->cvAutofocus = 0; } parameterId++; /* 104 */ - if((Settings.timeZone.hours > 14) - || (Settings.timeZone.hours < -12) - || (Settings.timeZone.minutes > 45)) + if((pSettings->timeZone.hours > 14) + || (pSettings->timeZone.hours < -12) + || (pSettings->timeZone.minutes > 45)) { - Settings.timeZone.hours = 0; - Settings.timeZone.minutes = 0; + pSettings->timeZone.hours = 0; + pSettings->timeZone.minutes = 0; corrections++; } parameterId++; /* 105 */ @@ -1957,7 +2017,17 @@ { return &Settings; } +SSettings* profileGetPointer(uint8_t number) +{ + SSettings* returnPointer = NULL; + if(number < NUMBER_OF_PROFILES) + { + returnPointer = &Profile[number]; + } + + return returnPointer; +} // =============================================================================== // set_settings_to_Standard @@ -1971,7 +2041,7 @@ /// 160622 added lastDiveLogIdBackup /// // =============================================================================== -void set_settings_to_Standard(void) +void set_settings_to_Standard(uint8_t whichSettings) { SSettings *pSettings; const SSettings *pSettingsStandard; @@ -1980,6 +2050,22 @@ uint32_t sampleStartBackup; pSettings = settingsGetPointer(); pSettingsStandard = settingsGetPointerStandard(); + uint8_t profileBackup = pSettings->activeProfile; + + switch(whichSettings) + { + default: + case EF_SETTINGS: + break; + case EF_PROFILE0: pSettings = profileGetPointer(0); + break; + case EF_PROFILE1: pSettings = profileGetPointer(1); + break; + case EF_PROFILE2: pSettings = profileGetPointer(2); + break; + case EF_PROFILE3: pSettings = profileGetPointer(3); + break; + } personalDiveCountBackup = pSettings->personalDiveCount; lastDiveLogIdBackup = pSettings->lastDiveLogId; @@ -1999,8 +2085,26 @@ sprintf(pSettings->customtext," <your name>\n <address>"); pSettings->cv_configuration &= ~(1 << CVIEW_sensors | 1 << CVIEW_sensors_mV | 1 << CVIEW_Timer); - set_new_settings_missing_in_ext_flash(); - check_and_correct_settings(); + switch(whichSettings) /* some default data may be dependend on the default value => adapt setting */ + { + default: + case EF_SETTINGS: pSettings->activeProfile = profileBackup; + break; + case EF_PROFILE0: pSettings = profileGetPointer(0); + break; + case EF_PROFILE1: pSettings = profileGetPointer(1); + break; + case EF_PROFILE2: pSettings = profileGetPointer(2); /* MCCR */ + pSettings->dive_mode = DIVEMODE_CCR; + break; + case EF_PROFILE3: pSettings = profileGetPointer(3); /* ECCR */ + pSettings->dive_mode = DIVEMODE_CCR; + pSettings->CCR_Mode = CCRMODE_Sensors; + break; + } + + set_new_settings_missing_in_ext_flash(whichSettings); + check_and_correct_settings(whichSettings); // has to be called too: createDiveSettings(); } @@ -3413,3 +3517,4 @@ return false; } +
--- a/Discovery/Src/t3.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/t3.c Mon Sep 15 21:12:44 2025 +0200 @@ -537,13 +537,13 @@ else { color = 0xff; - if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter)) + if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter) && (stateUsed->lifeData.depth_meter > 0.3)) { color = t3_drawSlowExitGraph(tXscreen, tXl1, tXr1); } if(color == 0xff) /* no slow exit => continue with common ascent graph */ { - if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) /* ascentrate graph -standard mode */ + if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) /* ascent rate graph -standard mode */ { if(!pSettings->FlipDisplay) {
--- a/Discovery/Src/t7.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/t7.c Mon Sep 15 21:12:44 2025 +0200 @@ -2834,7 +2834,7 @@ /* ascent rate graph */ color = 0xff; - if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter)) + if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter) && (stateUsed->lifeData.depth_meter > 0.3)) { color = t7_drawSlowExitGraph(); }
--- a/Discovery/Src/tComm.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/tComm.c Mon Sep 15 21:12:44 2025 +0200 @@ -328,7 +328,7 @@ #ifndef BOOTLOADER_STANDALONE if(updateSettingsAndMenuOnExit) { - check_and_correct_settings(); + check_and_correct_settings(EF_SETTINGS); createDiveSettings(); tM_rebuild_menu_after_tComm(); } @@ -1183,7 +1183,7 @@ #ifndef BOOTLOADER_STANDALONE //Reset all setting case 0x78: - set_settings_to_Standard(); + set_settings_to_Standard(EF_SETTINGS); updateSettingsAndMenuOnExit = 1; aTxBuffer[count++] = prompt4D4C(receiveStartByteUart); break;
--- a/Discovery/Src/tMenu.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/tMenu.c Mon Sep 15 21:12:44 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,12 @@ 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)) +#ifdef ENABLE_SETTING_PROFILES + || (line == get_lineOfID(StMSYS_Profile))) +#else + ) +#endif { tM_rebuild_pages(); menu.lineMemoryForNavigationForPage[page] = line; // fix 160623
--- a/Discovery/Src/tMenuEdit.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/tMenuEdit.c Mon Sep 15 21:12:44 2025 +0200 @@ -47,6 +47,9 @@ /* Private types -------------------------------------------------------------*/ #define TEXTSIZE 16 +#define IDENT_MAY_INPUT_NUM 4 /* legacy value of ident.input struct */ +#define IDENT_MAX_INPUT_TEXT 9 /* 8 data items + 0 for string operations */ + typedef struct { uint32_t pEventFunction; @@ -64,9 +67,9 @@ { char orgText[32]; char newText[32]; - uint32_t input[4]; + uint32_t input[IDENT_MAX_INPUT_TEXT]; uint16_t coord[3]; - int8_t begin[4], size[4]; + int8_t begin[IDENT_MAX_INPUT_TEXT], size[IDENT_MAX_INPUT_TEXT]; tFont *fontUsed; uint32_t callerID; uint8_t maintype; @@ -86,6 +89,7 @@ FIELD_3DIGIT, FIELD_SDIGIT, FIELD_FLOAT, + FIELD_TEXT, FIELD_END } SField; @@ -290,7 +294,7 @@ { reset_SettingWarning(); GFX_logoAutoOff(); - ext_flash_write_settings(0); + ext_flash_write_settings(EF_SETTINGS,0); WriteSettings = 0; } } @@ -448,7 +452,7 @@ return 1; } - if(((block + 1) < 4) && (ident[actualId].size[block+1] > 0)) + if((((block + 1) < 4) || ((ident[actualId].maintype == FIELD_TEXT) && ((block + 1) < IDENT_MAX_INPUT_TEXT))) && (ident[actualId].size[block+1] > 0)) { block++; subBlockPosition = 0; @@ -482,7 +486,7 @@ content += ident[actualId].newText[ident[actualId].begin[block] + 1]; } else - if(ident[actualId].maintype == FIELD_NUMBERS) + if((ident[actualId].maintype == FIELD_NUMBERS) || (ident[actualId].maintype == FIELD_TEXT)) content = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition]; else if((ident[actualId].maintype == FIELD_ON_OFF) || (ident[actualId].maintype == FIELD_TOGGLE)) @@ -501,7 +505,7 @@ if(event[actualevid].callerID != ident[actualId].callerID) return; - if(ident[actualId].maintype == FIELD_NUMBERS) + if((ident[actualId].maintype == FIELD_NUMBERS) || (ident[actualId].maintype == FIELD_TEXT)) { oneCharText[0] = ident[actualId].newText[ident[actualId].begin[oldblock] + oldsubblockpos]; oneCharText[1] = 0; @@ -553,18 +557,34 @@ void mark_new_digit_of_actual_id_block_and_subBlock(void) { char oneCharText[2]; + char text[10]; uint16_t positionOffset; + uint8_t index = 0; + uint8_t textPos = 0; if(event[actualevid].callerID != ident[actualId].callerID) return; - if(ident[actualId].maintype == FIELD_NUMBERS) + if((ident[actualId].maintype == FIELD_NUMBERS) || (ident[actualId].maintype == FIELD_TEXT)) { oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition]; oneCharText[1] = 0; positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + subBlockPosition); write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit); } + if(ident[actualId].maintype == FIELD_TEXT) /* letter width may change from character to character => output end of string */ + { + if(block + 1 < 8) + { + for(index = block + 1; index < 8; index++) + { + text[textPos++] = ident[actualId].newText[ident[actualId].begin[index] + 0]; + } + text[textPos] = 0; + positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block + 1] + subBlockPosition); + write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, text, CLUT_MenuEditFieldSelected); + } + } } @@ -588,7 +608,7 @@ block = 0; subBlockPosition = 0; - if(ident[actualId].maintype == FIELD_NUMBERS) + if((ident[actualId].maintype == FIELD_NUMBERS) || (ident[actualId].maintype == FIELD_TEXT)) { change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black @@ -696,7 +716,13 @@ break; case FIELD_SELECT: write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); + break; + case FIELD_TEXT: + write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); + if((newContent >= 'A') && (newContent <= '_')) + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; + mark_new_digit_of_actual_id_block_and_subBlock(); break; } } @@ -821,6 +847,9 @@ else if((ident[actualId].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; + else + if((ident[actualId].maintype == FIELD_TEXT) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; if(action == ACTION_BUTTON_ENTER) { @@ -917,6 +946,10 @@ ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; } + if ((ident[actualId].maintype == FIELD_TEXT) && (newContent >= 'A' && newContent <= '_')) + { + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; + } mark_new_digit_of_actual_id_block_and_subBlock(); } @@ -956,6 +989,9 @@ } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; } + if ((ident[actualId].maintype == FIELD_TEXT) && (newContent >= 'A' && newContent <= '_')) { + ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent; + } mark_new_digit_of_actual_id_block_and_subBlock(); } @@ -1024,7 +1060,27 @@ *pNewValue3 = sum[2]; *pNewValue4 = sum[3]; } +void evaluateNewStringText(uint32_t editID, uint8_t *pNewString) +{ + if(editID != ident[actualId].callerID) + return; + uint8_t i, digitCount; + uint8_t digit = '_'; + + memset(pNewString, 0 , IDENT_MAX_INPUT_TEXT); + + i = 0; + while( ident[actualId].size[i] && (i < IDENT_MAX_INPUT_TEXT - 1)) + { + for(digitCount = 0; digitCount < ident[actualId].size[i]; digitCount++) + { + digit = ident[actualId].newText[ident[actualId].begin[i] + digitCount]; + } + pNewString[i] = digit; + i++; + } +} uint8_t get_id_of(uint32_t editID) { @@ -1162,7 +1218,38 @@ id = backup_id; } +void tMenuEdit_newInputText(uint32_t editID, uint8_t* ptext) +{ + uint8_t backup_id, temp_id; + uint8_t index = 0; + temp_id = get_id_of(editID); + if(temp_id == 255) + return; + + backup_id = id; + id = temp_id; + + if(editID != ident[id].callerID) + { + temp_id = 0; + while((temp_id < IDENT_MAX_INPUT_TEXT) && (editID != ident[temp_id].callerID)) + temp_id++; + if(editID != ident[temp_id].callerID) + return; + id = temp_id; + } + for(index = 0; index < IDENT_MAX_INPUT_TEXT; index++) + { + ident[id].input[index] = *ptext++; + } + create_newText_for_Id(id); + if(id <= idLast) + change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); + write_content_of_Id(id); + + id = backup_id; +} void resetEnterPressedToStateBeforeButtonAction(void) { @@ -1263,6 +1350,20 @@ } } +void create_newText_for_Id_and_field_text(int8_t localId) +{ + uint8_t i; + + i = 0; + while( ident[localId].size[i] && (i < 9)) + { + if(ident[localId].input[i]) + ident[localId].newText[ident[localId].begin[i]] = ident[localId].input[i]; + i++; + } +} + + void create_newText_for_actual_Id_and_field_select(void) { create_newText_for_Id_and_field_select(actualId); @@ -1282,6 +1383,12 @@ return; } + if( ident[localId].maintype == FIELD_TEXT) + { + create_newText_for_Id_and_field_text(localId); + return; + } + while( ident[localId].size[i] && (i < 4)) { bool isNegative = false; @@ -1449,6 +1556,66 @@ write_field_udigit_and_2digit(FIELD_SDIGIT, editID, XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text, ((input_u)int1).uint32, ((input_u)int2).uint32, ((input_u)int3).uint32, ((input_u)int4).uint32); } +void write_field_text(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t* pInput) +{ + if(id >= 9) + return; + + int8_t beginTmp; + + ident[id].maintype = FIELD_TEXT; + ident[id].subtype = FIELD_TEXT; + + 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; + + for(int i=0;i < IDENT_MAX_INPUT_TEXT -1;i++) + { + ident[id].input[i] = pInput[i]; + ident[id].size[i] = 0; + } + pInput[8] = 0; + + beginTmp = 0; + for(int i=0;i < IDENT_MAX_INPUT_TEXT;i++) + { + while((ident[id].orgText[beginTmp] != '#')&& ident[id].orgText[beginTmp]) + beginTmp++; + + if(ident[id].orgText[beginTmp] == '#') + { + + ident[id].begin[i] = beginTmp; + ident[id].size[i] = 1; + beginTmp = ident[id].begin[i] + ident[id].size[i]; + } + else + break; + } + + change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); + + create_newText_for_Id(id); + + if(editID == 0) + write_content_without_Id(); + else + { + write_content_of_Id(id); + if(!tME_stop) + idLast = id; + id++; + } +} + void write_field_select(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1, uint8_t int2, uint8_t int3, uint8_t int4) {
--- a/Discovery/Src/tMenuEditSystem.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/tMenuEditSystem.c Mon Sep 15 21:12:44 2025 +0200 @@ -46,12 +46,19 @@ /*#define HAVE_DEBUG_VIEW */ static uint8_t infoPage = 0; +#ifdef ENABLE_SETTING_PROFILES +static uint32_t profileStartCrc[NUMBER_OF_PROFILES]; +static uint8_t profileActiveStart = 0; +#endif /* Private function prototypes -----------------------------------------------*/ void openEdit_DateTime(void); void openEdit_DateFormat(void); void openEdit_Language(void); void openEdit_Design(void); +#ifdef ENABLE_SETTING_PROFILES +void openEdit_Profile(void); +#endif void openEdit_Information(void); void openEdit_Reset(void); void openEdit_Maintenance(void); @@ -94,7 +101,10 @@ uint8_t OnAction_Units (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Colorscheme (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_DebugInfo (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); - +#ifdef ENABLE_SETTING_PROFILES +uint8_t OnAction_Profile(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +uint8_t OnAction_SetProfile(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +#endif uint8_t OnAction_Exit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Confirm (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Maintenance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); @@ -131,25 +141,33 @@ if(actual_menu_content == MENU_SURFACE) { - switch(line) - { - case 1: - default: - openEdit_DateTime(); - break; - case 2: - openEdit_Language(); - break; - case 3: - openEdit_Design(); - break; - case 4: - openEdit_Information(); - break; - case 5: - openEdit_Reset(); - break; - } + + if(line == get_lineOfID(StMSYS1_DateTime)) + { + openEdit_DateTime(); + } + else if(line == get_lineOfID(StMSYS2_English)) + { + openEdit_Language(); + } + else if(line == get_lineOfID(StMSYS3_Units)) + { + openEdit_Design(); + } + else if(line == get_lineOfID(StMSYS4_Info)) + { + openEdit_Information(); + } + else if(line == get_lineOfID(StMSYS5_ResetAll)) + { + openEdit_Reset(); + } +#ifdef ENABLE_SETTING_PROFILES + else if(line == get_lineOfID(StMSYS_Profile)) + { + openEdit_Profile(); + } +#endif } else { @@ -909,10 +927,131 @@ #endif } +#ifdef ENABLE_SETTING_PROFILES +void changeActiveProfil(uint8_t newProfile) +{ + SSettings *pSettings = settingsGetPointer(); + SSettings* pOldProfile = profileGetPointer(pSettings->activeProfile); + SSettings* pNewProfile = profileGetPointer(newProfile); + uint16_t personalDiveCountBackup; + uint8_t lastDiveLogIdBackup; + uint32_t sampleStartBackup; + char customTextBackup[60]; + + if( newProfile < NUMBER_OF_PROFILES) + { + /* some data needs to be the same in all profiles => make backup before gettings the new profile */ + personalDiveCountBackup = pSettings->personalDiveCount; + lastDiveLogIdBackup = pSettings->lastDiveLogId; + sampleStartBackup = pSettings->logFlashNextSampleStartAddress; + memcpy(customTextBackup, pSettings->customtext, 60); + + + memcpy(pOldProfile,pSettings,sizeof(SSettings)); + memcpy(pSettings,pNewProfile,sizeof(SSettings)); + + set_new_settings_missing_in_ext_flash(EF_PROFILE0 + newProfile); + check_and_correct_settings(EF_PROFILE0 + newProfile); + + pSettings->personalDiveCount = personalDiveCountBackup; + pSettings->lastDiveLogId = lastDiveLogIdBackup; + pSettings->logFlashNextSampleStartAddress = sampleStartBackup; + + pSettings->firmwareVersion[0] = firmware_FirmwareData.versionFirst; + pSettings->firmwareVersion[1] = firmware_FirmwareData.versionSecond; + pSettings->firmwareVersion[2] = firmware_FirmwareData.versionThird; + pSettings->firmwareVersion[3] = firmware_FirmwareData.versionBeta; + + memcpy(pSettings->customtext, customTextBackup, 60); + + if(pOldProfile->tX_colorscheme != pSettings->tX_colorscheme) + { + GFX_use_colorscheme(pSettings->tX_colorscheme); + tHome_init_compass(); + } + } +} + +void exitMenuProfil() +{ + uint8_t index = 0; + SSettings* pProfile; + uint8_t writeFlash = 0; + uint32_t profileExitCrc; + + for(index = 0; index < NUMBER_OF_PROFILES; index++) + { + pProfile = profileGetPointer(index); + profileExitCrc = CalcFletcher32((uint32_t)pProfile, (uint32_t)pProfile + sizeof(SSettings)); + + if(profileExitCrc != profileStartCrc[index]) + { + writeFlash = 1; + break; + } + } + if(writeFlash) + { + for(index = EF_PROFILE0; index <= EF_PROFILE3; index++) + ext_flash_write_settings(index,0); + } + if(profileActiveStart != settingsGetPointer()->activeProfile) + { + createDiveSettings(); + } + exitMenuEdit(1); +} +#endif +#ifdef ENABLE_SETTING_PROFILES +void openEdit_Profile(void) +{ + char text[50]; + uint8_t index = 0; + SSettings *pSettings = settingsGetPointer(); + SSettings* pProfile; + + setBackMenu((uint32_t)exitMenuProfil,0,0); + + profileActiveStart = pSettings->activeProfile; + +/* read profiles from flash */ + for(index = EF_PROFILE0; index <= EF_PROFILE3; index++) + { + set_settings_to_Standard(index); /* this is needed because details like header version are used by the read block function */ + ext_flash_read_settings(index); /* will overwrite standard settings if reading is successfull */ + pProfile = profileGetPointer(index - EF_PROFILE0); + profileStartCrc[index - EF_PROFILE0] = CalcFletcher32((uint32_t)pProfile, (uint32_t)pProfile + sizeof(SSettings)); + set_new_settings_missing_in_ext_flash(index); + check_and_correct_settings(index); + } + + sprintf(text,"\001%c%c",TXT_2BYTE,TXT2BYTE_Profile); + write_topline(text); + + sprintf(text,"%c %c%c:",TXT_Active,TXT_2BYTE,TXT2BYTE_Profile); + write_label_var( 30, 300, ME_Y_LINE1, &FontT48, text); + sprintf(text,"%s",pSettings->profileName[pSettings->activeProfile]); + write_field_button(StMSYS_Profile, 400, 700, ME_Y_LINE1, &FontT48, text); + write_field_text(StMSYS_ProfileA, 400, 700, ME_Y_LINE3, &FontT48, "########", pSettings->profileName[0]); + write_field_text(StMSYS_ProfileB, 400, 700, ME_Y_LINE4, &FontT48, "########", pSettings->profileName[1]); + write_field_text(StMSYS_ProfileC, 400, 700, ME_Y_LINE5, &FontT48, "########", pSettings->profileName[2]); + write_field_text(StMSYS_ProfileD, 400, 700, ME_Y_LINE6, &FontT48, "########", pSettings->profileName[3]); + + setEvent(StMSYS_Profile, (uint32_t)OnAction_SetProfile); + setEvent(StMSYS_ProfileA, (uint32_t)OnAction_Profile); + setEvent(StMSYS_ProfileB, (uint32_t)OnAction_Profile); + setEvent(StMSYS_ProfileC, (uint32_t)OnAction_Profile); + setEvent(StMSYS_ProfileD, (uint32_t)OnAction_Profile); + + write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); +} +#endif + void refresh_Design(void) { - char text[32]; + char text[32]; + SSettings *pSettings = settingsGetPointer(); // header text[0] = '\001'; @@ -927,7 +1066,7 @@ text[2] = 0; write_label_var( 30, 200, ME_Y_LINE1, &FontT48, text); - if(settingsGetPointer()->nonMetricalSystem) + if(pSettings->nonMetricalSystem) { text[1] = TXT2BYTE_Units_feet; } @@ -943,7 +1082,7 @@ text[2] = 0; write_label_var( 30, 300, ME_Y_LINE2, &FontT48, text); - text[0] = '0' + settingsGetPointer()->tX_colorscheme; + text[0] = '0' + pSettings->tX_colorscheme; text[1] = 0; write_label_var( 400, 700, ME_Y_LINE2, &FontT48, text); @@ -1004,8 +1143,103 @@ return UPDATE_DIVESETTINGS; } +#ifdef ENABLE_SETTING_PROFILES +uint8_t OnAction_SetProfile(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + SSettings *pSettings = settingsGetPointer(); + uint8_t newProfile = pSettings->activeProfile + 1; + if(newProfile == NUMBER_OF_PROFILES) + { + newProfile = 0; + } + changeActiveProfil(newProfile); + pSettings->activeProfile = newProfile; + + tMenuEdit_newButtonText(editId,(char*)pSettings->profileName[pSettings->activeProfile]); + return UNSPECIFIC_RETURN; +} + +uint8_t OnAction_Profile(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + SSettings *pSettings = settingsGetPointer(); + SSettings *pProfile; + uint8_t digitContentNew; + uint8_t profilName[9]; + uint8_t updateProfilIndex = 0; + uint8_t index = 0; + + uint8_t returnValue = UNSPECIFIC_RETURN; + + switch (editId) + { + default: + case StMSYS_ProfileA: updateProfilIndex = 0; + break; + case StMSYS_ProfileB: updateProfilIndex = 1; + break; + case StMSYS_ProfileC: updateProfilIndex = 2; + break; + case StMSYS_ProfileD: updateProfilIndex = 3; + break; + } + + switch (action) + { + case ACTION_BUTTON_ENTER: returnValue = digitContent; + break; + case ACTION_BUTTON_ENTER_FINAL: + { + evaluateNewStringText(editId, profilName); + tMenuEdit_newInputText(editId, profilName); + if(pSettings->activeProfile == updateProfilIndex) + { + tMenuEdit_newButtonText(StMSYS_Profile, (char*)profilName); + } + strcpy((char*)pSettings->profileName[updateProfilIndex],(char*)profilName); + for (index = 0; index < NUMBER_OF_PROFILES; index++) + { + pProfile = profileGetPointer(index); + strcpy((char*)pProfile->profileName[updateProfilIndex],(char*)profilName); + } + } + + break; + case ACTION_BUTTON_NEXT: + if(digitContent == 'Z') + { + digitContentNew = '_'; + } + else if (digitContent == '_') + { + digitContentNew = 'A'; + } + else + { + digitContentNew = digitContent + 1; + } + returnValue = digitContentNew; + break; + case ACTION_BUTTON_BACK: + if(digitContent == 'A') + { + digitContentNew = '_'; + } + else if (digitContent == '_') + { + digitContentNew = 'Z'; + } + else + { + digitContentNew = digitContent - 1; + } + returnValue = digitContentNew; + break; + } + return returnValue; +} +#endif /* uint8_t OnAction_Design_t7ft (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) @@ -1574,8 +1808,8 @@ uint8_t OnAction_ResetAll (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { - set_settings_to_Standard(); - check_and_correct_settings(); + set_settings_to_Standard(EF_SETTINGS); + check_and_correct_settings(EF_SETTINGS); return UPDATE_AND_EXIT_TO_HOME; }
--- a/Discovery/Src/tMenuSystem.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Discovery/Src/tMenuSystem.c Mon Sep 15 21:12:44 2025 +0200 @@ -145,8 +145,22 @@ strcpy(&text[textPointer],"\n\r"); textPointer += 2; } - +#ifdef ENABLE_SETTING_PROFILES + if((line == 0) || (line == 2)) + { + textPointer += snprintf(&text[textPointer], 40,"%c%c:\t%s\n\r",TXT_2BYTE,TXT2BYTE_Profile,data->profileName[data->activeProfile]); + } + else + { + strcpy(&text[textPointer],"\n\r"); + textPointer += 2; + } +#endif +#ifdef ENABLE_SETTING_PROFILES if((line == 0) || (line == 3)) +#else + if((line == 0) || (line == 2)) +#endif { text[textPointer++] = TXT_Language; text[textPointer++] = '\t'; @@ -160,8 +174,11 @@ strcpy(&text[textPointer],"\n\r"); textPointer += 2; } - +#ifdef ENABLE_SETTING_PROFILES if((line == 0) || (line == 4)) +#else + if((line == 0) || (line == 3)) +#endif { text[textPointer++] = TXT_2BYTE; text[textPointer++] = TXT2BYTE_Layout; @@ -234,7 +251,11 @@ textPointer += 2; } +#ifdef ENABLE_SETTING_PROFILES if((line == 0) || (line == 5)) +#else + if((line == 0) || (line == 4)) +#endif { text[textPointer++] = TXT_Information; text[textPointer++] = '\t'; @@ -249,7 +270,11 @@ strcpy(&text[textPointer],"\n\r"); textPointer += 2; +#ifdef ENABLE_SETTING_PROFILES if((line == 0) || (line == 6)) +#else + if((line == 0) || (line == 5)) +#endif { text[textPointer++] = TXT_2BYTE; text[textPointer++] = TXT2BYTE_ResetMenu;
--- a/FontPack/base_upperRegion.c Sun Aug 10 15:28:59 2025 +0200 +++ b/FontPack/base_upperRegion.c Mon Sep 15 21:12:44 2025 +0200 @@ -83,32 +83,6 @@ .magic[3] = FIRMWARE_MAGIC_END }; - -const SFirmwareData font_CustomData __attribute__(( section(".font_custom_data") )) = -{ - .versionFirst = 1, - .versionSecond = 0, - .versionThird = 0, - .versionBeta = 0, - - /* 4 bytes, including trailing 0 */ - .signature = "im", - - .release_year = 18, - .release_month = 10, - .release_day = 04, - .release_sub = 0, - - /* max 48, including trailing 0 */ - .release_info ="FontPack extension", - - /* for safety reasons and coming functions */ - .magic[0] = FIRMWARE_MAGIC_FIRST, - .magic[1] = FIRMWARE_MAGIC_SECOND, - .magic[2] = FIRMWARE_MAGIC_FONT, /* the magic byte for fonts*/ - .magic[3] = FIRMWARE_MAGIC_END -}; - ////////////////////////////////////////////////////////////////////////////// #ifdef BUILD_LIBRARY
--- a/Small_CPU/Inc/gpio.h Sun Aug 10 15:28:59 2025 +0200 +++ b/Small_CPU/Inc/gpio.h Mon Sep 15 21:12:44 2025 +0200 @@ -52,6 +52,7 @@ uint8_t GPIO_GetVersion(void); void GPIO_Activate_V2(void); +void GPIO_Init_V2(void); void GPIO_HandleBuzzer(); #endif #ifdef __cplusplus
--- a/Small_CPU/Src/baseCPU2.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Small_CPU/Src/baseCPU2.c Mon Sep 15 21:12:44 2025 +0200 @@ -285,8 +285,6 @@ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); MX_RTC_init(); - GPIO_LEDs_VIBRATION_Init(); - GPIO_GNSS_Init(); GPIO_new_DEBUG_Init(); // added 170322 hw initGlobals(); @@ -528,7 +526,6 @@ externalInterface_SwitchPower33(false); if (hasExternalClock()) SystemClock_Config_HSI(); - GPIO_LEDs_VIBRATION_Init(); sleep_prepare(); while(time_elapsed_ms(shutdownTick,HAL_GetTick()) < 1000 ) /* delay shutdown till shutdown animation is finished */ @@ -537,6 +534,8 @@ } shutdownTick = 0; scheduleSleepMode(); + + /* wakeup starts here */ if (hasExternalClock()) SystemClock_Config_HSE(); EXTI_Wakeup_Button_DeInit(); @@ -555,8 +554,7 @@ externalInterface_SwitchPower33(true); } externalInterface_InitDatastruct(); - MX_USART6_UART_Init(); - GNSS_Init(&GNSS_Handle, &huart6); + GPIO_Init_V2(); // EXTILine0_Button_DeInit(); not now, later after testing break; } @@ -885,6 +883,9 @@ } void sleep_prepare(void) { + + GPIO_InitTypeDef GPIO_InitStruct; + EXTI_Wakeup_Button_Init(); compass_sleep(); @@ -897,7 +898,12 @@ MX_SPI3_DeInit(); ADCx_DeInit(); - GPIO_InitTypeDef GPIO_InitStruct; + if(GPIO_GetVersion() > 0) + { + GPIO_LED_GREEN_OFF(); + GPIO_LED_RED_OFF(); + GPIO_VIBRATION_OFF(); + } __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); @@ -909,35 +915,29 @@ GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init( GPIOH, &GPIO_InitStruct); + #ifdef ENABLE_SLEEP_DEBUG GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9); /* debug */ #endif -/* +#ifdef ENABLE_GNSS_INTERN GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN | GPS_BCKP_CONTROL_PIN); +#else + GPIO_InitStruct.Pin = GPIO_PIN_All; +#endif HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); -*/ + GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( MAINCPU_CONTROL_PIN | CHARGE_OUT_PIN | EXT33V_CONTROL_PIN); /* power off & charger in & charge out & OSC32 & ext33Volt */ - HAL_GPIO_Init( GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | VIBRATION_CONTROL_PIN | LED_CONTROL_PIN_RED | LED_CONTROL_PIN_GREEN); + GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 ); /* could be added for debug purpose: | VIBRATION_CONTROL_PIN | LED_CONTROL_PIN_RED | LED_CONTROL_PIN_GREEN */ #ifdef ENABLE_SLEEP_DEBUG GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | GPIO_PIN_13 | GPIO_PIN_14); /* wake up button & debug */ #endif HAL_GPIO_Init( GPIOA, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_All; - HAL_GPIO_Init( GPIOH, &GPIO_InitStruct); - GPIO_Power_MainCPU_OFF(); - if(GPIO_GetVersion() > 0) - { - GPIO_LED_GREEN_OFF(); - GPIO_LED_RED_OFF(); - GPIO_VIBRATION_OFF(); - } #ifdef ENABLE_GNSS_INTERN if(GPIO_GetVersion() > 0) { @@ -947,9 +947,9 @@ } #endif #ifndef ENABLE_SLEEP_DEBUG -/* +#ifndef ENABLE_GNSS_INTERN __HAL_RCC_GPIOB_CLK_DISABLE(); -*/ +#endif #endif __HAL_RCC_GPIOH_CLK_DISABLE(); }
--- a/Small_CPU/Src/gpio.c Sun Aug 10 15:28:59 2025 +0200 +++ b/Small_CPU/Src/gpio.c Mon Sep 15 21:12:44 2025 +0200 @@ -183,15 +183,21 @@ { if(GPIO_Version == 0) { - GPIO_Version = 1; - GPIO_LEDs_VIBRATION_Init(); + GPIO_Version = 1; + } +} +void GPIO_Init_V2(void) +{ + if(GPIO_Version == 1) + { + GPIO_LEDs_VIBRATION_Init(); #ifdef ENABLE_GNSS_INTERN - GNSS_IO_init(); - GPIO_GPS_ON(); - GPIO_GPS_BCKP_ON(); - MX_USART6_UART_Init(); - GNSS_Init(&GNSS_Handle, &huart6); + GNSS_IO_init(); + GPIO_GPS_ON(); + GPIO_GPS_BCKP_ON(); + MX_USART6_UART_Init(); + GNSS_Init(&GNSS_Handle, &huart6); #endif } }
