Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch settings decrement to honour increment size and not skip max #1181

Merged
merged 1 commit into from
Jan 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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