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

Fix for preheat selecting the wrong device #23467

Closed
wants to merge 2 commits into from
Closed

Fix for preheat selecting the wrong device #23467

wants to merge 2 commits into from

Conversation

DragRedSim
Copy link
Contributor

Originally caused by the TEST() macro bitshifting the second value once more before comparison
Fix changes values sent to the macro, and performs the bitshifting as part of function invocation

Description

The current workflow is selecting the wrong device when put through the function apply_preheat() and its shortcuts. This is caused by the apply_preheat() function using the TEST() macro, which bit-shifts the second argument passed to it before comparison. Rather than modify the macro (since it is used in other parts of Marlin), it is better to manipulate the constants used.

Previously, the masking values were constantly increasing by powers of two via bitshifting. However, the TEST() macro would then bit-shift them again as part of its comparison. This PR changes them to increasing by one, such that the only round of bitshifting done is in the TEST() macro. To facilitate this, the pmask value is bit-shifted at the time of calling the shortcut functions.

Bitshift operations performed

pmask compared constant
Current One (as part of definition of the constants) Two (one as definition of constants, one as part of TEST() macro)
PR One (as part of the function call to apply_preheat() ) One (as part of TEST() macro)

Requirements

Any board/interface using these functions in marlinui.cpp/marlinui.h

Benefits

This ensures that the preheat commands are run on the expected devices (bed, nozzle, fan). Before changes, a call to preheat_hotend does nothing, while a call to preheat_bed will trigger preheat on the hotend, and a call to preheat_set_fan will trigger the bed.

Configurations

N/A

Related Issues

Fixes Jyers#1651

# Originally caused by the TEST() macro bitshifting the second value once more before comparison
# Fix changes values sent to the macro, and performs the bitshifting as part of function invocation
# TERN_(ANY()) failed to compile on LPC1769, reverted
@thinkyhead
Copy link
Member

There is a bug in GitHub where a PR from a fork of a fork cannot be modified by admins. Since your fork is derived from the Jyers fork of Marlin, this PR is manifesting that bug. So, to edit and merge this, I will need to close this PR and do the merge directly.

@DragRedSim
Copy link
Contributor Author

Understood; I see the changes have been taken on board and merged both to bugfix and mainline manually. Thanks for all the major work you put in on Marlin itself!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants