Detecting when a sprite is not created due to available RAM shortage #2681
-
I am working with a ESP32-2432S028 display. I have a 8 bit, 240x240 sprite that I've used on Pico 2040 with no issues. With this display, I get a "0" displayed in the upper right hand corner (0,0) of the TFT (tft is rotated to 320x240) . This is in an area outside of the sprite. It only happens when I go into that mode the first time after boot. When I come back to that mode from elsewhere in the program, the "0" is gone. The "0" is displayed in the last used font and color used in the sprite code just before it gets pushed. Frankly, I've been working on this one little error for days....Any easy ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
After further investigation, the "0" is actually the last character, of the last string printed to the sprite before PUSH. It's almost like what ever is last printed to the sprite is also getting printed to TFT at 0,0 |
Beta Was this translation helpful? Give feedback.
-
After more work, this only happens when using smooth fonts. Free fonts only render to the sprite with no extra characters on the TFT. |
Beta Was this translation helpful? Give feedback.
-
Provide a complete sketch that demonstrates the problem. |
Beta Was this translation helpful? Give feedback.
If there is insufficient memory for a sprite to be created then the subsequent behaviour will most likely be wrong. In this case the sprite does not exist, the library creates a sprite for you to contain each character and plots each one to the screen at the cursor position (default is 0,0). In this case the 0 is the last character and the remains of the "A" can also be seen.
The amount of memory available varies as a program runs. The simplest approach during program development and when swapping processors (that have different available RAM pools) is to trap whether the sprite is created and/or print available memory to ensure the program has a generous margin in all circumstances. This…