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

Bit mask bug in Epd::SetPartialWindow causes visual glitch at certain coordinates #330

Open
LingDong- opened this issue Feb 14, 2024 · 0 comments

Comments

@LingDong-
Copy link

LingDong- commented Feb 14, 2024

Dear Waveshare team,

I believe there is a bug in Epd::SetPartialWindow (in Arduino/epd4in2b_V2, and probably a few other demos) that causes a visual glitch.

More specifically, these two lines:

https://github.com/waveshareteam/e-Paper/blob/master/Arduino/epd4in2b_V2/epd4in2b_V2.cpp#L107

SendData(((x & 0xf8) + w  - 1) >> 8);
SendData(((x & 0xf8) + w  - 1) | 0x07);

Should be changed to:

SendData(((x & 0xff8) + w  - 1) >> 8);
SendData(((x & 0xff8) + w  - 1) | 0x07);

The glitch occurs when x is smaller than 255 and x+w is larger than 255, x & 0xf8 will clear all the bits above 8, which will make the computed HRED smaller than HRST, violating the datasheet. The result on the screen looks like jagged strips of torn pieces. To reproduce the glitched effect, one can change the number 200 to 280 in this line:

epd.SetPartialWindowRed(paint.GetImage(), 280, 200, paint.GetWidth(), paint.GetHeight());

The bug can be easily fixed with a larger mask that does not discard the higher bits, e.g. 0xff8 or 0xfff8 etc. I've confirmed that this works on the 4.2inch module.

Thank you for publishing these demos, and for taking a look at this issue! Please feel free to let me know if I missed anything.

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

No branches or pull requests

1 participant