Skip to content

Commit

Permalink
Merge pull request #1164 from Ralim/settings
Browse files Browse the repository at this point in the history
Settings
  • Loading branch information
Ralim authored Jan 6, 2022
2 parents f85c62c + 3741804 commit fd7354d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
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

0 comments on commit fd7354d

Please sign in to comment.