PaulStoffregen / ILI9341_t3

Optimized ILI9341 TFT Library
http://pjrc.com/store/display_ili9341.html
242 stars 95 forks source link

Re-implement readRect to avoid RX FIFO overflow #40

Open mudaltsov opened 7 years ago

mudaltsov commented 7 years ago

This fixes https://github.com/PaulStoffregen/ILI9341_t3/issues/29

The implementation of readRect had an issue where it would not correctly read the last pixel from the screen. This was caused by an overflow in the RX FIFO while waiting for the EOQ flag in the last transmitted byte. The loop only counted transmitted bytes, so it would fill up the TX FIFO and not wait until the transfer actually happened. Waiting for EOQ competed the queued transfers and overflowed the RX FIFO since nothing was reading from it.

The new implementation explicitly tracks the number of RX and TX bytes to ensure that all bytes are correctly transmitted and received. A few ideas have been borrowed from KurtE/ILI9341_t3n as well: