Skip to content

Commit

Permalink
Fix FAST_PWM_FAN / TouchUI with NO_MOTION_BEFORE_HOMING (MarlinFirmwa…
Browse files Browse the repository at this point in the history
  • Loading branch information
marciot authored and SMHRambo committed Feb 7, 2023
1 parent 6c52e81 commit 61633fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions Marlin/src/HAL/AVR/fast_pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
LIMIT(res_pc_temp, 1U, maxtop);

// Calculate frequencies of test prescaler and resolution values
const uint32_t f_diff = _MAX(f, f_desired) - _MIN(f, f_desired),
f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)),
f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired),
f_pc_temp = (F_CPU) / (2 * p * res_pc_temp),
f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired);
const int f_diff = ABS(f - int(f_desired)),
f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)),
f_fast_diff = ABS(f_fast_temp - int(f_desired)),
f_pc_temp = (F_CPU) / (2 * p * res_pc_temp),
f_pc_diff = ABS(f_pc_temp - int(f_desired));

if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f
// Set the Wave Generation Mode to FAST PWM
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ namespace ExtUI {
bool canMove(const axis_t axis) {
switch (axis) {
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
case X: return axis_should_home(X_AXIS);
OPTCODE(HAS_Y_AXIS, case Y: return axis_should_home(Y_AXIS))
OPTCODE(HAS_Z_AXIS, case Z: return axis_should_home(Z_AXIS))
case X: return !axis_should_home(X_AXIS);
OPTCODE(HAS_Y_AXIS, case Y: return !axis_should_home(Y_AXIS))
OPTCODE(HAS_Z_AXIS, case Z: return !axis_should_home(Z_AXIS))
#else
case X: case Y: case Z: return true;
#endif
Expand Down

0 comments on commit 61633fe

Please sign in to comment.