Repository navigation
🐛 Fix negative int16 values on classic DGUS - #28748
Merged
thinkyhead merged 1 commit intoOct 25, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
DGUSDisplay::writeVariable(uint16_t, int16_t)swaps bytes with(value & 0xFFU) << 8U | (value >> 8U)on the signed value. For a negative value,value >> 8sign-extends, and the OR overwrites the high byte with0xFF. So most negative numbers reach the display wrong:FF FFFF FEFF FFFF 83FE FFFE D4This change sends the value through the existing
uint16_toverload, so the swap is done on an unsigned value.The path is used by
sendFloatAsIntValueToDisplay, e.g. for a negative probe Z offset shown with 2 decimals (-1.25 is sent as -125 and shows as -0.01).The CR6Community fork had already fixed this in its own copy of the DGUS code. I found it while porting that fork's work for #19958.
Requirements
A classic DGUS display:
DGUS_LCD_UIORIGIN,FYSETC,HIPRECYorMKS. DGUS Reloaded and the other DWIN UIs have their own code and aren't affected.Benefits
Negative values (e.g. Z offset) display correctly on classic DGUS screens.
Testing
int16_tvalues: 32640 values were wrong before, none after.mega2560exttests 1 (FYSETC) and 2 (MKS).Configurations
buildroot/tests/mega2560extconfig-01 / config-02.Related Issues
None filed. Found while working on #19958.