e-Paper icon indicating copy to clipboard operation
e-Paper copied to clipboard

SRAM address calculated incorrectly in Arduino/epd4in2b_V2 .

Open o-gb opened this issue 4 years ago • 0 comments

in file /aveshare/e-Paper/Arduino/epd4in2b_V2/epd4in2b_V2.cpp in functions Epd::SetPartialWindow(...) Lines 107 and 108 Epd::SetPartialWindowBlack(...) Lines 140 and 141 Epd::SetPartialWindowRed(...) Lines 166 and 167 allway the same statements: SendData(((x & 0xf8) + w - 1) >> 8); SendData(((x & 0xf8) + w - 1) | 0x07);

If the x-value is bigger than 255 the data sended are incorrect. 
The 0x100 bit of x are allways cleared. 
So you can't send smal pices of data to the higher part of SRAM.

Solution: change this statements to SendData((x + w - 1) >> 8); SendData(((x + w - 1) & 0xf8) | 0x07);

In my installation I changed the entire range in all 3 functions for safe x/y values to: SendData((x >> 8) & 0x01); SendData(x & 0xf8); // x should be the multiple of 8, the last 3 bit will always be ignored SendData(((x + w - 1) >> 8) & 0x01); SendData(((x + w - 1) & 0xf8) | 0x07); SendData((y >> 8) & 0x01); SendData(y & 0xff); SendData(((y + l - 1) >> 8) & 0x01); SendData((y + l - 1) & 0xff);

I did not check if this error was also present in other EPD drivers in this project.

o-gb avatar Oct 28 '21 15:10 o-gb