Any known issues with readRect() to read screen data? #1023
-
As the title states, I am having problems with the readRect() function, but it is a complex problem. I wrote a library to draw a pop-up window on my display. The library uses readRect() to read the screen data before drawing the pop-up window. When the pop-up window should be erased from the display, I use pushRect() to re-draw the area of the screen where the pop-up window was. The code works great and I'm attaching it here. The problem I am having is when I add that library to my main project, which is kind of complex. When my project calls the readRect(), it crashes the ESP32. The crash produces an error message with a backtrace, see here - https://www.esp32.com/viewtopic.php?f=19&t=19355 According to that data, my code was crashing on a task I have running on core0. When I disable the code running on core0, now when the crash occurs, it's a WDT reset. So I'm a bit confused as to what is happening. Anyone have any idea what might be going on here? I do have a debugger on order and I am switching to PlatformIO IDE to look into this problem, but if anyone has any advice, I'd love to hear it! Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
This sounds like a memory issue since it worked in a simpler environment. Screen buffers take a lot of memory. Make sure you can reserve enough space for the readRect data. Note that if you are trying to run RTOS tasks (or use TFT_eSPI across both processors) that TFT_eSPI is not thread safe. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply! I was thinking memory issue too, but after further testing, I'm not so sure that it's a memory problem. I'm using the ESP32's huge_app.cvs partition scheme, compiled it's using 10% ram and 35% flash memory. The size of the screen I'm trying to copy is 160x140 pixels, which would use 22.4k of memory. So I should have enough room to store that data. I do have code running on both cores, but all the code is separated and not shared between cores. I have experienced crashes when I tried to share code between the cores, and learned to keep the code between the cores separated. My current problem is not that kind of crash that you get when trying to share code between cores. I'm still looking into the problem, but it does appear to be a problem after my call to readRect(). So it's probably my code and not your library that is causing the crash. Currently, I'm getting a WDT reboot after the readRect() call and a couple of other lines of code execute. Is there any way to trace what triggers a WDT reboot? |
Beta Was this translation helpful? Give feedback.
-
"Each pixel requires 2 bytes so the memory demand will be 44.8kBytes." This is the problem, I was a bit confused about the data type and size of the buffer. I was defining the buffer like so: Thank you for the discussion, and a bigger thank you for the library! |
Beta Was this translation helpful? Give feedback.
This sounds like a memory issue since it worked in a simpler environment. Screen buffers take a lot of memory. Make sure you can reserve enough space for the readRect data.
Note that if you are trying to run RTOS tasks (or use TFT_eSPI across both processors) that TFT_eSPI is not thread safe.