Skip to content

Commit

Permalink
Merge pull request #1181 from Ralim/ralim/settings-patch
Browse files Browse the repository at this point in the history
Patch settings decrement to honour increment size and not skip max
  • Loading branch information
Ralim authored Jan 16, 2022
2 parents 77fe3f3 + d59db82 commit 96e30aa
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions source/Core/Src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,18 @@ bool nextSettingValue(const enum SettingsOptions option) {
// Return true if we are at the end (min)
bool prevSettingValue(const enum SettingsOptions option) {
const auto constants = settingsConstants[(int)option];
int value = systemSettings.settingsValues[(int)option];
if (value <= constants.min) {
value = constants.max;
if (systemSettings.settingsValues[(int)option] == (constants.min)) {
// Already at min, wrap to the max
systemSettings.settingsValues[(int)option] = constants.max;
} else if (systemSettings.settingsValues[(int)option] <= (constants.min + constants.increment)) {
// If within one increment of the start, constrain to the start
systemSettings.settingsValues[(int)option] = constants.min;
} else {
// Otherwise decrement
systemSettings.settingsValues[(int)option] -= constants.increment;
}
value -= constants.increment;
systemSettings.settingsValues[(int)option] = value;
return systemSettings.settingsValues[(int)option] == constants.min;
// Return if we are at the min
return constants.min == systemSettings.settingsValues[(int)option];
}
uint16_t lookupHallEffectThreshold() {
// Return the threshold above which the hall effect sensor is "activated"
Expand Down

0 comments on commit 96e30aa

Please sign in to comment.