comparison Discovery/Src/settings.c @ 387:0dbb74be972f

Merged in Ideenmodellierer/ostc4/MotionDetection (pull request #34) MotionDetection
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Sun, 24 Nov 2019 15:46:58 +0000
parents 14fd5f35cb50
children ebc2b571a0b9
comparison
equal deleted inserted replaced
358:c6a084d1433f 387:0dbb74be972f
30 #include "settings.h" 30 #include "settings.h"
31 #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS 31 #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS
32 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP 32 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP
33 #include "text_multilanguage.h" // for LANGUAGE_END 33 #include "text_multilanguage.h" // for LANGUAGE_END
34 #include "tHome.h" // for CVIEW_END 34 #include "tHome.h" // for CVIEW_END
35 #include "Motion.h"
35 36
36 SSettings Settings; 37 SSettings Settings;
37 38
38 const uint8_t RTErequiredHigh = 1; 39 const uint8_t RTErequiredHigh = 1;
39 const uint8_t RTErequiredLow = 9; 40 const uint8_t RTErequiredLow = 9;
80 81
81 /* always adjust check_and_correct_settings() accordingly 82 /* always adjust check_and_correct_settings() accordingly
82 * There might even be entries with fixed values that have no range 83 * There might even be entries with fixed values that have no range
83 */ 84 */
84 const SSettings SettingsStandard = { 85 const SSettings SettingsStandard = {
85 .header = 0xFFFF0019, 86 .header = 0xFFFF001A,
86 .warning_blink_dsec = 8 * 2, 87 .warning_blink_dsec = 8 * 2,
87 .lastDiveLogId = 0, 88 .lastDiveLogId = 0,
88 .logFlashNextSampleStartAddress = 0, 89 .logFlashNextSampleStartAddress = 0,
89 90
90 .gas[0].oxygen_percentage = 21, 91 .gas[0].oxygen_percentage = 21,
305 .FactoryButtonBalance[0] = 3, 306 .FactoryButtonBalance[0] = 3,
306 .FactoryButtonBalance[1] = 3, 307 .FactoryButtonBalance[1] = 3,
307 .FactoryButtonBalance[2] = 3, 308 .FactoryButtonBalance[2] = 3,
308 .FlipDisplay = 0, 309 .FlipDisplay = 0,
309 .cv_configuration = 0xFFFFFFFF, 310 .cv_configuration = 0xFFFFFFFF,
311 .MotionDetection = MOTION_DETECT_OFF,
310 }; 312 };
311 313
312 /* Private function prototypes -----------------------------------------------*/ 314 /* Private function prototypes -----------------------------------------------*/
313 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to); 315 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to);
314 316
351 SSettings* pSettings = settingsGetPointer(); 353 SSettings* pSettings = settingsGetPointer();
352 const SSettings* pStandard = settingsGetPointerStandard(); 354 const SSettings* pStandard = settingsGetPointerStandard();
353 355
354 pSettings->scooterControl = 0; 356 pSettings->scooterControl = 0;
355 357
358 /* Pointing to the old header data => set new data depending on what had been added since last version */
356 switch(pSettings->header) 359 switch(pSettings->header)
357 { 360 {
358 case 0xFFFF0000: 361 case 0xFFFF0000:
359 case 0xFFFF0001: 362 case 0xFFFF0001:
360 case 0xFFFF0002: 363 case 0xFFFF0002:
448 pSettings->FlipDisplay = 0; 451 pSettings->FlipDisplay = 0;
449 // no break 452 // no break
450 case 0xFFFF0018: 453 case 0xFFFF0018:
451 pSettings->cv_configuration = 0xFFFFFFFF; 454 pSettings->cv_configuration = 0xFFFFFFFF;
452 // no break 455 // no break
456 case 0xFFFF0019:
457 pSettings->MotionDetection = MOTION_DETECT_OFF;
458 // no break
453 default: 459 default:
454 pSettings->header = pStandard->header; 460 pSettings->header = pStandard->header;
455 break; // no break before!! 461 break; // no break before!!
456 } 462 }
457 } 463 }
1345 if(Settings.FlipDisplay > 1) /* only boolean values allowed */ 1351 if(Settings.FlipDisplay > 1) /* only boolean values allowed */
1346 { 1352 {
1347 Settings.FlipDisplay = 0; 1353 Settings.FlipDisplay = 0;
1348 corrections++; 1354 corrections++;
1349 } 1355 }
1356 if(Settings.MotionDetection >= MOTION_DETECT_END)
1357 {
1358 Settings.MotionDetection = MOTION_DETECT_OFF;
1359 corrections++;
1360 }
1350 1361
1351 if(corrections > 255) 1362 if(corrections > 255)
1352 return 255; 1363 return 255;
1353 else 1364 else
1354 return (uint8_t)corrections; 1365 return (uint8_t)corrections;
1397 uint8_t firmwareVersion_16bit_low(void) 1408 uint8_t firmwareVersion_16bit_low(void)
1398 { 1409 {
1399 return ((firmware_FirmwareData.versionSecond & 0x03) << 6) + ((firmware_FirmwareData.versionThird & 0x1F) << 1) + (firmware_FirmwareData.versionBeta & 0x01); 1410 return ((firmware_FirmwareData.versionSecond & 0x03) << 6) + ((firmware_FirmwareData.versionThird & 0x1F) << 1) + (firmware_FirmwareData.versionBeta & 0x01);
1400 } 1411 }
1401 1412
1402 SSettings* settingsGetPointer(void) 1413 inline SSettings* settingsGetPointer(void)
1403 { 1414 {
1404 return &Settings; 1415 return &Settings;
1405 } 1416 }
1406 1417
1407 1418