fix 9-bit spi data corruption by padding no-op#763
fix 9-bit spi data corruption by padding no-op#763Eggrror404 wants to merge 1 commit intomoononournation:masterfrom
Conversation
- ensured buffer is byte-aligned by padding no-op commands before
flushing
- in writeRepeat loop, made sure all data is properly sent in bytes
- done by (1) padding existing buffer data with requested ones, (2)
flushing the existing data, then (3) sending out packed up buffer
repeatedly
|
make it simple, is it can do the job if set buffer to zero while init and after flush? |
I believe it has to be a no-op command (9 zeros at once), not just setting the buffer to zero. for example, to send a If we leave the 7 empty slots ( This is what happens currently, to my understanding. So I'm deliberately appending no-op commands until byte borders to ensure that doesn't happen, and it seemed to work. |
|
How can I test it works? |
To test this, you'll need a display that uses 3-wire SPI interface. void setup(void)
{
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX Hello World example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(RGB565_BLACK);
gfx->setCursor(10, 10);
gfx->setTextColor(RGB565_RED);
gfx->println("Hello World!");
delay(5000); // 5 seconds
}Without this PR, the display can't initialize at all and my display simply stays white (only backlight turns on). And with my patches, the display is correctly painted black and wrote "Hello World".
The original issue is caused by the exact reason I wrote in the last message. This PR does fix it. |
closes #754
As described in the issue, this is the fix that appends zeros into the buffer to prevent breakage.
The implementation in writeRepeat() is more complicated because (1) there may be leftover data to flush and we can't pad zeros there and (2) half-pixels are transferred between transactions. And the difference between ESP32 boards makes the implementation even look more complicated.
But I tested it with continuous fillScreen() calls and it seemed to work fine. I'm getting ~80 fps on my ESP32C3 board, it should be pretty solid.