comparison Discovery/Src/settings.c @ 765:da8126d5ea9f

After a firmware update, use the factory settings for button sensitivity if these exist, the default settings otherwise. The factory settings for the buttons can be updated in the System menu / Reset menu / Maintenance / 'Store button factory defaults'.
author heinrichsweikamp
date Wed, 12 Apr 2023 09:24:44 +0200
parents 32529dfea3b0
children dfdfea8897f3
comparison
equal deleted inserted replaced
764:c47fe41b2378 765:da8126d5ea9f
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 #include "settings.h" 32 #include "settings.h"
31 #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS 33 #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS
32 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP 34 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP
33 #include "text_multilanguage.h" // for LANGUAGE_END 35 #include "text_multilanguage.h" // for LANGUAGE_END
34 #include "tHome.h" // for CVIEW_END 36 #include "tHome.h" // for CVIEW_END
557 559
558 return 0; 560 return 0;
559 } 561 }
560 562
561 563
562 void set_settings_button_to_standard_with_individual_buttonBalance(void) 564 void set_settings_button_to_factory_with_individual_buttonBalance(void)
563 { 565 {
564 settingsHelperButtonSens_keepPercentageValues(SettingsStandard.ButtonResponsiveness[3], settingsGetPointer()->ButtonResponsiveness); 566 bool factoryBalanceSettingsValid = true;
567 unsigned i = 0;
568 while (factoryBalanceSettingsValid && i < 3) {
569 if (Settings.FactoryButtonBalance[i] < 2 || Settings.FactoryButtonBalance[i] > 5) {
570 factoryBalanceSettingsValid = false;
571 }
572
573 i++;
574 }
575 if (factoryBalanceSettingsValid) {
576 for (i = 0; i < 3; i++) {
577 Settings.buttonBalance[i] = Settings.FactoryButtonBalance[i];
578 }
579 }
580
581 uint8_t buttonResponsiveness = Settings.FactoryButtonBase;
582 if (buttonResponsiveness < 70 || buttonResponsiveness > 110) {
583 buttonResponsiveness = SettingsStandard.ButtonResponsiveness[3];
584 }
585
586 settingsHelperButtonSens_keepPercentageValues(buttonResponsiveness, settingsGetPointer()->ButtonResponsiveness);
565 } 587 }
566 588
567 589
568 uint8_t check_and_correct_settings(void) 590 uint8_t check_and_correct_settings(void)
569 { 591 {