Thanks David. I haven't seen anything related to what I want to do in Bodmer's examples, that's why I asked the question.
I tried, but it seems the saved portion of the image is full black.
Here is the code doing it:
TFT_eSPI tft = TFT_eSPI(135, 240); // Invoke custom library
TFT_eSprite img = TFT_eSprite(&tft); // Sprite object
uint16_t bg[400] = {0};
void setup() {
tft.begin();
tft.setRotation(0); // 0 & 2 Portrait. 1 & 3 landscape
tft.fillScreen(TFT_BLACK);
drawBmp("/Sapin.bmp", 0, 0);
int x = 60;
int y = 10;
// Move 1 sprite containing a "transparent" colour
for (int i = 0; i < 100; i++)
{
tft.readRect(x, y, 20, 20, bg);
drawStar(x, y);
delay(100);
tft.pushRect(x, y, 20, 20, bg);
++y;
}
}
void loop() {
}
drawStar only draws a red X at given location, and I can see it moving down the display, but on a black background:
void drawStar(int x, int y)
{
img.setColorDepth(8);
img.createSprite(20, 20);
img.fillSprite(TFT_TRANSPARENT);
img.drawLine(0, 0, 20, 20, TFT_RED);
img.drawLine(0, 20, 20, 0, TFT_RED);
img.pushSprite(x, y, TFT_TRANSPARENT);
// Delete it to free memory
img.deleteSprite();
}
If I comment the call to drawStar, I just see a black square moving down, so the problem lies in the read / push pair.
When I print the content of the bg array, it's all zeros.