comparison Discovery/Src/settings.c @ 788:4abfb8a2a435

Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
author heinrichsweikamp
date Tue, 04 Jul 2023 14:39:06 +0200
parents 45b8f3c2acce
children 25103f5c7e29
comparison
equal deleted inserted replaced
787:aeb72882f30a 788:4abfb8a2a435
25 /// You should have received a copy of the GNU General Public License 25 /// You should have received a copy of the GNU General Public License
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 ////////////////////////////////////////////////////////////////////////////// 27 //////////////////////////////////////////////////////////////////////////////
28 28
29 #include <string.h> 29 #include <string.h>
30 #include <stdbool.h>
31 30
32 #include "settings.h" 31 #include "settings.h"
33 #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS 32 #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS
34 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP 33 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP
35 #include "text_multilanguage.h" // for LANGUAGE_END 34 #include "text_multilanguage.h" // for LANGUAGE_END
332 .ext_sensor_map[2] = SENSOR_OPTIC, 331 .ext_sensor_map[2] = SENSOR_OPTIC,
333 .ext_sensor_map[3] = SENSOR_NONE, 332 .ext_sensor_map[3] = SENSOR_NONE,
334 .ext_sensor_map[4] = SENSOR_NONE, 333 .ext_sensor_map[4] = SENSOR_NONE,
335 .buttonLockActive = 0, 334 .buttonLockActive = 0,
336 .compassDeclinationDeg = 0, 335 .compassDeclinationDeg = 0,
336 .delaySetpointLow = false,
337 }; 337 };
338 338
339 /* Private function prototypes -----------------------------------------------*/ 339 /* Private function prototypes -----------------------------------------------*/
340 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to); 340 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to);
341 341
535 // no break; 535 // no break;
536 case 0xFFFF0024: pSettings->buttonLockActive = 0; 536 case 0xFFFF0024: pSettings->buttonLockActive = 0;
537 // no break; 537 // no break;
538 case 0xFFFF0025: 538 case 0xFFFF0025:
539 pSettings->compassDeclinationDeg = pStandard->compassDeclinationDeg; 539 pSettings->compassDeclinationDeg = pStandard->compassDeclinationDeg;
540 pSettings->delaySetpointLow = pStandard->delaySetpointLow;
540 541
541 // no break; 542 // no break;
542 default: 543 default:
543 pSettings->header = pStandard->header; 544 pSettings->header = pStandard->header;
544 break; // no break before!! 545 break; // no break before!!
587 if (buttonResponsiveness < 70 || buttonResponsiveness > 110) { 588 if (buttonResponsiveness < 70 || buttonResponsiveness > 110) {
588 buttonResponsiveness = SettingsStandard.ButtonResponsiveness[3]; 589 buttonResponsiveness = SettingsStandard.ButtonResponsiveness[3];
589 } 590 }
590 591
591 settingsHelperButtonSens_keepPercentageValues(buttonResponsiveness, settingsGetPointer()->ButtonResponsiveness); 592 settingsHelperButtonSens_keepPercentageValues(buttonResponsiveness, settingsGetPointer()->ButtonResponsiveness);
593 }
594
595
596 bool checkAndFixSetpointSettings(void)
597 {
598 SSettings *settings = settingsGetPointer();
599
600 bool fixed = false;
601 if (settings->autoSetpoint) {
602 SSetpointLine *setpointLow = &settings->setpoint[SETPOINT_INDEX_AUTO_LOW];
603 if (setpointLow->setpoint_cbar >= 100) {
604 setpointLow->setpoint_cbar = 70;
605
606 fixed = true;
607 }
608 if (setpointLow->depth_meter == 0 || setpointLow->depth_meter > 100) {
609 setpointLow->depth_meter = 2;
610
611 fixed = true;
612 }
613 SSetpointLine *setpointHigh = &settings->setpoint[SETPOINT_INDEX_AUTO_HIGH];
614 if (setpointHigh->setpoint_cbar <= setpointLow->setpoint_cbar) {
615 setpointHigh->setpoint_cbar = 130;
616
617 fixed = true;
618 }
619 if (setpointHigh->depth_meter <= setpointLow->depth_meter) {
620 setpointHigh->depth_meter = setpointLow->depth_meter + 6;
621
622 fixed = true;
623 }
624
625 SSetpointLine *setpointDeco = &settings->setpoint[SETPOINT_INDEX_AUTO_DECO];
626 if (setpointDeco->note.ub.active) {
627 if (setpointDeco->setpoint_cbar == setpointHigh->setpoint_cbar || setpointDeco->setpoint_cbar == setpointLow->setpoint_cbar) {
628 setpointDeco->setpoint_cbar = 10 * (setpointHigh->setpoint_cbar / 10) - 10;
629 if (setpointDeco->setpoint_cbar == setpointLow->setpoint_cbar) {
630 setpointDeco->setpoint_cbar += 5;
631 }
632
633 fixed = true;
634 }
635 }
636 }
637
638 return fixed;
592 } 639 }
593 640
594 641
595 uint8_t check_and_correct_settings(void) 642 uint8_t check_and_correct_settings(void)
596 { 643 {
764 if(Settings.setpoint[i].depth_meter > 250) 811 if(Settings.setpoint[i].depth_meter > 250)
765 { 812 {
766 Settings.setpoint[i].depth_meter = 250; 813 Settings.setpoint[i].depth_meter = 250;
767 corrections++; 814 corrections++;
768 } 815 }
769 if(Settings.setpoint[i].note.ub.deco)
770 {
771 if(Settings.setpoint[i].note.ub.active != 1)
772 {
773 Settings.setpoint[i].note.ub.active = 1;
774 corrections++;
775 }
776 if(Settings.setpoint[i].note.ub.travel == 1)
777 {
778 Settings.setpoint[i].note.ub.travel = 0;
779 corrections++;
780 }
781 }
782 if(Settings.setpoint[i].note.ub.travel)
783 {
784 if(Settings.setpoint[i].note.ub.active != 1)
785 {
786 Settings.setpoint[i].note.ub.active = 1;
787 corrections++;
788 }
789 if(Settings.setpoint[i].note.ub.deco == 1)
790 {
791 Settings.setpoint[i].note.ub.deco = 0;
792 corrections++;
793 }
794 }
795 if(Settings.setpoint[i].note.ub.first)
796 {
797 if(Settings.setpoint[i].note.ub.active != 1)
798 {
799 Settings.setpoint[i].note.ub.active = 1;
800 corrections++;
801 }
802 if(Settings.setpoint[i].note.ub.travel == 1)
803 {
804 Settings.setpoint[i].note.ub.travel = 0;
805 corrections++;
806 }
807 if(Settings.setpoint[i].note.ub.deco == 1)
808 {
809 Settings.setpoint[i].note.ub.deco = 0;
810 corrections++;
811 }
812 }
813 } // for(int i=1; i<=NUM_GASES;i++) 816 } // for(int i=1; i<=NUM_GASES;i++)
817
818 if (checkAndFixSetpointSettings()) {
819 corrections++;
820 }
814 821
815 /* uint8_t CCR_Mode; 822 /* uint8_t CCR_Mode;
816 */ 823 */
817 if( (Settings.CCR_Mode != CCRMODE_Sensors) && 824 if( (Settings.CCR_Mode != CCRMODE_Sensors) &&
818 (Settings.CCR_Mode != CCRMODE_Simulation) && 825 (Settings.CCR_Mode != CCRMODE_Simulation) &&
3068 } 3075 }
3069 inline uint8_t isSettingsWarning() 3076 inline uint8_t isSettingsWarning()
3070 { 3077 {
3071 return settingsWarning; 3078 return settingsWarning;
3072 } 3079 }
3073