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

[BUG] Fan calculation macro uses defines that do not exist yet (wrong import order) #25347

Closed
1 task done
lukaskuzmiak opened this issue Feb 6, 2023 · 4 comments · Fixed by #25731
Closed
1 task done

Comments

@lukaskuzmiak
Copy link

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

Pull request #24873 moved the CALC_FAN_SPEED macro into Marlin/src/inc/Conditionals_adv.h, the macro however, makes use of FAN_MIN_PWM, FAN_MAX_PWM and FAN_OFF_PWM which are undefined by default. The values for these defines are "fixed" (if undefined) in Conditionals_post.h (lines 2707-2731). But Conditionals_post.h is only imported after Conditionals_adv.h.

Therefore, in the default case of undefined FAN_MIN_PWM, FAN_MAX_PWM or FAN_OFF_PWM the current macro for CALC_FAN_SPEED always falls into the "else" clause because MIN/MAX are undefined:

#if FAN_MIN_PWM == 0 && FAN_MAX_PWM == 255
  #define CALC_FAN_SPEED(f) (f ?: FAN_OFF_PWM)
#else
  #define CALC_FAN_SPEED(f) (f ? map(f, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM)
#endif

I am not sure where would be a good place for the CALC_FAN_SPEED, I'll be happy to submit a pull-request if anyone has a suggestion.

Bug Timeline

No response

Expected behavior

No response

Actual behavior

No response

Steps to Reproduce

No response

Version of Marlin Firmware

2.1.2

Printer model

No response

Electronics

No response

Add-ons

No response

Bed Leveling

None

Your Slicer

None

Host Software

None

Don't forget to include

  • A ZIP file containing your Configuration.h and Configuration_adv.h.

Additional information & file uploads

No response

@sjasonsmith
Copy link
Contributor

Can you confirm whether this is still an issue? If so, please attach configuration files which can be used to reproduce this.

@sjasonsmith sjasonsmith added the Needs: More Data We need more data in order to proceed label Apr 1, 2023
@GMagician
Copy link
Contributor

I did some test and it seems confirmed with latest bugfix

@GMagician
Copy link
Contributor

@sjasonsmith you may use any configuration you want, I used mine, just comment out FAN_MIN_PWM and FAN_MAX_PWM in your "Configuration_adv.h" file and check which 'CALC_FAN_SPEED' branch is compiled (I added a simple #error but intellisense already display it)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants