I’m trying understand the Sprites in the TFT_eSPI library. The sample code I am trying below does not show the red color rectangle. Anyone could highlight what I am doing wrong here. Or if my understand and usage of Sprites here is wrong.
Btw, example tft_graphicstest_ine_lib in the TFT_eSPI library is working.
➜ the parent sprite spr_parent is explicitly filled with a background color (TFT_BLACK ) before pushing the child sprites
(The children are drawn into the parent sprite, so the parent acts as a canvas. If the parent is uninitialized, its undefined content could possibly interfere with the children when the parent is finally pushed to the screen).
(spr_child2 has a slightly smaller height and its push position starts at y = 51 instead of 50 so that we are not exceeding the parent sprite’s boundaries)
On an ESP32 the workspace RAM is more limited than the datasheet implies so a 16-bit colour Sprite is limited to about 200x200 pixels (~80Kbytes), an 8-bit sprite to 320x240 pixels (~76kbytes). A 1 bit per pixel Sprite requires only 9600 bytes for a full 320 x 240 screen buffer, this is ideal for supporting use with 2 colour bitmap fonts.
I mean your sprites should not be that big or full color.
the link shared above states
Sprites by default use 16-bit colours, the bit depth can be set to 8 bits (256 colours) , or 1 bit (any 2 colours) to reduce the RAM needed. On an ESP8266 the largest 16-bit colour Sprite that can be created is about 160x128 pixels, this consumes 40Kbytes of RAM. On an ESP32 the workspace RAM is more limited than the datasheet implies so a 16-bit colour Sprite is limited to about 200x200 pixels (~80Kbytes), an 8-bit sprite to 320x240 pixels (~76kbytes). A 1 bit per pixel Sprite requires only 9600 bytes for a full 320 x 240 screen buffer, this is ideal for supporting use with 2 colour bitmap fonts.
One or more sprites can be created, a sprite can be any pixel width and height, limited only by available RAM. The RAM needed for a 16-bit colour depth Sprite is (2 x width x height) bytes, for a Sprite with 8-bit colour depth the RAM needed is (width x height) bytes. Sprites can be created and deleted dynamically as needed in the sketch, this means RAM can be freed up after the Sprite has been plotted on the screen, more RAM intensive WiFi based code can then be run and normal graphics operations still work.
Would really depend on what kind of graphics you were displaying. You can draw shapes and print text directly to the display, although that may involve erasing portions of what is already on the screen. Could also be that the images are stored in flash memory and written to the display directly, instead of having to buffer through a sprite.