Mercurial > public > ostc4
comparison Discovery/Src/settings.c @ 662:1b995079c045 Betatest
PSCR Mode
author | heinrichs weikamp |
---|---|
date | Tue, 14 Dec 2021 15:36:10 +0100 |
parents | 9513a92b293b |
children | 12d029f38430 |
comparison
equal
deleted
inserted
replaced
661:87bee7cc77b3 | 662:1b995079c045 |
---|---|
34 #include "tHome.h" // for CVIEW_END | 34 #include "tHome.h" // for CVIEW_END |
35 #include "motion.h" | 35 #include "motion.h" |
36 #include "t7.h" | 36 #include "t7.h" |
37 #include "data_central.h" | 37 #include "data_central.h" |
38 | 38 |
39 static uint8_t settingsWarning = 0; /* Active if setting values have been corrected */ | |
40 | |
39 SSettings Settings; | 41 SSettings Settings; |
40 | 42 |
41 const uint8_t RTErequiredHigh = 2; | 43 const uint8_t RTErequiredHigh = 2; |
42 const uint8_t RTErequiredLow = 7; | 44 const uint8_t RTErequiredLow = 7; |
43 | 45 |
83 | 85 |
84 /* always adjust check_and_correct_settings() accordingly | 86 /* always adjust check_and_correct_settings() accordingly |
85 * There might even be entries with fixed values that have no range | 87 * There might even be entries with fixed values that have no range |
86 */ | 88 */ |
87 const SSettings SettingsStandard = { | 89 const SSettings SettingsStandard = { |
88 .header = 0xFFFF001F, | 90 .header = 0xFFFF0021, |
89 .warning_blink_dsec = 8 * 2, | 91 .warning_blink_dsec = 8 * 2, |
90 .lastDiveLogId = 0, | 92 .lastDiveLogId = 0, |
91 .logFlashNextSampleStartAddress = 0, | 93 .logFlashNextSampleStartAddress = SAMPLESTART, |
92 | 94 |
93 .gas[0].oxygen_percentage = 21, | 95 .gas[0].oxygen_percentage = 21, |
94 .gas[1].oxygen_percentage = 21, | 96 .gas[1].oxygen_percentage = 21, |
95 .gas[2].oxygen_percentage = 21, | 97 .gas[2].oxygen_percentage = 21, |
96 .gas[3].oxygen_percentage = 21, | 98 .gas[3].oxygen_percentage = 21, |
217 .ppO2_max_deco = 160, | 219 .ppO2_max_deco = 160, |
218 .ppO2_max_std = 140, | 220 .ppO2_max_std = 140, |
219 .ppO2_min = 15, | 221 .ppO2_min = 15, |
220 .CNS_max = 90, | 222 .CNS_max = 90, |
221 .ascent_MeterPerMinute_max = 30, | 223 .ascent_MeterPerMinute_max = 30, |
222 .ascent_MeterPerMinute_showGraph = 7, | 224 .ascent_MeterPerMinute_showGraph = 30, |
223 .future_TTS = 5, | 225 .future_TTS = 5, |
224 .GF_high = 85, | 226 .GF_high = 85, |
225 .GF_low = 30, | 227 .GF_low = 30, |
226 .aGF_high = 95, | 228 .aGF_high = 95, |
227 .aGF_low = 95, | 229 .aGF_low = 95, |
266 .nonMetricalSystem = 0, | 268 .nonMetricalSystem = 0, |
267 .fallbackToFixedSetpoint = 1, | 269 .fallbackToFixedSetpoint = 1, |
268 .bluetoothActive = 0, | 270 .bluetoothActive = 0, |
269 .safetystopDepth = 5, | 271 .safetystopDepth = 5, |
270 .updateSettingsAllowedFromHeader = 0xFFFF0002, | 272 .updateSettingsAllowedFromHeader = 0xFFFF0002, |
271 .scooterControl = 0, | 273 .pscr_lung_ratio = 10, |
272 .scooterDrag = 2, | 274 .pscr_o2_drop = 4, |
273 .scooterLoad = 2, | 275 .co2_sensor_active = 0, |
274 .scooterNumberOfBatteries = 1, | |
275 .scooterBattSize = 760, | |
276 .scooterSPARE1[0] = 0, | |
277 .scooterSPARE2[0] = 0, | |
278 .ppo2sensors_deactivated = 0, | 276 .ppo2sensors_deactivated = 0, |
279 .tX_colorscheme = 0, | 277 .tX_colorscheme = 0, |
280 .tX_userselectedLeftLowerCornerPrimary = LLC_Temperature, | 278 .tX_userselectedLeftLowerCornerPrimary = LLC_Temperature, |
281 .tX_userselectedLeftLowerCornerTimeout = 0, | 279 .tX_userselectedLeftLowerCornerTimeout = 0, |
282 .tX_customViewPrimary = 1, | 280 .tX_customViewPrimary = 1, |
368 settingsGetPointer()->firmwareVersion[2] = firmware_FirmwareData.versionThird; | 366 settingsGetPointer()->firmwareVersion[2] = firmware_FirmwareData.versionThird; |
369 settingsGetPointer()->firmwareVersion[3] = firmware_FirmwareData.versionBeta; | 367 settingsGetPointer()->firmwareVersion[3] = firmware_FirmwareData.versionBeta; |
370 | 368 |
371 SSettings* pSettings = settingsGetPointer(); | 369 SSettings* pSettings = settingsGetPointer(); |
372 const SSettings* pStandard = settingsGetPointerStandard(); | 370 const SSettings* pStandard = settingsGetPointerStandard(); |
373 | |
374 pSettings->scooterControl = 0; | |
375 | 371 |
376 /* Pointing to the old header data => set new data depending on what had been added since last version */ | 372 /* Pointing to the old header data => set new data depending on what had been added since last version */ |
377 switch(pSettings->header) | 373 switch(pSettings->header) |
378 { | 374 { |
379 case 0xFFFF0000: | 375 case 0xFFFF0000: |
431 pSettings->debugModeOnStart = 0; | 427 pSettings->debugModeOnStart = 0; |
432 // no break | 428 // no break |
433 case 0xFFFF000F: | 429 case 0xFFFF000F: |
434 pSettings->compassBearing = 0; | 430 pSettings->compassBearing = 0; |
435 // no break | 431 // no break |
436 case 0xFFFF0010: | |
437 pSettings->scooterDrag = 2; | |
438 pSettings->scooterLoad = 2; | |
439 pSettings->scooterSPARE1[0] = 0; | |
440 pSettings->scooterSPARE2[0] = 0; | |
441 // no break | |
442 case 0xFFFF0011: | 432 case 0xFFFF0011: |
443 pSettings->scooterNumberOfBatteries = 1; | |
444 pSettings->scooterBattSize = 760; | |
445 pSettings->lastKnownBatteryPercentage = 0; | 433 pSettings->lastKnownBatteryPercentage = 0; |
446 // no break | 434 // no break |
447 case 0xFFFF0012: | 435 case 0xFFFF0012: |
448 pSettings->buttonBalance[0] = 3; | 436 pSettings->buttonBalance[0] = 3; |
449 pSettings->buttonBalance[1] = 3; | 437 pSettings->buttonBalance[1] = 3; |
494 case 0xFFFF001D: | 482 case 0xFFFF001D: |
495 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC; | 483 pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC; |
496 pSettings->ppo2sensors_calibCoeff[0] = 0.0; | 484 pSettings->ppo2sensors_calibCoeff[0] = 0.0; |
497 pSettings->ppo2sensors_calibCoeff[1] = 0.0; | 485 pSettings->ppo2sensors_calibCoeff[1] = 0.0; |
498 pSettings->ppo2sensors_calibCoeff[2] = 0.0; | 486 pSettings->ppo2sensors_calibCoeff[2] = 0.0; |
487 pSettings->amPMTime = 0; | |
499 // no break | 488 // no break |
489 case 0xFFFF001E: | |
490 pSettings->autoSetpoint = 0; | |
491 pSettings->scrubTimerMax = 0; | |
492 pSettings->scrubTimerCur = 0; | |
493 pSettings->scrubTimerMode = SCRUB_TIMER_OFF; | |
494 // no break | |
495 case 0xFFFF001F: | |
496 pSettings->pscr_lung_ratio = 10; | |
497 pSettings->pscr_o2_drop = 4; | |
498 // no break | |
499 case 0xFFFF0020: | |
500 pSettings->co2_sensor_active = 0; | |
501 // no break; | |
500 default: | 502 default: |
501 pSettings->header = pStandard->header; | 503 pSettings->header = pStandard->header; |
502 break; // no break before!! | 504 break; // no break before!! |
503 } | 505 } |
504 } | 506 } |
534 { | 536 { |
535 uint32_t corrections = 0; | 537 uint32_t corrections = 0; |
536 uint8_t firstGasFoundOC = 0; | 538 uint8_t firstGasFoundOC = 0; |
537 uint8_t firstGasFoundCCR = 0; | 539 uint8_t firstGasFoundCCR = 0; |
538 | 540 |
541 | |
542 settingsWarning = 0; /* reset warning indicator */ | |
543 | |
539 /* uint32_t header; | 544 /* uint32_t header; |
540 */ | 545 */ |
541 | 546 |
542 /* uint8_t warning_blink_dsec; 1/10 seconds | 547 /* uint8_t warning_blink_dsec; 1/10 seconds |
543 */ | 548 */ |
562 /* uint8_t dive_mode; has to before the gases | 567 /* uint8_t dive_mode; has to before the gases |
563 */ | 568 */ |
564 if( (Settings.dive_mode != DIVEMODE_OC) && | 569 if( (Settings.dive_mode != DIVEMODE_OC) && |
565 (Settings.dive_mode != DIVEMODE_CCR) && | 570 (Settings.dive_mode != DIVEMODE_CCR) && |
566 (Settings.dive_mode != DIVEMODE_Gauge) && | 571 (Settings.dive_mode != DIVEMODE_Gauge) && |
567 (Settings.dive_mode != DIVEMODE_Apnea) ) | 572 (Settings.dive_mode != DIVEMODE_Apnea) && |
573 (Settings.dive_mode != DIVEMODE_PSCR)) | |
568 { | 574 { |
569 Settings.dive_mode = DIVEMODE_OC; | 575 Settings.dive_mode = DIVEMODE_OC; |
570 corrections++; | 576 corrections++; |
571 } | 577 } |
572 | 578 |
616 corrections++; | 622 corrections++; |
617 } | 623 } |
618 } | 624 } |
619 if(Settings.gas[i].note.ub.first) | 625 if(Settings.gas[i].note.ub.first) |
620 { | 626 { |
621 if(Settings.setpoint[i].note.ub.active != 1) | 627 if(Settings.gas[i].note.ub.active != 1) |
622 { | 628 { |
623 Settings.setpoint[i].note.ub.active = 1; | 629 Settings.gas[i].note.ub.active = 1; |
624 corrections++; | 630 corrections++; |
625 } | 631 } |
626 if(Settings.gas[i].note.ub.travel == 1) | 632 if(Settings.gas[i].note.ub.travel == 1) |
627 { | 633 { |
628 Settings.gas[i].note.ub.travel = 0; | 634 Settings.gas[i].note.ub.travel = 0; |
669 { | 675 { |
670 Settings.gas[1].note.ub.active = 1; | 676 Settings.gas[1].note.ub.active = 1; |
671 Settings.gas[1].note.ub.first = 1; | 677 Settings.gas[1].note.ub.first = 1; |
672 Settings.gas[1].note.ub.travel = 0; | 678 Settings.gas[1].note.ub.travel = 0; |
673 Settings.gas[1].note.ub.deco = 0; | 679 Settings.gas[1].note.ub.deco = 0; |
680 corrections++; | |
674 } | 681 } |
675 if(!firstGasFoundCCR) | 682 if(!firstGasFoundCCR) |
676 { | 683 { |
677 Settings.gas[1 + NUM_GASES].note.ub.active = 1; | 684 Settings.gas[1 + NUM_GASES].note.ub.active = 1; |
678 Settings.gas[1 + NUM_GASES].note.ub.first = 1; | 685 Settings.gas[1 + NUM_GASES].note.ub.first = 1; |
679 Settings.gas[1 + NUM_GASES].note.ub.travel = 0; | 686 Settings.gas[1 + NUM_GASES].note.ub.travel = 0; |
680 Settings.gas[1 + NUM_GASES].note.ub.deco = 0; | 687 Settings.gas[1 + NUM_GASES].note.ub.deco = 0; |
688 corrections++; | |
681 } | 689 } |
682 /* SSetpointLine setpoint[1 + NUM_GASES]; | 690 /* SSetpointLine setpoint[1 + NUM_GASES]; |
683 */ | 691 */ |
684 for(int i=1; i<=NUM_GASES;i++) | 692 for(int i=1; i<=NUM_GASES;i++) |
685 { | 693 { |
745 } // for(int i=1; i<=NUM_GASES;i++) | 753 } // for(int i=1; i<=NUM_GASES;i++) |
746 | 754 |
747 /* uint8_t CCR_Mode; | 755 /* uint8_t CCR_Mode; |
748 */ | 756 */ |
749 if( (Settings.CCR_Mode != CCRMODE_Sensors) && | 757 if( (Settings.CCR_Mode != CCRMODE_Sensors) && |
758 (Settings.CCR_Mode != CCRMODE_Simulation) && | |
750 (Settings.CCR_Mode != CCRMODE_FixedSetpoint)) | 759 (Settings.CCR_Mode != CCRMODE_FixedSetpoint)) |
751 { | 760 { |
752 Settings.CCR_Mode = CCRMODE_FixedSetpoint; | 761 Settings.CCR_Mode = CCRMODE_FixedSetpoint; |
753 corrections++; | 762 corrections++; |
754 } | 763 } |
1459 if(Settings.scrubTimerMode > SCRUB_TIMER_END) | 1468 if(Settings.scrubTimerMode > SCRUB_TIMER_END) |
1460 { | 1469 { |
1461 Settings.scrubTimerMode = SCRUB_TIMER_OFF; | 1470 Settings.scrubTimerMode = SCRUB_TIMER_OFF; |
1462 corrections++; | 1471 corrections++; |
1463 } | 1472 } |
1473 | |
1474 if((Settings.pscr_lung_ratio > PSCR_MAX_LUNG_RATIO) || (Settings.pscr_lung_ratio < PSCR_MIN_LUNG_RATIO)) | |
1475 { | |
1476 Settings.pscr_lung_ratio = 10; | |
1477 corrections++; | |
1478 } | |
1479 if(Settings.pscr_o2_drop > PSCR_MAX_O2_DROP) | |
1480 { | |
1481 Settings.pscr_o2_drop = 4; | |
1482 corrections++; | |
1483 } | |
1484 | |
1485 if(Settings.co2_sensor_active > 1) | |
1486 { | |
1487 Settings.co2_sensor_active = 0; | |
1488 corrections++; | |
1489 } | |
1490 | |
1491 if(corrections) | |
1492 { | |
1493 settingsWarning = 1; | |
1494 } | |
1495 else | |
1496 | |
1464 if(corrections > 255) | 1497 if(corrections > 255) |
1465 return 255; | 1498 { |
1466 else | 1499 corrections = 255; |
1467 return (uint8_t)corrections; | 1500 } |
1501 | |
1502 return (uint8_t)corrections; | |
1468 } | 1503 } |
1469 | 1504 |
1470 | 1505 |
1471 /* always at 0x8080000, do not move -> bootloader access */ | 1506 /* always at 0x8080000, do not move -> bootloader access */ |
1472 const SFirmwareData* firmwareDataGetPointer(void) | 1507 const SFirmwareData* firmwareDataGetPointer(void) |
2919 { | 2954 { |
2920 return 110; | 2955 return 110; |
2921 } | 2956 } |
2922 } | 2957 } |
2923 } | 2958 } |
2959 | |
2960 void reset_SettingWarning() | |
2961 { | |
2962 settingsWarning = 0; | |
2963 } | |
2964 inline uint8_t isSettingsWarning() | |
2965 { | |
2966 return settingsWarning; | |
2967 } | |
2968 |