Fix for preheat selecting the wrong device #23467
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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