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

Settings #1164

Merged
merged 4 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion source/Core/Src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef struct {
uint16_t versionMarker;
uint16_t length; // Length of valid bytes following
uint16_t settingsValues[SettingsOptionsLength];
// used to make this nicely "good enough" aligned to 32 butes to make driver code trivial
// used to make this nicely "good enough" aligned to 32 bytes to make driver code trivial
uint32_t padding;

} systemSettingsType;
Expand Down
58 changes: 27 additions & 31 deletions source/Core/Threads/GUIThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,59 +202,55 @@ static void gui_solderingTempAdjust() {
break;
case BUTTON_B_LONG:
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = getSettingValue(SettingsOptions::TempChangeLongStep);
} else
delta = -getSettingValue(SettingsOptions::TempChangeLongStep);

delta = -getSettingValue(SettingsOptions::TempChangeLongStep);
autoRepeatTimer = xTaskGetTickCount();
autoRepeatAcceleration += PRESS_ACCEL_STEP;
}
break;
case BUTTON_B_SHORT:
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = getSettingValue(SettingsOptions::TempChangeShortStep);
} else
delta = -getSettingValue(SettingsOptions::TempChangeShortStep);
delta = -getSettingValue(SettingsOptions::TempChangeShortStep);
break;
case BUTTON_F_LONG:
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = -getSettingValue(SettingsOptions::TempChangeLongStep);
} else
delta = getSettingValue(SettingsOptions::TempChangeLongStep);
delta = getSettingValue(SettingsOptions::TempChangeLongStep);
autoRepeatTimer = xTaskGetTickCount();
autoRepeatAcceleration += PRESS_ACCEL_STEP;
}
break;
case BUTTON_F_SHORT:
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = -getSettingValue(SettingsOptions::TempChangeShortStep);
} else
delta = getSettingValue(SettingsOptions::TempChangeShortStep);
delta = getSettingValue(SettingsOptions::TempChangeShortStep);
break;
default:
break;
}
if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) < PRESS_ACCEL_INTERVAL_MIN) {
autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
}
// constrain between 10-450 C
uint16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp);
newTemp += delta;
if (getSettingValue(SettingsOptions::TemperatureInF)) {
if (newTemp > MAX_TEMP_F)
newTemp = MAX_TEMP_F;
if (newTemp < MIN_TEMP_F)
newTemp = MIN_TEMP_F;
} else {
if (newTemp > MAX_TEMP_C)
newTemp = MAX_TEMP_C;
if (newTemp < MIN_TEMP_C)
newTemp = MIN_TEMP_C;
// If buttons are flipped; flip the delta
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = -delta;
}
setSettingValue(SettingsOptions::SolderingTemp, newTemp);
if (delta != 0) {
// constrain between the set temp limits, i.e. 10-450 C
int16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp);
newTemp += delta;
// Round to nearest increment of delta
delta = abs(delta);
newTemp = (newTemp / delta) * delta;

if (getSettingValue(SettingsOptions::TemperatureInF)) {
if (newTemp > MAX_TEMP_F)
newTemp = MAX_TEMP_F;
if (newTemp < MIN_TEMP_F)
newTemp = MIN_TEMP_F;
} else {
if (newTemp > MAX_TEMP_C)
newTemp = MAX_TEMP_C;
if (newTemp < MIN_TEMP_C)
newTemp = MIN_TEMP_C;
}
setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp);
}
if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2))
return; // exit if user just doesn't press anything for a bit

Expand Down