comparison Discovery/Src/settings.c @ 981:c6c781a2e85b default

Merge into default
author heinrichsweikamp
date Tue, 11 Feb 2025 18:12:00 +0100
parents 79b522fbabe6
children 22d5b477c903
comparison
equal deleted inserted replaced
871:f7318457df4d 981:c6c781a2e85b
41 static SSettingsStatus SettingsStatus; /* Structure containing number of corrections and first occurrence */ 41 static SSettingsStatus SettingsStatus; /* Structure containing number of corrections and first occurrence */
42 42
43 SSettings Settings; 43 SSettings Settings;
44 44
45 const uint8_t RTErequiredHigh = 3; 45 const uint8_t RTErequiredHigh = 3;
46 const uint8_t RTErequiredLow = 2; 46 const uint8_t RTErequiredLow = 4;
47 47
48 const uint8_t FONTrequiredHigh = 1; 48 const uint8_t FONTrequiredHigh = 1;
49 const uint8_t FONTrequiredLow = 0; 49 const uint8_t FONTrequiredLow = 0;
50 50
51 uint8_t RTEactualHigh = 0; 51 uint8_t RTEactualHigh = 0;
60 60
61 const SFirmwareData firmware_FirmwareData __attribute__( (section(".firmware_firmware_data")) ) = 61 const SFirmwareData firmware_FirmwareData __attribute__( (section(".firmware_firmware_data")) ) =
62 { 62 {
63 .versionFirst = 1, 63 .versionFirst = 1,
64 .versionSecond = 6, 64 .versionSecond = 6,
65 .versionThird = 5, 65 .versionThird = 9,
66 .versionBeta = 0, 66 .versionBeta = 0,
67 67
68 /* 4 bytes with trailing 0 */ 68 /* 4 bytes with trailing 0 */
69 .signature = "mh", 69 .signature = "mh",
70 70
71 .release_year = 23, 71 .release_year = 25,
72 .release_month = 8, 72 .release_month = 1,
73 .release_day = 26, 73 .release_day = 18,
74 .release_sub = 0, 74 .release_sub = 0,
75 75
76 /* max 48 with trailing 0 */ 76 /* max 48 with trailing 0 */
77 //release_info ="12345678901234567890123456789012345678901" 77 //release_info ="12345678901234567890123456789012345678901"
78 .release_info ="gcc_2nd", 78 .release_info ="gcc_2nd",
87 87
88 /* always adjust check_and_correct_settings() accordingly 88 /* always adjust check_and_correct_settings() accordingly
89 * There might even be entries with fixed values that have no range 89 * There might even be entries with fixed values that have no range
90 */ 90 */
91 const SSettings SettingsStandard = { 91 const SSettings SettingsStandard = {
92 .header = 0xFFFF0028, 92 .header = 0xFFFF002C,
93 .warning_blink_dsec = 8 * 2, 93 .warning_blink_dsec = 8 * 2,
94 .lastDiveLogId = 0, 94 .lastDiveLogId = 0,
95 .logFlashNextSampleStartAddress = SAMPLESTART, 95 .logFlashNextSampleStartAddress = SAMPLESTART,
96 96
97 .gas[0].oxygen_percentage = 21, 97 .gas[0].oxygen_percentage = 21,
337 .ext_sensor_map[7] = SENSOR_NONE, 337 .ext_sensor_map[7] = SENSOR_NONE,
338 .buttonLockActive = 0, 338 .buttonLockActive = 0,
339 .compassDeclinationDeg = 0, 339 .compassDeclinationDeg = 0,
340 .delaySetpointLow = false, 340 .delaySetpointLow = false,
341 .timerDurationS = 180, 341 .timerDurationS = 180,
342 .cvAutofocus = 0,
343 .slowExitTime = 0,
344 .timeZone.hours = 0,
345 .timeZone.minutes = 0,
346 .warningBuzzer = 0
342 }; 347 };
343 348
344 /* Private function prototypes -----------------------------------------------*/ 349 /* Private function prototypes -----------------------------------------------*/
345 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to); 350 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to);
346 351
579 } 584 }
580 } 585 }
581 pSettings->cv_config_BigScreen = pSettings->cv_config_BigScreen >> (LEGACY_T3_START_ID_PRE_TIMER - 3); 586 pSettings->cv_config_BigScreen = pSettings->cv_config_BigScreen >> (LEGACY_T3_START_ID_PRE_TIMER - 3);
582 pSettings->cv_config_BigScreen &= ~0x00000007; /* just to be sure: clear lower three bits */ 587 pSettings->cv_config_BigScreen &= ~0x00000007; /* just to be sure: clear lower three bits */
583 pSettings->cv_config_BigScreen |= tmp; 588 pSettings->cv_config_BigScreen |= tmp;
584 589 // no break;
590 case 0xFFFF0028:
591 #ifdef ENABLE_DECOCALC_OPTION
592 /* In previous version deco gases were automatically used for deco calculation */
593 for(tmp=1; tmp<=2*NUM_GASES; tmp++) /* This is now handled by an additional parameter. Set it to true to maintain same behavior as before */
594 {
595 if(Settings.gas[tmp].note.ub.deco)
596 {
597 Settings.gas[tmp].note.ub.decocalc = 1;
598 }
599 else
600 {
601 Settings.gas[tmp].note.ub.decocalc = 0;
602 }
603 }
604 #endif
605 // no break;
606 case 0xFFFF0029:
607 Settings.cvAutofocus = 0;
608 // no break;
609 case 0xFFFF002A:
610 Settings.slowExitTime = 0;
611 // no break;
612 case 0xFFFF002B:
613 Settings.timeZone.hours = 0;
614 Settings.timeZone.minutes = 0;
615 Settings.warningBuzzer = 0;
585 // no break; 616 // no break;
586 default: 617 default:
587 pSettings->header = pStandard->header; 618 pSettings->header = pStandard->header;
588 break; // no break before!! 619 break; // no break before!!
589 } 620 }
1282 Settings.divetimeToCreateLogbook = 60; 1313 Settings.divetimeToCreateLogbook = 60;
1283 corrections++; 1314 corrections++;
1284 setFirstCorrection(parameterId); 1315 setFirstCorrection(parameterId);
1285 } 1316 }
1286 parameterId++; 1317 parameterId++;
1318 if(Settings.slowExitTime > 9)
1319 {
1320 Settings.divetimeToCreateLogbook = 0;
1321 corrections++;
1322 setFirstCorrection(parameterId);
1323 }
1324 parameterId++;
1325
1326 if(Settings.warningBuzzer > 1)
1327 {
1328 Settings.warningBuzzer = 0;
1329 corrections++;
1330 setFirstCorrection(parameterId);
1331 }
1332 parameterId++;
1333
1334
1287 /* uint8_t serialHigh; 1335 /* uint8_t serialHigh;
1288 */ 1336 */
1289 1337
1290 /* uint8_t serialLow; 1338 /* uint8_t serialLow;
1291 */ 1339 */
1819 1867
1820 corrections++; 1868 corrections++;
1821 setFirstCorrection(parameterId); 1869 setFirstCorrection(parameterId);
1822 } 1870 }
1823 parameterId++; 1871 parameterId++;
1872 if(Settings.cvAutofocus > 1)
1873 {
1874 corrections++;
1875 Settings.cvAutofocus = 0;
1876 }
1877 parameterId++;
1878 if((Settings.timeZone.hours > 14)
1879 || (Settings.timeZone.hours < -12)
1880 || (Settings.timeZone.minutes > 45))
1881 {
1882 Settings.timeZone.hours = 0;
1883 Settings.timeZone.minutes = 0;
1884 corrections++;
1885 }
1886 parameterId++;
1824 if(corrections) 1887 if(corrections)
1825 { 1888 {
1826 settingsWarning = 1; 1889 settingsWarning = 1;
1827 } 1890 }
1828 else 1891 else
1834 1897
1835 SettingsStatus.Corrections = corrections; 1898 SettingsStatus.Corrections = corrections;
1836 return (uint8_t)corrections; 1899 return (uint8_t)corrections;
1837 } 1900 }
1838 1901
1839 1902 #ifndef BOOTLOADER_STANDALONE
1840 /* always at 0x8080000, do not move -> bootloader access */ 1903 /* always at 0x8080000, do not move -> bootloader access */
1841 const SFirmwareData* firmwareDataGetPointer(void) 1904 const SFirmwareData* firmwareDataGetPointer(void)
1842 { 1905 {
1843 return &firmware_FirmwareData; 1906 return &firmware_FirmwareData;
1844 } 1907 }
1848 const SHardwareData* hardwareDataGetPointer(void) 1911 const SHardwareData* hardwareDataGetPointer(void)
1849 { 1912 {
1850 return (SHardwareData *)HARDWAREDATA_ADDRESS; 1913 return (SHardwareData *)HARDWAREDATA_ADDRESS;
1851 } 1914 }
1852 #endif 1915 #endif
1853 1916 #endif
1854 const SSettings* settingsGetPointerStandard(void) 1917 const SSettings* settingsGetPointerStandard(void)
1855 { 1918 {
1856 return &SettingsStandard; 1919 return &SettingsStandard;
1857 } 1920 }
1858 1921
2987 { 3050 {
2988 RTEactualHigh = high; 3051 RTEactualHigh = high;
2989 RTEactualLow = low; 3052 RTEactualLow = low;
2990 } 3053 }
2991 3054
2992 3055 #ifndef BOOTLOADER_STANDALONE
2993 void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow) 3056 void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow)
2994 { 3057 {
2995 if(RTEhigh && RTElow) 3058 if(RTEhigh && RTElow)
2996 { 3059 {
2997 *RTEhigh = RTEactualHigh; 3060 *RTEhigh = RTEactualHigh;
3007 3070
3008 uint8_t getLicence(void) 3071 uint8_t getLicence(void)
3009 { 3072 {
3010 return hardwareDataGetPointer()->primaryLicence; 3073 return hardwareDataGetPointer()->primaryLicence;
3011 } 3074 }
3012 3075 #endif
3013 3076
3014 void firmwareGetDate(RTC_DateTypeDef *SdateOutput) 3077 void firmwareGetDate(RTC_DateTypeDef *SdateOutput)
3015 { 3078 {
3016 SdateOutput->Year = firmwareDataGetPointer()->release_year; 3079 SdateOutput->Year = firmwareDataGetPointer()->release_year;
3017 SdateOutput->Month = firmwareDataGetPointer()->release_month; 3080 SdateOutput->Month = firmwareDataGetPointer()->release_month;