KurtE / ILI9341_t3n

Extended ILI9341_T3 library (Teensy) including all SPI buses, Frame buffer, plus
MIT License
51 stars 23 forks source link

.readPixel(x, y) crashes Teensy 4.0 when using frame buffer #42

Closed PaulN8 closed 2 years ago

PaulN8 commented 2 years ago

Teensy 4.0 freezes then reboots when calling this function. I have found that by disabling the use of the frame buffer beforehand, the crash is avoided and everything works fine. So, for example:

uint16_t pix = tft.readPixel(x, y); // crashes T4.0

tft.useFrameBuffer(false); uint16_t pix = tft.readPixel(x, y); // works fine tft.useFrameBuffer(true);

I was sure to use the function to wait for async screen update to finish beforehand, even tried not using it at all, but it was not this. It is something to do with the frame buffer being used.

PaulN8 commented 2 years ago

Update: Perhaps not surprisingly this only happens when x or y are outside the range of the array (oops!). In some ways it's better that it does not handle this error as gracefully as readPixel without using FrameBuffer because that is why I missed a particular bug in my indexing! Change nothing, let it crash to force better code proofing!