Mercurial > public > ostc4
changeset 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 | c47fe41b2378 |
children | 9660df857c57 |
files | Common/Inc/settings.h Discovery/Src/base.c Discovery/Src/settings.c |
diffstat | 3 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/settings.h Mon Mar 27 10:04:53 2023 +0200 +++ b/Common/Inc/settings.h Wed Apr 12 09:24:44 2023 +0200 @@ -354,7 +354,7 @@ void set_new_settings_missing_in_ext_flash(void); uint8_t check_and_correct_settings(void); uint8_t newFirmwareVersionCheckViaSettings(void); -void set_settings_button_to_standard_with_individual_buttonBalance(void); +void set_settings_button_to_factory_with_individual_buttonBalance(void); uint8_t getLicence(void); void firmwareGetDate(RTC_DateTypeDef *SdateOutput);
--- a/Discovery/Src/base.c Mon Mar 27 10:04:53 2023 +0200 +++ b/Discovery/Src/base.c Wed Apr 12 09:24:44 2023 +0200 @@ -381,7 +381,7 @@ if( newFirmwareVersionCheckViaSettings() ) // test for old firmware version in loaded settings { wasFirmwareUpdateCheckBattery = 1; - set_settings_button_to_standard_with_individual_buttonBalance(); // will adapt individual values + set_settings_button_to_factory_with_individual_buttonBalance(); // will adapt individual values } //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */ //settingsGetPointer()->compassBearing = 0;
--- a/Discovery/Src/settings.c Mon Mar 27 10:04:53 2023 +0200 +++ b/Discovery/Src/settings.c Wed Apr 12 09:24:44 2023 +0200 @@ -27,6 +27,8 @@ ////////////////////////////////////////////////////////////////////////////// #include <string.h> +#include <stdbool.h> + #include "settings.h" #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP @@ -559,9 +561,29 @@ } -void set_settings_button_to_standard_with_individual_buttonBalance(void) +void set_settings_button_to_factory_with_individual_buttonBalance(void) { - settingsHelperButtonSens_keepPercentageValues(SettingsStandard.ButtonResponsiveness[3], settingsGetPointer()->ButtonResponsiveness); + bool factoryBalanceSettingsValid = true; + unsigned i = 0; + while (factoryBalanceSettingsValid && i < 3) { + if (Settings.FactoryButtonBalance[i] < 2 || Settings.FactoryButtonBalance[i] > 5) { + factoryBalanceSettingsValid = false; + } + + i++; + } + if (factoryBalanceSettingsValid) { + for (i = 0; i < 3; i++) { + Settings.buttonBalance[i] = Settings.FactoryButtonBalance[i]; + } + } + + uint8_t buttonResponsiveness = Settings.FactoryButtonBase; + if (buttonResponsiveness < 70 || buttonResponsiveness > 110) { + buttonResponsiveness = SettingsStandard.ButtonResponsiveness[3]; + } + + settingsHelperButtonSens_keepPercentageValues(buttonResponsiveness, settingsGetPointer()->ButtonResponsiveness); }