# HG changeset patch # User Ideenmodellierer # Date 1757264624 -7200 # Node ID 158100a84ebdd8b56e3cc6c861201a3d610e416e # Parent 5fedf7ba239262947c909ff0a823389686b2e251 New profile feature: In the past the OSTC provide just one instance for settings. If for example a diver switched from OC to CCR configuration several settings had to be modified. To improve this and to be more flexible in adapting the OSTC to differend dive scenarions the usage of up to 4 profiles has beem introduced. The profiles are copies of the common settings but stored in a separate, previously not used, flash section => no impact to existings settings handling. For access to the profiles the existing setting flash functions are reused. To enable this a parameter war introduced which defines the target of the operation (common settings or profiles). diff -r 5fedf7ba2392 -r 158100a84ebd Common/Inc/settings.h --- a/Common/Inc/settings.h Sun Sep 07 18:55:45 2025 +0200 +++ b/Common/Inc/settings.h Sun Sep 07 19:03: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); diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Inc/externLogbookFlash.h --- a/Discovery/Inc/externLogbookFlash.h Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Inc/externLogbookFlash.h Sun Sep 07 19:03: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); diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Inc/tStructure.h --- a/Discovery/Inc/tStructure.h Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Inc/tStructure.h Sun Sep 07 19:03:44 2025 +0200 @@ -313,34 +313,44 @@ #define StMSYS1_GNSSDT _MB(2,8,1,5,0) #define StMSYS1_ZONE _MB(2,8,1,6,0) -#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) -#define StMSYS2_Italian _MB(2,8,2,4,0) -#define StMSYS2_Espanol _MB(2,8,2,5,0) +#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 StMSYS3_Units _MB(2,8,3,1,0) -#define StMSYS3_Colors _MB(2,8,3,2,0) -#define StMSYS3_Debug _MB(2,8,3,3,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 StMSYS4_Info _MB(2,8,4,1,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 StMSYS5_Exit _MB(2,8,5,1,0) -#define StMSYS5_LogbookOffset _MB(2,8,5,7,0) -#define StMSYS5_ResetAll _MB(2,8,5,2,0) -#define StMSYS5_ResetDeco _MB(2,8,5,3,0) -#define StMSYS5_Reboot _MB(2,8,5,4,0) -#define StMSYS5_Maintenance _MB(2,8,5,5,0) -#define StMSYS5_ResetLogbook _MB(2,8,5,6,0) -#define StMSYS5_SetBattCharge _MB(2,8,5,7,0) -#define StMSYS5_RebootRTE _MB(2,8,5,8,0) -#define StMSYS5_RebootMainCPU _MB(2,8,5,9,0) -#define StMSYS5_ScreenTest _MB(2,8,5,10,0) -#define StMSYS5_SetFactoryBC _MB(2,8,5,11,0) -#define StMSYS5_ResetBluetooth _MB(2,8,5,12,0) -#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) + #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) + + #define StMSYS_Custom0 _MB(2,8,1,0,0) #define StMSYS_Custom1 _MB(2,8,2,0,0) diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Src/externLogbookFlash.c --- a/Discovery/Src/externLogbookFlash.c Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Src/externLogbookFlash.c Sun Sep 07 19:03: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; diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Src/logbook.c --- a/Discovery/Src/logbook.c Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Src/logbook.c Sun Sep 07 19:03: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 */ diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Src/settings.c --- a/Discovery/Src/settings.c Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Src/settings.c Sun Sep 07 19:03: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," \n
"); 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; } + diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Src/tComm.c --- a/Discovery/Src/tComm.c Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Src/tComm.c Sun Sep 07 19:03: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; diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Src/tMenuEditSystem.c --- a/Discovery/Src/tMenuEditSystem.c Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Src/tMenuEditSystem.c Sun Sep 07 19:03:44 2025 +0200 @@ -46,12 +46,16 @@ /*#define HAVE_DEBUG_VIEW */ static uint8_t infoPage = 0; +static uint32_t profileStartCrc[NUMBER_OF_PROFILES]; +static uint8_t profileActiveStart = 0; + /* Private function prototypes -----------------------------------------------*/ void openEdit_DateTime(void); void openEdit_DateFormat(void); void openEdit_Language(void); void openEdit_Design(void); +void openEdit_Profile(void); void openEdit_Information(void); void openEdit_Reset(void); void openEdit_Maintenance(void); @@ -94,6 +98,8 @@ 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); +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); 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); @@ -138,17 +144,21 @@ openEdit_DateTime(); break; case 2: - openEdit_Language(); + openEdit_Profile(); break; case 3: - openEdit_Design(); + openEdit_Language(); break; case 4: - openEdit_Information(); + openEdit_Design(); break; case 5: + openEdit_Information(); + break; + case 6: openEdit_Reset(); break; + } } else @@ -909,10 +919,129 @@ #endif } +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); +} + +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); +} + + void refresh_Design(void) { - char text[32]; + char text[32]; + SSettings *pSettings = settingsGetPointer(); // header text[0] = '\001'; @@ -927,7 +1056,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,10 +1072,20 @@ 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); +#if 0 + /* profile */ + sprintf(text,"Profile:"); + write_label_var( 30, 300, ME_Y_LINE3, &FontT48, text); + + memset(text,0, sizeof(text)); + sprintf(text,"%s",pSettings->profileName[pSettings->activeProfile]); + tMenuEdit_newInputText(StMSYS_Profile,(uint8_t*)text); + // write_label_var( 400, 700, ME_Y_LINE3, &FontT48, text); +#endif #ifdef HAVE_DEBUG_VIEW // specials text[0] = TXT_2BYTE; @@ -1004,7 +1143,100 @@ return UPDATE_DIVESETTINGS; } +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; +} /* @@ -1574,8 +1806,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; } diff -r 5fedf7ba2392 -r 158100a84ebd Discovery/Src/tMenuSystem.c --- a/Discovery/Src/tMenuSystem.c Sun Sep 07 18:55:45 2025 +0200 +++ b/Discovery/Src/tMenuSystem.c Sun Sep 07 19:03:44 2025 +0200 @@ -146,6 +146,15 @@ textPointer += 2; } + 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; + } if((line == 0) || (line == 3)) { text[textPointer++] = TXT_Language;